mirror of
https://github.com/WordPress/WordPress.git
synced 2024-08-11 23:32:58 +02:00
Props celloexpressions, iamtakashi, fixes #30164 and #29980. Built from https://develop.svn.wordpress.org/trunk@30230 git-svn-id: http://core.svn.wordpress.org/trunk@30230 1a063a9b-81f0-0310-95a4-ce76da25c4cd
35 lines
1.4 KiB
JavaScript
35 lines
1.4 KiB
JavaScript
/* global colorScheme */
|
|
/**
|
|
* Customizer enhancements for a better user experience.
|
|
*
|
|
* Adds listener to Color Scheme control to update other color controls with new values/defaults
|
|
*/
|
|
|
|
( function( api ) {
|
|
api.controlConstructor.select = api.Control.extend( {
|
|
ready: function() {
|
|
if ( 'color_scheme' === this.id ) {
|
|
this.setting.bind( 'change', function( value ) {
|
|
// Update Background Color.
|
|
api( 'background_color' ).set( colorScheme[value].colors[0] );
|
|
api.control( 'background_color' ).container.find( '.color-picker-hex' )
|
|
.data( 'data-default-color', colorScheme[value].colors[0] )
|
|
.wpColorPicker( 'defaultColor', colorScheme[value].colors[0] );
|
|
|
|
// Update Header/Sidebar Background Color.
|
|
api( 'header_background_color' ).set( colorScheme[value].colors[1] );
|
|
api.control( 'header_background_color' ).container.find( '.color-picker-hex' )
|
|
.data( 'data-default-color', colorScheme[value].colors[1] )
|
|
.wpColorPicker( 'defaultColor', colorScheme[value].colors[1] );
|
|
|
|
// Update Header/Sidebar Text Color.
|
|
api( 'sidebar_textcolor' ).set( colorScheme[value].colors[4] );
|
|
api.control( 'sidebar_textcolor' ).container.find( '.color-picker-hex' )
|
|
.data( 'data-default-color', colorScheme[value].colors[4] )
|
|
.wpColorPicker( 'defaultColor', colorScheme[value].colors[4] );
|
|
} );
|
|
}
|
|
}
|
|
} );
|
|
} )( wp.customize );
|