src/js/components/toggle.js   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 1.33

Size

Lines of Code 20
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 2
dl 0
loc 20
rs 10
wmc 4
mnd 1
bc 3
fnc 3
bpm 1
cpm 1.3333
noi 1

3 Functions

Rating   Name   Duplication   Size   Complexity  
A Mivhak.component(ꞌtoggleꞌ).methods.toggle 0 4 1
A Mivhak.component(ꞌtoggleꞌ).created 0 3 2
A Mivhak.component(ꞌtoggleꞌ).events.click 0 3 1
1
Mivhak.component('toggle', {
0 ignored issues
show
Bug introduced by
The variable Mivhak seems to be never declared. If this is a global, consider adding a /** global: Mivhak */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
2
    template: '<div class="mivhak-toggle"><div class="mivhak-toggle-knob"></div></div>',
3
    props: {
4
        on: true
5
    },
6
    events: {
7
        click: function() {
8
            this.toggle();
9
        }
10
    },
11
    created: function() {
12
        this.$el.addClass('mivhak-toggle-'+(this.on?'on':'off'));
13
    },
14
    methods: {
15
        toggle: function() {
16
            this.on = !this.on;
17
            this.$el.toggleClass('mivhak-toggle-on').toggleClass('mivhak-toggle-off');
18
        }
19
    }
20
});