CoreFiles by mySites.guru
customize-preview.js60 lines, 1,675 bytes, from wordpress-5.3.21.zip
Raw History Compare with 5.3.20
md5
58ab0787ff03efa0304cd63c9f457c73
sha1
1f424b4230df8eee6eb29a4d15926a17f33e6420
sha256
076faf446fed1663f8098c4f6fe0b21aecc4d8670c26fd42b2f9b796d62f1208
/**
 * 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 );

The same content is in 40 releases, WordPress 5.3-beta1 to 5.3.28. See them all, or every version of this file.