From d13b9b284a5988778ca9fe68f97ea08d688a76c8 Mon Sep 17 00:00:00 2001 From: "David A. Kennedy" Date: Tue, 1 Nov 2016 18:59:06 +0000 Subject: [PATCH] Twenty Seventeen: Remove unnecessary l10n variables * Relies on header skip link instead of l10n variables in JavaScript. * Fixes issue where scroll down arrow appeared next to the navigation on the front page with no header image or video. It now only appears with a big header. Props enodekciw, laurelfulford. Fixes #38502. git-svn-id: https://develop.svn.wordpress.org/trunk@39073 602fd350-edb4-49c9-b593-d223f7449a82 --- .../twentyseventeen/assets/js/global.js | 22 +++++++++++-------- .../themes/twentyseventeen/functions.php | 2 -- .../navigation/navigation-top.php | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/wp-content/themes/twentyseventeen/assets/js/global.js b/src/wp-content/themes/twentyseventeen/assets/js/global.js index af41bde05b..8c103d6ebe 100644 --- a/src/wp-content/themes/twentyseventeen/assets/js/global.js +++ b/src/wp-content/themes/twentyseventeen/assets/js/global.js @@ -142,20 +142,25 @@ // Fires on document ready $( document ).ready( function() { - // Let's fire some JavaScript! - setNavProps(); + // If navigation menu is present on page, setNavProps and adjustScrollClass + if( $navigation.length ) { + setNavProps(); + adjustScrollClass(); + } + // If 'Scroll Down' arrow in present on page, calculate scroll offset and bind an event handler to the click event if ( $menuScrollDown.length ) { - /** - * 'Scroll Down' arrow in menu area - */ if ( $( 'body' ).hasClass( 'admin-bar' ) ) { menuTop -= 32; } if ( $( 'body' ).hasClass( 'blog' ) ) { menuTop -= 30; // The div for latest posts has no space above content, add some to account for this } + if ( ! $navigation.length ) { + navigationOuterHeight = 0; + } + $menuScrollDown.click( function( e ) { e.preventDefault(); $( window ).scrollTo( '#primary', { @@ -163,8 +168,6 @@ offset: { 'top': menuTop - navigationOuterHeight } } ); } ); - - adjustScrollClass(); } adjustHeaderHeight(); @@ -175,7 +178,8 @@ } } ); - if ( 'true' === twentyseventeenScreenReaderText.has_navigation ) { + // If navigation menu is present on page, adjust it on scroll and screen resize + if ( $navigation.length ) { // On scroll, we want to stick/unstick the navigation $( window ).on( 'scroll', function() { @@ -187,7 +191,6 @@ $( window ).resize( function() { setNavProps(); setTimeout( adjustScrollClass, 500 ); - setTimeout( adjustHeaderHeight, 1000 ); } ); } @@ -196,6 +199,7 @@ resizeTimer = setTimeout( function() { belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' ); }, 300 ); + setTimeout( adjustHeaderHeight, 1000 ); } ); }( jQuery ) ); diff --git a/src/wp-content/themes/twentyseventeen/functions.php b/src/wp-content/themes/twentyseventeen/functions.php index 71eff2307f..79bfed78d2 100644 --- a/src/wp-content/themes/twentyseventeen/functions.php +++ b/src/wp-content/themes/twentyseventeen/functions.php @@ -368,12 +368,10 @@ function twentyseventeen_scripts() { $twentyseventeen_l10n = array( 'quote' => twentyseventeen_get_svg( array( 'icon' => 'quote-right' ) ), - 'has_navigation' => 'false', ); if ( has_nav_menu( 'top' ) ) { wp_enqueue_script( 'twentyseventeen-navigation', get_theme_file_uri( '/assets/js/navigation.js' ), array(), '1.0', true ); - $twentyseventeen_l10n['has_navigation'] = 'true'; $twentyseventeen_l10n['expand'] = __( 'Expand child menu', 'twentyseventeen' ); $twentyseventeen_l10n['collapse'] = __( 'Collapse child menu', 'twentyseventeen' ); $twentyseventeen_l10n['icon'] = twentyseventeen_get_svg( array( 'icon' => 'angle-down', 'fallback' => true ) ); diff --git a/src/wp-content/themes/twentyseventeen/template-parts/navigation/navigation-top.php b/src/wp-content/themes/twentyseventeen/template-parts/navigation/navigation-top.php index adabb53b29..afc81c4e63 100644 --- a/src/wp-content/themes/twentyseventeen/template-parts/navigation/navigation-top.php +++ b/src/wp-content/themes/twentyseventeen/template-parts/navigation/navigation-top.php @@ -16,7 +16,7 @@ 'menu_id' => 'top-menu', ) ); ?> - + 'arrow-right' ) ); ?>