Total Complexity | 9 |
Complexity/F | 1.5 |
Lines of Code | 36 |
Function Count | 6 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | var pollux = { |
||
2 | metabox: {}, |
||
3 | }; |
||
4 | |||
5 | pollux.metabox.hasValue = function( el ) { |
||
6 | if( el.type === 'checkbox' ) { |
||
7 | return el.checked === true; |
||
8 | } |
||
9 | return el.value !== ''; |
||
10 | }; |
||
11 | |||
12 | pollux.metabox.onChangeValue = function( el ) |
||
13 | { |
||
14 | pollux.metabox.setVisibility( el ); |
||
15 | }; |
||
16 | |||
17 | pollux.metabox.setVisibility = function( el ) |
||
18 | { |
||
19 | var dependency = document.getElementById( el.getAttribute( 'data-depends' )); |
||
20 | el.closest( '.rwmb-field' ).style.display = pollux.metabox.hasValue( dependency ) ? '' : 'none'; |
||
21 | return dependency; |
||
22 | }; |
||
23 | |||
24 | jQuery(function(x) { |
||
|
|||
25 | |||
26 | var depends = document.querySelectorAll( '.rwmb-input [data-depends]' ); |
||
27 | |||
28 | [].forEach.call( depends, function( el ) { |
||
29 | var dependency = pollux.metabox.setVisibility( el ); |
||
30 | var event = dependency.type === 'checkbox' ? 'change' : 'keyup'; |
||
31 | dependency.addEventListener( event, function() { |
||
32 | pollux.metabox.onChangeValue( el ); |
||
33 | }, false ); |
||
34 | }); |
||
35 | |||
36 | }); |
||
37 |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.