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