Passed
Branch master (32b4c5)
by Askupa
01:33
created

src/js/components/notifier.js   A

Complexity

Total Complexity 8
Complexity/F 1.33

Size

Lines of Code 33
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 33
rs 10
wmc 8
mnd 1
bc 6
fnc 6
bpm 1
cpm 1.3333
noi 3
1
Mivhak.component('notifier', {
2
    template: '<div class="mivhak-notifier"></div>',
3
    methods: {
4
        notification: function(html) {
5
            if(!html) return;
6
            clearTimeout(this.timeout);
7
            this.$el.off('click');
8
            this.$el.html(html);
9
            this.$el.addClass('mivhak-visible');
10
        },
11
        timedNotification: function(html, timeout) {
12
            var $this = this;
13
            this.notification(html);
14
            this.timeout = setTimeout(function(){
15
                $this.hide();
16
            },timeout);
17
        },
18
        closableNotification: function(html, onclick)
19
        {
20
            var $this = this;
21
            this.notification(html);
22
            this.$el.addClass('mivhak-button');
23
            this.$el.click(function(e){
24
                $this.hide();
25
                if(typeof onclick !== 'undefined')
26
                    onclick.call(null, e);
27
            });
28
        },
29
        hide: function() {
30
            this.$el.removeClass('mivhak-visible mivhak-button');
31
        }
32
    }
33
});