Issues (377)

modules/css-vars/script.js (35 issues)

1
/* global kirkiCssVarFields */
0 ignored issues
show
You must use "/**" style comments for a file comment
Loading history...
2
var kirkiCssVars = {
3
4
	/**
5
	 * Get styles.
6
	 *
7
	 * @since 3.0.28
8
	 * @returns {Object}
9
	 */
10
	getStyles: function() {
11
		var style     = jQuery( '#kirki-css-vars' ),
12
			styles    = style.html().replace( ':root{', '' ).replace( '}', '' ).split( ';' ),
13
			stylesObj = {};
14
15
		// Format styles as a object we can then tweak.
16
		_.each( styles, function( style ) {
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
17
			style = style.split( ':' );
18
			if ( style[0] && style[1] ) {
19
				stylesObj[ style[0] ] = style[1];
20
			}
21
		} );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
22
		return stylesObj;
23
	},
24
25
	/**
26
	 * Builds the styles from an object.
27
	 *
28
	 * @since 3.0.28
29
	 * @param {Object} vars - The vars.
30
	 * @returns {string}
31
	 */
32
	buildStyle: function( vars ) {
33
		var style = '';
34
35
		_.each( vars, function( val, name ) {
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
36
			style += name + ':' + val + ';';
37
		} );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
38
		return ':root{' + style + '}';
39
	}
40
};
41
42
jQuery( document ).ready( function() {
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
43
	_.each( kirkiCssVarFields, function( field ) {
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
44
		wp.customize( field.settings, function( value ) {
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
45
			value.bind( function( newVal ) {
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
46
				var styles = kirkiCssVars.getStyles();
47
48
				_.each( field.css_vars, function( cssVar ) {
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
49
					if ( 'object' === typeof newVal ) {
50
						if ( cssVar[2] && newVal[ cssVar[2] ] ) {
51
							styles[ cssVar[0] ] = cssVar[1].replace( '$', newVal[ cssVar[2] ] );
52
						}
53
					} else {
54
						styles[ cssVar[0] ] = cssVar[1].replace( '$', newVal );
55
					}
56
				} );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
57
				jQuery( '#kirki-css-vars' ).html( kirkiCssVars.buildStyle( styles ) );
58
			} );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
59
		} );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
60
	} );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
61
} );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
62
63
wp.customize.bind( 'preview-ready', function() {
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
64
	wp.customize.preview.bind( 'active', function() {
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
65
		_.each( kirkiCssVarFields, function( field ) {
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
66
			wp.customize( field.settings, function( value ) {
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
67
				var styles = kirkiCssVars.getStyles(),
68
					newVal = window.parent.wp.customize( value.id ).get();
69
				_.each( field.css_vars, function( cssVar ) {
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
70
					if ( 'object' === typeof newVal ) {
71
						if ( cssVar[2] && newVal[ cssVar[2] ] ) {
72
							styles[ cssVar[0] ] = cssVar[1].replace( '$', newVal[ cssVar[2] ] );
73
						}
74
					} else {
75
						styles[ cssVar[0] ] = cssVar[1].replace( '$', newVal );
76
					}
77
				} );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
78
				jQuery( '#kirki-css-vars' ).html( kirkiCssVars.buildStyle( styles ) );
79
			} );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
80
		} );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
81
	} );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
82
} );
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
83