customize-controls.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * Scripts within the customizer controls window.
  3. *
  4. * Contextually shows the color hue control and informs the preview
  5. * when users open or close the front page sections section.
  6. */
  7. (function() {
  8. wp.customize.bind( 'ready', function() {
  9. // Only show the color hue control when there's a custom color scheme.
  10. wp.customize( 'colorscheme', function( setting ) {
  11. wp.customize.control( 'colorscheme_hue', function( control ) {
  12. var visibility = function() {
  13. if ( 'custom' === setting.get() ) {
  14. control.container.slideDown( 180 );
  15. } else {
  16. control.container.slideUp( 180 );
  17. }
  18. };
  19. visibility();
  20. setting.bind( visibility );
  21. });
  22. });
  23. // Detect when the front page sections section is expanded (or closed) so we can adjust the preview accordingly.
  24. wp.customize.section( 'theme_options', function( section ) {
  25. section.expanded.bind( function( isExpanding ) {
  26. // Value of isExpanding will = true if you're entering the section, false if you're leaving it.
  27. wp.customize.previewer.send( 'section-highlight', { expanded: isExpanding });
  28. } );
  29. } );
  30. });
  31. })( jQuery );