forked from mirror/_s
_s: cache the masthead selector and use find to grab it's descendants to improve performance while removing the style attribute on the toggled menu to prevent it from seeming to disappear on resizing up when the menu is toggled off
git-svn-id: https://wpcom-themes.svn.automattic.com/_s/@8875 d957f892-c61d-0410-b221-f235e6eecf30
This commit is contained in:
parent
4f3d984c7c
commit
a14038728d
|
@ -54,7 +54,7 @@
|
||||||
</hgroup>
|
</hgroup>
|
||||||
|
|
||||||
<nav role="navigation" class="site-navigation main-navigation">
|
<nav role="navigation" class="site-navigation main-navigation">
|
||||||
<h1 class="assistive-text"><?php _e( 'Main menu', '_s' ); ?></h1>
|
<h1 class="assistive-text"><?php _e( 'Menu', '_s' ); ?></h1>
|
||||||
<div class="assistive-text skip-link"><a href="#content" title="<?php esc_attr_e( 'Skip to content', '_s' ); ?>"><?php _e( 'Skip to content', '_s' ); ?></a></div>
|
<div class="assistive-text skip-link"><a href="#content" title="<?php esc_attr_e( 'Skip to content', '_s' ); ?>"><?php _e( 'Skip to content', '_s' ); ?></a></div>
|
||||||
|
|
||||||
<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
|
<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
jQuery( document ).ready( function( $ ) {
|
jQuery( document ).ready( function( $ ) {
|
||||||
var $browserWidth = $( window ).width();
|
var $browserWidth = $( window ).width();
|
||||||
|
var $masthead = $( '#masthead' );
|
||||||
|
|
||||||
$.fn.smallMenu = function() {
|
$.fn.smallMenu = function() {
|
||||||
$( '#masthead .site-navigation' ).removeClass( 'main-navigation' ).addClass( 'main-small-navigation' );
|
$( $masthead ).find( '.site-navigation' ).removeClass( 'main-navigation' ).addClass( 'main-small-navigation' );
|
||||||
$( '#masthead .site-navigation h1' ).removeClass( 'assistive-text' ).addClass( 'menu-toggle' );
|
$( $masthead ).find( '.site-navigation h1' ).removeClass( 'assistive-text' ).addClass( 'menu-toggle' );
|
||||||
|
|
||||||
$( '.menu-toggle' ).click( function () {
|
$( '.menu-toggle' ).click( function () {
|
||||||
$( '#masthead .menu' ).toggle( 'fast' );
|
$( $masthead ).find( '.menu' ).toggle();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +17,9 @@ jQuery( document ).ready( function( $ ) {
|
||||||
if ( $browserWidth < 600 ) {
|
if ( $browserWidth < 600 ) {
|
||||||
$.fn.smallMenu();
|
$.fn.smallMenu();
|
||||||
} else {
|
} else {
|
||||||
$( '#masthead .site-navigation' ).removeClass( 'main-small-navigation' ).addClass( 'main-navigation' );
|
$( $masthead ).find( '.site-navigation' ).removeClass( 'main-small-navigation' ).addClass( 'main-navigation' );
|
||||||
$( '#masthead .site-navigation h1' ).removeClass( 'menu-toggle' ).addClass( 'assistive-text' );
|
$( $masthead ).find( '.site-navigation h1' ).removeClass( 'menu-toggle' ).addClass( 'assistive-text' );
|
||||||
|
$( $masthead ).find( '.menu' ).removeAttr( 'style' );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Reference in New Issue