customize.js 839 B

123456789101112131415161718192021222324252627
  1. /* global wp, jQuery */
  2. ( function( $, api ) {
  3. $( document ).ready( function() {
  4. // Make it possible to reset the color based on a radio input's value.
  5. // `active` can be either `custom` or `default`.
  6. api.control( 'accent_hue_active' ).setting.bind( function( active ) {
  7. var control = api.control( 'accent_hue' ); // Get the accent hue control.
  8. if ( 'custom' === active ) {
  9. // Activate the hue color picker control and focus it.
  10. control.activate( {
  11. completeCallback: function() {
  12. control.focus();
  13. }
  14. } );
  15. } else {
  16. // If the `custom` option isn't selected, deactivate the hue color picker and set a default.
  17. control.deactivate( {
  18. completeCallback: function() {
  19. control.setting.set( control.params.defaultValue );
  20. }
  21. } );
  22. }
  23. } );
  24. } );
  25. }( jQuery, wp.customize ) );