2018-02-12 12:10:16 +00:00
|
|
|
<template>
|
2018-09-18 17:32:44 +00:00
|
|
|
<div class="notifications" v-hotkey.global="keymap">
|
2018-11-08 18:44:35 +00:00
|
|
|
<button :data-active="isOpen" @click="toggle" :title="$t('title')">
|
2018-11-05 16:40:11 +00:00
|
|
|
<i class="bell"><fa :icon="['far', 'bell']"/></i>
|
|
|
|
<i class="circle" v-if="hasUnreadNotification"><fa icon="circle"/></i>
|
2018-02-12 12:10:16 +00:00
|
|
|
</button>
|
2018-02-20 13:53:34 +00:00
|
|
|
<div class="pop" v-if="isOpen">
|
2018-02-12 12:10:16 +00:00
|
|
|
<mk-notifications/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-08 18:44:35 +00:00
|
|
|
import i18n from '../../../i18n';
|
2018-02-12 12:10:16 +00:00
|
|
|
import contains from '../../../common/scripts/contains';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 18:44:35 +00:00
|
|
|
i18n: i18n('desktop/views/components/ui.header.notifications.vue'),
|
2018-02-12 12:10:16 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2018-05-28 16:22:39 +00:00
|
|
|
isOpen: false
|
2018-02-12 12:10:16 +00:00
|
|
|
};
|
|
|
|
},
|
2018-09-18 17:32:44 +00:00
|
|
|
|
2018-05-28 16:22:39 +00:00
|
|
|
computed: {
|
|
|
|
hasUnreadNotification(): boolean {
|
|
|
|
return this.$store.getters.isSignedIn && this.$store.state.i.hasUnreadNotification;
|
2018-09-18 17:32:44 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
keymap(): any {
|
|
|
|
return {
|
|
|
|
'shift+n': this.toggle
|
|
|
|
};
|
2018-02-12 12:10:16 +00:00
|
|
|
}
|
|
|
|
},
|
2018-09-18 17:32:44 +00:00
|
|
|
|
2018-02-12 12:10:16 +00:00
|
|
|
methods: {
|
|
|
|
toggle() {
|
|
|
|
this.isOpen ? this.close() : this.open();
|
|
|
|
},
|
|
|
|
|
|
|
|
open() {
|
|
|
|
this.isOpen = true;
|
2018-12-11 11:36:55 +00:00
|
|
|
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
2018-02-12 12:10:16 +00:00
|
|
|
el.addEventListener('mousedown', this.onMousedown);
|
2018-12-11 11:36:55 +00:00
|
|
|
}
|
2018-02-12 12:10:16 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
close() {
|
|
|
|
this.isOpen = false;
|
2018-12-11 11:36:55 +00:00
|
|
|
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
2018-02-12 12:10:16 +00:00
|
|
|
el.removeEventListener('mousedown', this.onMousedown);
|
2018-12-11 11:36:55 +00:00
|
|
|
}
|
2018-02-12 12:10:16 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onMousedown(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (!contains(this.$el, e.target) && this.$el != e.target) this.close();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-27 06:19:11 +00:00
|
|
|
.notifications
|
2018-02-12 12:10:16 +00:00
|
|
|
> button
|
|
|
|
display block
|
|
|
|
margin 0
|
|
|
|
padding 0
|
|
|
|
width 32px
|
2018-09-27 06:19:11 +00:00
|
|
|
color var(--desktopHeaderFg)
|
2018-02-12 12:10:16 +00:00
|
|
|
border none
|
|
|
|
background transparent
|
|
|
|
cursor pointer
|
|
|
|
|
|
|
|
*
|
|
|
|
pointer-events none
|
|
|
|
|
|
|
|
&:hover
|
|
|
|
&[data-active='true']
|
2018-09-27 06:19:11 +00:00
|
|
|
color var(--desktopHeaderHoverFg)
|
2018-02-12 12:10:16 +00:00
|
|
|
|
2018-11-05 16:40:11 +00:00
|
|
|
> i.bell
|
2018-02-12 12:10:16 +00:00
|
|
|
font-size 1.2em
|
|
|
|
line-height 48px
|
|
|
|
|
2018-11-05 16:40:11 +00:00
|
|
|
> i.circle
|
2018-02-12 12:10:16 +00:00
|
|
|
margin-left -5px
|
|
|
|
vertical-align super
|
|
|
|
font-size 10px
|
2018-09-26 11:19:35 +00:00
|
|
|
color var(--primary)
|
2018-02-12 12:10:16 +00:00
|
|
|
|
2018-02-20 13:53:34 +00:00
|
|
|
> .pop
|
2018-09-26 11:28:13 +00:00
|
|
|
$bgcolor = var(--face)
|
2018-02-12 12:10:16 +00:00
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
top 56px
|
|
|
|
right -72px
|
|
|
|
width 300px
|
2018-04-19 22:45:37 +00:00
|
|
|
background $bgcolor
|
2018-02-12 12:10:16 +00:00
|
|
|
border-radius 4px
|
2018-04-28 23:51:17 +00:00
|
|
|
box-shadow 0 1px 4px rgba(#000, 0.25)
|
2018-02-12 12:10:16 +00:00
|
|
|
|
|
|
|
&:before
|
|
|
|
content ""
|
|
|
|
pointer-events none
|
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
top -28px
|
|
|
|
right 74px
|
|
|
|
border-top solid 14px transparent
|
|
|
|
border-right solid 14px transparent
|
2018-04-28 23:51:17 +00:00
|
|
|
border-bottom solid 14px rgba(#000, 0.1)
|
2018-02-12 12:10:16 +00:00
|
|
|
border-left solid 14px transparent
|
|
|
|
|
|
|
|
&:after
|
|
|
|
content ""
|
|
|
|
pointer-events none
|
|
|
|
display block
|
|
|
|
position absolute
|
|
|
|
top -27px
|
|
|
|
right 74px
|
|
|
|
border-top solid 14px transparent
|
|
|
|
border-right solid 14px transparent
|
2018-04-19 22:45:37 +00:00
|
|
|
border-bottom solid 14px $bgcolor
|
2018-02-12 12:10:16 +00:00
|
|
|
border-left solid 14px transparent
|
|
|
|
|
2018-02-16 18:01:00 +00:00
|
|
|
> .mk-notifications
|
2018-02-12 12:10:16 +00:00
|
|
|
max-height 350px
|
|
|
|
font-size 1rem
|
|
|
|
overflow auto
|
|
|
|
|
|
|
|
</style>
|