wp/wp-content/themes/twentyseventeen/assets/js/customize-controls.js
changeset 7 cf61fcea0001
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
       
     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 
       
     8 (function() {
       
     9 	wp.customize.bind( 'ready', function() {
       
    10 
       
    11 		// Only show the color hue control when there's a custom color scheme.
       
    12 		wp.customize( 'colorscheme', function( setting ) {
       
    13 			wp.customize.control( 'colorscheme_hue', function( control ) {
       
    14 				var visibility = function() {
       
    15 					if ( 'custom' === setting.get() ) {
       
    16 						control.container.slideDown( 180 );
       
    17 					} else {
       
    18 						control.container.slideUp( 180 );
       
    19 					}
       
    20 				};
       
    21 
       
    22 				visibility();
       
    23 				setting.bind( visibility );
       
    24 			});
       
    25 		});
       
    26 
       
    27 		// Detect when the front page sections section is expanded (or closed) so we can adjust the preview accordingly.
       
    28 		wp.customize.section( 'theme_options', function( section ) {
       
    29 			section.expanded.bind( function( isExpanding ) {
       
    30 
       
    31 				// Value of isExpanding will = true if you're entering the section, false if you're leaving it.
       
    32 				wp.customize.previewer.send( 'section-highlight', { expanded: isExpanding });
       
    33 			} );
       
    34 		} );
       
    35 	});
       
    36 })( jQuery );