| 1 |
/* |
| 2 |
* Script run inside a Customizer control sidebar |
| 3 |
* |
| 4 |
* Enable / disable the control title by toggeling its .disabled-control-title style class on or off. |
| 5 |
*/ |
| 6 |
( function( $ ) { |
| 7 |
wp.customize.bind( 'ready', function() { // Ready? |
| 8 |
|
| 9 |
var customize = this; // Customize object alias. |
| 10 |
// Array with the control names |
| 11 |
// TODO: Replace #CONTROLNAME01#, #CONTROLNAME02# etc with the real control names. |
| 12 |
var toggleControls = [ |
| 13 |
'#CONTROLNAME01#', |
| 14 |
'#CONTROLNAME02#' |
| 15 |
]; |
| 16 |
$.each( toggleControls, function( index, control_name ) { |
| 17 |
customize( control_name, function( value ) { |
| 18 |
var controlTitle = customize.control( control_name ).container.find( '.customize-control-title' ); // Get control title. |
| 19 |
// 1. On loading. |
| 20 |
controlTitle.toggleClass('disabled-control-title', !value.get() ); |
| 21 |
// 2. Binding to value change. |
| 22 |
value.bind( function( to ) { |
| 23 |
controlTitle.toggleClass( 'disabled-control-title', !value.get() ); |
| 24 |
} ); |
| 25 |
} ); |
| 26 |
} ); |
| 27 |
} ); |
| 28 |
} )( jQuery ); |
| 29 |
|