diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-01-07 13:06:14 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-01-07 13:06:14 +0100 |
| commit | 7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8 (patch) | |
| tree | f7453d7dd5cbaaab246e23810b02d3edf1e451be /srcs/wordpress/wp-content/themes/twentynineteen/js/customize-preview.js | |
| parent | c59bdcf77c50cbe89b4a93782cdd6d9e7532080e (diff) | |
| download | ft_server-7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8.tar.gz ft_server-7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8.tar.bz2 ft_server-7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8.zip | |
Added wordpress
Diffstat (limited to 'srcs/wordpress/wp-content/themes/twentynineteen/js/customize-preview.js')
| -rw-r--r-- | srcs/wordpress/wp-content/themes/twentynineteen/js/customize-preview.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/srcs/wordpress/wp-content/themes/twentynineteen/js/customize-preview.js b/srcs/wordpress/wp-content/themes/twentynineteen/js/customize-preview.js new file mode 100644 index 0000000..91b91f3 --- /dev/null +++ b/srcs/wordpress/wp-content/themes/twentynineteen/js/customize-preview.js @@ -0,0 +1,60 @@ +/** + * File customize-preview.js. + * + * Theme Customizer enhancements for a better user experience. + * + * Contains handlers to make Theme Customizer preview reload changes asynchronously. + */ + +(function( $ ) { + + // Primary color. + wp.customize( 'primary_color', function( value ) { + value.bind( function( to ) { + // Update custom color CSS. + var style = $( '#custom-theme-colors' ), + hue = style.data( 'hue' ), + css = style.html(), + color; + + if( 'custom' === to ){ + // If a custom primary color is selected, use the currently set primary_color_hue + color = wp.customize.get().primary_color_hue; + } else { + // If the "default" option is selected, get the default primary_color_hue + color = 199; + } + + // Equivalent to css.replaceAll, with hue followed by comma to prevent values with units from being changed. + css = css.split( hue + ',' ).join( color + ',' ); + style.html( css ).data( 'hue', color ); + }); + }); + + // Primary color hue. + wp.customize( 'primary_color_hue', function( value ) { + value.bind( function( to ) { + + // Update custom color CSS. + var style = $( '#custom-theme-colors' ), + hue = style.data( 'hue' ), + css = style.html(); + + // Equivalent to css.replaceAll, with hue followed by comma to prevent values with units from being changed. + css = css.split( hue + ',' ).join( to + ',' ); + style.html( css ).data( 'hue', to ); + }); + }); + + // Image filter. + wp.customize( 'image_filter', function( value ) { + value.bind( function( to ) { + if ( to ) { + $( 'body' ).addClass( 'image-filters-enabled' ); + } else { + $( 'body' ).removeClass( 'image-filters-enabled' ); + } + } ); + } ); + +})( jQuery ); |
