No Description

customize.js 1.0KB

1234567891011121314151617181920212223242526
  1. /* global twentytwentyoneGetHexLum */
  2. ( function() {
  3. // Wait until the customizer has finished loading.
  4. wp.customize.bind( 'ready', function() {
  5. // Hide the "respect_user_color_preference" setting if the background-color is dark.
  6. if ( 127 > twentytwentyoneGetHexLum( wp.customize( 'background_color' ).get() ) ) {
  7. wp.customize.control( 'respect_user_color_preference' ).deactivate();
  8. wp.customize.control( 'respect_user_color_preference_notice' ).deactivate();
  9. }
  10. // Handle changes to the background-color.
  11. wp.customize( 'background_color', function( setting ) {
  12. setting.bind( function( value ) {
  13. if ( 127 > twentytwentyoneGetHexLum( value ) ) {
  14. wp.customize.control( 'respect_user_color_preference' ).deactivate();
  15. wp.customize.control( 'respect_user_color_preference_notice' ).activate();
  16. } else {
  17. wp.customize.control( 'respect_user_color_preference' ).activate();
  18. wp.customize.control( 'respect_user_color_preference_notice' ).deactivate();
  19. }
  20. } );
  21. } );
  22. } );
  23. }() );