Make WordPress Core

Ticket #38627: 38627.2.patch

File 38627.2.patch, 1.5 KB (added by davidakennedy, 8 years ago)

Account for inner container class name change with and without header image or video.

  • src/wp-content/themes/twentyseventeen/assets/js/customize-preview.js

     
    102102                        }
    103103                } );
    104104        } );
     105
     106        // Whether a header image is available.
     107        function hasHeaderImage() {
     108                var image = wp.customize( 'header_image' )();
     109                return '' !== image && 'remove-header' !== image;
     110        }
     111
     112        // Whether a header video is available.
     113        function hasHeaderVideo() {
     114                var externalVideo = wp.customize( 'external_header_video' )(),
     115                        video = wp.customize( 'header_video' )();
     116
     117                return '' !== externalVideo || ( 0 !== video && '' !== video );
     118        }
     119
     120        // Toggle a body class if a custom header exists and adjust inner container class.
     121        $.each( [ 'external_header_video', 'header_image', 'header_video' ], function( index, settingId ) {
     122                wp.customize( settingId, function( setting ) {
     123                        setting.bind(function() {
     124                                if ( hasHeaderImage() || ( hasHeaderVideo() && $( 'body' ).hasClass( 'twentyseventeen-front-page' ) ) ) {
     125                                        $( document.body ).addClass( 'has-header-image' );
     126                                        $( '.custom-header-simple' ).addClass( 'custom-header-image' ).removeClass( 'custom-header-simple' );
     127                                } else {
     128                                        $( document.body ).removeClass( 'has-header-image' );
     129                                        $( '.custom-header-image' ).addClass( 'custom-header-simple' ).removeClass( 'custom-header-image' );
     130                                }
     131                        } );
     132                } );
     133        } );
     134
    105135} )( jQuery );