customizer-panels.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  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( 'affinity_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: 'affinity-panel1', expanded: isExpanding } );
  13. } );
  14. wp.customize.section( 'affinity_panel2' ).expanded.bind( function( isExpanding ) {
  15. wp.customize.previewer.send( 'section-highlight', { section: 'affinity-panel2', expanded: isExpanding } );
  16. } );
  17. wp.customize.section( 'affinity_panel3' ).expanded.bind( function( isExpanding ) {
  18. wp.customize.previewer.send( 'section-highlight', { section: 'affinity-panel3', expanded: isExpanding } );
  19. } );
  20. wp.customize.section( 'affinity_panel4' ).expanded.bind( function( isExpanding ) {
  21. wp.customize.previewer.send( 'section-highlight', { section: 'affinity-panel4', expanded: isExpanding } );
  22. } );
  23. wp.customize.section( 'affinity_panel5' ).expanded.bind( function( isExpanding ) {
  24. wp.customize.previewer.send( 'section-highlight', { section: 'affinity-panel5', expanded: isExpanding } );
  25. } );
  26. } );
  27. } )( jQuery );