| 1 |
( function( $, exports, wp ) { |
| 2 |
|
| 3 |
function swap_values( setting_one, setting_two ) { |
| 4 |
var color_primary = wp.customize( setting_one )(); |
| 5 |
var color_secondary = wp.customize( setting_two )(); |
| 6 |
|
| 7 |
wp.customize( setting_one ).set( color_secondary ); |
| 8 |
wp.customize( setting_two ).set( color_primary ); |
| 9 |
} |
| 10 |
|
| 11 |
wp.customize.bind( 'ready', function() { |
| 12 |
const $document = $( document ); |
| 13 |
|
| 14 |
$document.on( 'click', '[data-action="sm_swap_colors"]', function( e ) { |
| 15 |
e.preventDefault(); |
| 16 |
swap_values( 'sm_color_primary', 'sm_color_secondary' ); |
| 17 |
} ); |
| 18 |
|
| 19 |
$document.on( 'click', '[data-action="sm_swap_dark_light"]', function( e ) { |
| 20 |
e.preventDefault(); |
| 21 |
swap_values( 'sm_dark_primary', 'sm_light_primary' ); |
| 22 |
swap_values( 'sm_dark_secondary', 'sm_light_secondary' ); |
| 23 |
swap_values( 'sm_dark_tertiary', 'sm_light_tertiary' ); |
| 24 |
} ); |
| 25 |
|
| 26 |
$document.on( 'click', '[data-action="sm_swap_colors_dark"]', function( e ) { |
| 27 |
e.preventDefault(); |
| 28 |
swap_values( 'sm_color_primary', 'sm_dark_primary' ); |
| 29 |
swap_values( 'sm_color_secondary', 'sm_dark_secondary' ); |
| 30 |
swap_values( 'sm_color_tertiary', 'sm_dark_tertiary' ); |
| 31 |
} ); |
| 32 |
|
| 33 |
$document.on( 'click', '[data-action="sm_swap_secondary_colors_dark"]', function( e ) { |
| 34 |
e.preventDefault(); |
| 35 |
swap_values( 'sm_color_secondary', 'sm_dark_secondary' ); |
| 36 |
} ); |
| 37 |
|
| 38 |
} ); |
| 39 |
|
| 40 |
} )( jQuery, window, wp ); |