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:
parent
b37b90b6f4
commit
d13b9b284a
@ -142,20 +142,25 @@
|
|||||||
// Fires on document ready
|
// Fires on document ready
|
||||||
$( document ).ready( function() {
|
$( document ).ready( function() {
|
||||||
|
|
||||||
// Let's fire some JavaScript!
|
// If navigation menu is present on page, setNavProps and adjustScrollClass
|
||||||
|
if( $navigation.length ) {
|
||||||
setNavProps();
|
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 ) {
|
if ( $menuScrollDown.length ) {
|
||||||
|
|
||||||
/**
|
|
||||||
* 'Scroll Down' arrow in menu area
|
|
||||||
*/
|
|
||||||
if ( $( 'body' ).hasClass( 'admin-bar' ) ) {
|
if ( $( 'body' ).hasClass( 'admin-bar' ) ) {
|
||||||
menuTop -= 32;
|
menuTop -= 32;
|
||||||
}
|
}
|
||||||
if ( $( 'body' ).hasClass( 'blog' ) ) {
|
if ( $( 'body' ).hasClass( 'blog' ) ) {
|
||||||
menuTop -= 30; // The div for latest posts has no space above content, add some to account for this
|
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 ) {
|
$menuScrollDown.click( function( e ) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$( window ).scrollTo( '#primary', {
|
$( window ).scrollTo( '#primary', {
|
||||||
@ -163,8 +168,6 @@
|
|||||||
offset: { 'top': menuTop - navigationOuterHeight }
|
offset: { 'top': menuTop - navigationOuterHeight }
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
adjustScrollClass();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
adjustHeaderHeight();
|
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
|
// On scroll, we want to stick/unstick the navigation
|
||||||
$( window ).on( 'scroll', function() {
|
$( window ).on( 'scroll', function() {
|
||||||
@ -187,7 +191,6 @@
|
|||||||
$( window ).resize( function() {
|
$( window ).resize( function() {
|
||||||
setNavProps();
|
setNavProps();
|
||||||
setTimeout( adjustScrollClass, 500 );
|
setTimeout( adjustScrollClass, 500 );
|
||||||
setTimeout( adjustHeaderHeight, 1000 );
|
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,6 +199,7 @@
|
|||||||
resizeTimer = setTimeout( function() {
|
resizeTimer = setTimeout( function() {
|
||||||
belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' );
|
belowEntryMetaClass( 'blockquote.alignleft, blockquote.alignright' );
|
||||||
}, 300 );
|
}, 300 );
|
||||||
|
setTimeout( adjustHeaderHeight, 1000 );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
}( jQuery ) );
|
}( jQuery ) );
|
||||||
|
@ -368,12 +368,10 @@ function twentyseventeen_scripts() {
|
|||||||
|
|
||||||
$twentyseventeen_l10n = array(
|
$twentyseventeen_l10n = array(
|
||||||
'quote' => twentyseventeen_get_svg( array( 'icon' => 'quote-right' ) ),
|
'quote' => twentyseventeen_get_svg( array( 'icon' => 'quote-right' ) ),
|
||||||
'has_navigation' => 'false',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( has_nav_menu( 'top' ) ) {
|
if ( has_nav_menu( 'top' ) ) {
|
||||||
wp_enqueue_script( 'twentyseventeen-navigation', get_theme_file_uri( '/assets/js/navigation.js' ), array(), '1.0', true );
|
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['expand'] = __( 'Expand child menu', 'twentyseventeen' );
|
||||||
$twentyseventeen_l10n['collapse'] = __( 'Collapse child menu', 'twentyseventeen' );
|
$twentyseventeen_l10n['collapse'] = __( 'Collapse child menu', 'twentyseventeen' );
|
||||||
$twentyseventeen_l10n['icon'] = twentyseventeen_get_svg( array( 'icon' => 'angle-down', 'fallback' => true ) );
|
$twentyseventeen_l10n['icon'] = twentyseventeen_get_svg( array( 'icon' => 'angle-down', 'fallback' => true ) );
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
'menu_id' => 'top-menu',
|
'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>
|
<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; ?>
|
<?php endif; ?>
|
||||||
</nav><!-- #site-navigation -->
|
</nav><!-- #site-navigation -->
|
||||||
|
Loading…
Reference in New Issue
Block a user