Completed
Push — master ( 58e905...b98842 )
by Aristeides
08:10 queued 04:37
created

controls/js/src/switch.js   A

Complexity

Total Complexity 3
Complexity/F 1.5

Size

Lines of Code 16
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
nc 2
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 3
mnd 1
bc 2
fnc 2
bpm 1
cpm 1.5
noi 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A wp.customize.kirkiDynamicControl.extend.initKirkiControl 0 13 1
1
wp.customize.controlConstructor['kirki-switch'] = wp.customize.kirkiDynamicControl.extend({
2
3
	initKirkiControl: function() {
4
5
		'use strict';
6
7
		var control       = this,
0 ignored issues
show
Coding Style introduced by
As per coding-style, prefer block-scoped variables using let or const which have better semantics than var.

Since ECMAScript 6, you can create block-scoped vars or constants with the keywords let or const. These variables/constants are only valid in the code block where they have been declared.

Consider the following two pieces of code:

if (true)
 {
    var x = "Hello, Stonehenge!";
}

console.log(x); //prints Hello, Stonehenge! to the console

and

if (true)
 {
    let x = "Hello, Stonehenge!";
}

console.log(x); //ReferenceError: x is not defined

The variable is not defined otuside of its block. This limits bleeding of variables into other contexts.

To know more about this ECMA6 feature, look at the MDN pages on let and const.

Loading history...
8
		    checkboxValue = control.setting._value;
9
10
		// Save the value
11
		this.container.on( 'change', 'input', function() {
12
			checkboxValue = ( jQuery( this ).is( ':checked' ) ) ? true : false;
13
			control.setting.set( checkboxValue );
14
		});
15
	}
16
});
17