Permalink
Browse files

_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
  • Loading branch information...
ianstewart committed Feb 6, 2012
1 parent 4f3d984 commit a14038728d6a817c3c4222058a859f8a63a81bf7
Showing with 8 additions and 6 deletions.
  1. +1 −1 header.php
  2. +7 −5 js/small-menu.js
View
@@ -54,7 +54,7 @@
</hgroup>
<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>
<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
View
@@ -1,12 +1,13 @@
jQuery( document ).ready( function( $ ) {
var $browserWidth = $( window ).width();
+ var $masthead = $( '#masthead' );
$.fn.smallMenu = function() {
- $( '#masthead .site-navigation' ).removeClass( 'main-navigation' ).addClass( 'main-small-navigation' );
- $( '#masthead .site-navigation h1' ).removeClass( 'assistive-text' ).addClass( 'menu-toggle' );
+ $( $masthead ).find( '.site-navigation' ).removeClass( 'main-navigation' ).addClass( 'main-small-navigation' );
+ $( $masthead ).find( '.site-navigation h1' ).removeClass( 'assistive-text' ).addClass( 'menu-toggle' );
$( '.menu-toggle' ).click( function () {
- $( '#masthead .menu' ).toggle( 'fast' );
+ $( $masthead ).find( '.menu' ).toggle();
});
}
@@ -16,8 +17,9 @@ jQuery( document ).ready( function( $ ) {
if ( $browserWidth < 600 ) {
$.fn.smallMenu();
} else {
- $( '#masthead .site-navigation' ).removeClass( 'main-small-navigation' ).addClass( 'main-navigation' );
- $( '#masthead .site-navigation h1' ).removeClass( 'menu-toggle' ).addClass( 'assistive-text' );
+ $( $masthead ).find( '.site-navigation' ).removeClass( 'main-small-navigation' ).addClass( 'main-navigation' );
+ $( $masthead ).find( '.site-navigation h1' ).removeClass( 'menu-toggle' ).addClass( 'assistive-text' );
+ $( $masthead ).find( '.menu' ).removeAttr( 'style' );
}
});

0 comments on commit a140387

Please sign in to comment.