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
This commit is contained in:
David A. Kennedy 2016-11-01 18:59:06 +00:00
parent b37b90b6f4
commit d13b9b284a
3 changed files with 14 additions and 12 deletions

View File

@ -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 ) );

View File

@ -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 ) );

View File

@ -16,7 +16,7 @@
'menu_id' => 'top-menu',
) ); ?>
<?php if ( twentyseventeen_is_frontpage() || ( is_home() && is_front_page() ) ) : ?>
<?php if ( ( twentyseventeen_is_frontpage() || ( is_home() && is_front_page() ) ) && has_custom_header() ) : ?>
<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>
<?php endif; ?>
</nav><!-- #site-navigation -->