2020-11-12 19:36:15 +01:00
|
|
|
/* global twentytwentyoneGetHexLum */
|
2020-11-02 20:45:07 +01:00
|
|
|
|
|
|
|
( 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();
|
2020-11-17 20:00:08 +01:00
|
|
|
wp.customize.control( 'respect_user_color_preference_notice' ).deactivate();
|
2020-11-02 20:45:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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();
|
2020-11-17 20:00:08 +01:00
|
|
|
wp.customize.control( 'respect_user_color_preference_notice' ).activate();
|
2020-11-02 20:45:07 +01:00
|
|
|
} else {
|
|
|
|
wp.customize.control( 'respect_user_color_preference' ).activate();
|
2020-11-17 20:00:08 +01:00
|
|
|
wp.customize.control( 'respect_user_color_preference_notice' ).deactivate();
|
2020-11-02 20:45:07 +01:00
|
|
|
}
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
}() );
|