Make WordPress Core

Ticket #38502: 38502.patch

File 38502.patch, 2.8 KB (added by enodekciw, 8 years ago)
  • assets/js/global.js

     
    142142        // Fires on document ready
    143143        $( document ).ready( function() {
    144144
    145                 // Let's fire some JavaScript!
    146                 setNavProps();
     145                // If navigation menu is present on page, setNavProps and adjustScrollClass
     146                if( $navigation.length ) {
    147147
     148                        setNavProps();
     149                        adjustScrollClass();
     150                }
     151
     152                // If 'Scroll Down' arrow in present on page, calculate scroll offset and bind an event handler to the click event
    148153                if ( $menuScrollDown.length ) {
    149154
    150                         /**
    151                          * 'Scroll Down' arrow in menu area
    152                          */
    153155                        if ( $( 'body' ).hasClass( 'admin-bar' ) ) {
    154156                                menuTop -= 32;
    155157                        }
     
    156158                        if ( $( 'body' ).hasClass( 'blog' ) ) {
    157159                                menuTop -= 30; // The div for latest posts has no space above content, add some to account for this
    158160                        }
     161                        if ( ! $navigation.length ) {
     162                                navigationOuterHeight = 0;
     163                        }
     164
    159165                        $menuScrollDown.click( function( e ) {
    160166                                e.preventDefault();
    161167                                $( window ).scrollTo( '#primary', {
     
    163169                                        offset: { 'top': menuTop - navigationOuterHeight }
    164170                                } );
    165171                        } );
    166 
    167                         adjustScrollClass();
    168172                }
    169173
    170174                adjustHeaderHeight();
     
    175179                }
    176180        } );
    177181
    178         if ( 'true' === twentyseventeenScreenReaderText.has_navigation ) {
     182        // If navigation menu is present on page, adjust it on scroll and screen resize
     183        if ( $navigation.length ) {
    179184
    180185                // On scroll, we want to stick/unstick the navigation
    181186                $( window ).on( 'scroll', function() {
     
    187192                $( window ).resize( function() {
    188193                        setNavProps();
    189194                        setTimeout( adjustScrollClass, 500 );
    190                         setTimeout( adjustHeaderHeight, 1000 );
    191195                } );
    192196        }
    193197
     
    196200                resizeTimer = setTimeout( function() {
    197201                        belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' );
    198202                }, 300 );
     203                setTimeout( adjustHeaderHeight, 1000 );
    199204        } );
    200205
    201206}( jQuery ) );
  • functions.php

     
    305305
    306306        $twentyseventeen_l10n = array(
    307307                'quote'          => twentyseventeen_get_svg( array( 'icon' => 'quote-right' ) ),
    308                 'has_navigation' => 'false',
    309308        );
    310309
    311310        if ( has_nav_menu( 'top' ) ) {
    312311                wp_enqueue_script( 'twentyseventeen-navigation', get_theme_file_uri( '/assets/js/navigation.js' ), array(), '1.0', true );
    313                 $twentyseventeen_l10n['has_navigation'] = 'true';
    314312                $twentyseventeen_l10n['expand']         = __( 'Expand child menu', 'twentyseventeen' );
    315313                $twentyseventeen_l10n['collapse']       = __( 'Collapse child menu', 'twentyseventeen' );
    316314                $twentyseventeen_l10n['icon']           = twentyseventeen_get_svg( array( 'icon' => 'expand', 'fallback' => true ) );