panel-customizer.js 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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( 'pique_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: 'pique-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( 'pique_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: 'pique-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( 'pique_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: 'pique-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( 'pique_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: 'pique-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( 'pique_panel5' ).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: 'pique-panel5', expanded: isExpanding } );
  33. } );
  34. // Detect when the section for each panel is expanded (or closed) so we can adjust preview accordingly
  35. wp.customize.section( 'pique_panel6' ).expanded.bind( function( isExpanding ) {
  36. // isExpanding will = true if you're entering the section, false if you're leaving it
  37. wp.customize.previewer.send( 'section-highlight', { section: 'pique-panel6', expanded: isExpanding } );
  38. } );
  39. // Detect when the section for each panel is expanded (or closed) so we can adjust preview accordingly
  40. wp.customize.section( 'pique_panel7' ).expanded.bind( function( isExpanding ) {
  41. // isExpanding will = true if you're entering the section, false if you're leaving it
  42. wp.customize.previewer.send( 'section-highlight', { section: 'pique-panel7', expanded: isExpanding } );
  43. } );
  44. // Detect when the section for each panel is expanded (or closed) so we can adjust preview accordingly
  45. wp.customize.section( 'pique_panel8' ).expanded.bind( function( isExpanding ) {
  46. // isExpanding will = true if you're entering the section, false if you're leaving it
  47. wp.customize.previewer.send( 'section-highlight', { section: 'pique-panel8', expanded: isExpanding } );
  48. } );
  49. /*
  50. var panels = [ '1', '2', '3', '4', '5', '6', '7', '8' ];
  51. // Add a listener for each panel
  52. for ( i=0; panels[i] =< 8; i++ ) {
  53. console.log ( panels[i] );
  54. wp.customize.section( 'pique_panel' + panels[i] ).expanded.bind( function( isExpanding ) {
  55. // this will return true you're entering the section, false if you're leaving it
  56. wp.customize.previewer.send( 'section-highlight', { section: 'pique_panel' + panels[], expanded: isExpanding } );
  57. } );
  58. }
  59. */
  60. } );
  61. } )( jQuery );