PluginProbe
Customify / 2.1.3
Customify v2.1.3
2.10.9 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.7.1 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.6.0 1.6.0.1 1.6.5 1.7.0 1.7.1 All 77 releases
customify / js / customizer / swap-values.js

swap-values.js in Customify 2.1.3, at js/customizer/swap-values.js

40 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 );