Make WordPress Core

Ticket #38502: 38502.1.patch

File 38502.1.patch, 3.9 KB (added by laurelfulford, 8 years ago)
  • src/wp-content/themes/twentyseventeen/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 ) {
     147                        setNavProps();
     148                        adjustScrollClass();
     149                }
    147150
     151                // If 'Scroll Down' arrow in present on page, calculate scroll offset and bind an event handler to the click event
    148152                if ( $menuScrollDown.length ) {
    149153
    150                         /**
    151                          * 'Scroll Down' arrow in menu area
    152                          */
    153154                        if ( $( 'body' ).hasClass( 'admin-bar' ) ) {
    154155                                menuTop -= 32;
    155156                        }
     
    156157                        if ( $( 'body' ).hasClass( 'blog' ) ) {
    157158                                menuTop -= 30; // The div for latest posts has no space above content, add some to account for this
    158159                        }
     160                        if ( ! $navigation.length ) {
     161                                navigationOuterHeight = 0;
     162                        }
     163
    159164                        $menuScrollDown.click( function( e ) {
    160165                                e.preventDefault();
    161166                                $( window ).scrollTo( '#primary', {
     
    163168                                        offset: { 'top': menuTop - navigationOuterHeight }
    164169                                } );
    165170                        } );
    166 
    167                         adjustScrollClass();
    168171                }
    169172
    170173                adjustHeaderHeight();
     
    175178                }
    176179        } );
    177180
    178         if ( 'true' === twentyseventeenScreenReaderText.has_navigation ) {
     181        // If navigation menu is present on page, adjust it on scroll and screen resize
     182        if ( $navigation.length ) {
    179183
    180184                // On scroll, we want to stick/unstick the navigation
    181185                $( window ).on( 'scroll', function() {
     
    187191                $( window ).resize( function() {
    188192                        setNavProps();
    189193                        setTimeout( adjustScrollClass, 500 );
    190                         setTimeout( adjustHeaderHeight, 1000 );
    191194                } );
    192195        }
    193196
     
    196199                resizeTimer = setTimeout( function() {
    197200                        belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' );
    198201                }, 300 );
     202                setTimeout( adjustHeaderHeight, 1000 );
    199203        } );
    200204
    201205}( jQuery ) );
  • src/wp-content/themes/twentyseventeen/functions.php

     
    368368
    369369        $twentyseventeen_l10n = array(
    370370                'quote'          => twentyseventeen_get_svg( array( 'icon' => 'quote-right' ) ),
    371                 'has_navigation' => 'false',
    372371        );
    373372
    374373        if ( has_nav_menu( 'top' ) ) {
    375374                wp_enqueue_script( 'twentyseventeen-navigation', get_theme_file_uri( '/assets/js/navigation.js' ), array(), '1.0', true );
    376                 $twentyseventeen_l10n['has_navigation'] = 'true';
    377375                $twentyseventeen_l10n['expand']         = __( 'Expand child menu', 'twentyseventeen' );
    378376                $twentyseventeen_l10n['collapse']       = __( 'Collapse child menu', 'twentyseventeen' );
    379377                $twentyseventeen_l10n['icon']           = twentyseventeen_get_svg( array( 'icon' => 'angle-down', 'fallback' => true ) );
  • src/wp-content/themes/twentyseventeen/template-parts/navigation/navigation-top.php

     
    1616                'menu_id'        => 'top-menu',
    1717        ) ); ?>
    1818
    19         <?php if ( twentyseventeen_is_frontpage() || ( is_home() && is_front_page() ) ) : ?>
     19        <?php if ( ( twentyseventeen_is_frontpage() || ( is_home() && is_front_page() ) ) && has_custom_header() ) : ?>
    2020                <a href="#content" class="menu-scroll-down"><?php echo twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ); ?><span class="screen-reader-text"><?php _e( 'Scroll Down', 'twentyseventeen' ); ?></span></a>
    2121        <?php endif; ?>
    2222</nav><!-- #site-navigation -->