WordPress/wp-content/themes/twentytwentyone/assets/js/customize.js
desrosj 634e6b16c8 Twenty Twenty-One: Sync the latest changes for 5.6 RC1.
For a full list of changes since [49574-49577], see https://github.com/WordPress/twentytwentyone/compare/aa284fd...trunk.

Props poena, luminuu, kjellr, ryelle, aristath.
See #51526.
Built from https://develop.svn.wordpress.org/trunk@49633


git-svn-id: http://core.svn.wordpress.org/trunk@49371 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-11-17 19:00:08 +00:00

26 lines
1.0 KiB
JavaScript

/* global twentytwentyoneGetHexLum */
( function() {
// Wait until the customizer has finished loading.
wp.customize.bind( 'ready', function() {
// Hide the "respect_user_color_preference" setting if the background-color is dark.
if ( 127 > twentytwentyoneGetHexLum( wp.customize( 'background_color' ).get() ) ) {
wp.customize.control( 'respect_user_color_preference' ).deactivate();
wp.customize.control( 'respect_user_color_preference_notice' ).deactivate();
}
// Handle changes to the background-color.
wp.customize( 'background_color', function( setting ) {
setting.bind( function( value ) {
if ( 127 > twentytwentyoneGetHexLum( value ) ) {
wp.customize.control( 'respect_user_color_preference' ).deactivate();
wp.customize.control( 'respect_user_color_preference_notice' ).activate();
} else {
wp.customize.control( 'respect_user_color_preference' ).activate();
wp.customize.control( 'respect_user_color_preference_notice' ).deactivate();
}
} );
} );
} );
}() );