panel-customizer.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * Theme Customizer enhancements, specific to panels, for a better user experience.
  3. *
  4. * This allows us to detect when the user has opened specific sections within the Customizer,
  5. * and adjust our preview pane accordingly.
  6. */
  7. ( function( $ ) {
  8. wp.customize.bind( 'ready', function() {
  9. // Detect when the section for each panel is expanded (or closed) so we can adjust preview accordingly
  10. wp.customize.section( 'lodestar_panel1' ).expanded.bind( function( isExpanding ) {
  11. // isExpanding will = true if you're entering the section, false if you're leaving it
  12. wp.customize.previewer.send( 'section-highlight', { section: 'lodestar-panel1', expanded: isExpanding } );
  13. } );
  14. // Detect when the section for each panel is expanded (or closed) so we can adjust preview accordingly
  15. wp.customize.section( 'lodestar_panel2' ).expanded.bind( function( isExpanding ) {
  16. // isExpanding will = true if you're entering the section, false if you're leaving it
  17. wp.customize.previewer.send( 'section-highlight', { section: 'lodestar-panel2', expanded: isExpanding } );
  18. } );
  19. // Detect when the section for each panel is expanded (or closed) so we can adjust preview accordingly
  20. wp.customize.section( 'lodestar_panel3' ).expanded.bind( function( isExpanding ) {
  21. // isExpanding will = true if you're entering the section, false if you're leaving it
  22. wp.customize.previewer.send( 'section-highlight', { section: 'lodestar-panel3', expanded: isExpanding } );
  23. } );
  24. // Detect when the section for each panel is expanded (or closed) so we can adjust preview accordingly
  25. wp.customize.section( 'lodestar_panel4' ).expanded.bind( function( isExpanding ) {
  26. // isExpanding will = true if you're entering the section, false if you're leaving it
  27. wp.customize.previewer.send( 'section-highlight', { section: 'lodestar-panel4', expanded: isExpanding } );
  28. } );
  29. // Detect when the section for each panel is expanded (or closed) so we can adjust preview accordingly
  30. wp.customize.section( 'lodestar_footer_settings' ).expanded.bind( function( isExpanding ) {
  31. // isExpanding will = true if you're entering the section, false if you're leaving it
  32. wp.customize.previewer.send( 'section-highlight', { section: 'lodestar-footer-settings', expanded: isExpanding } );
  33. } );
  34. } );
  35. } )( jQuery );