Skip to content

Commit

Permalink
Update js/small-menu.js
Browse files Browse the repository at this point in the history
Rather than using the number `600` in multiple places it makes more sense to create a variable that holds the value. It is easier to read and it is easier to update.
  • Loading branch information
BFTrick committed Feb 26, 2013
1 parent 50cee30 commit c1826b1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions js/small-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Handles toggling the main navigation menu for small screens.
*/
jQuery( document ).ready( function( $ ) {
var smallScreenWidth = 600;
var $masthead = $( '#masthead' ),
timeout = false;

Expand All @@ -16,7 +17,7 @@ jQuery( document ).ready( function( $ ) {
};

// Check viewport width on first load.
if ( $( window ).width() < 600 )
if ( $( window ).width() < smallScreenWidth )
$.fn.smallMenu();

// Check viewport width when user resizes the browser window.
Expand All @@ -27,7 +28,7 @@ jQuery( document ).ready( function( $ ) {
clearTimeout( timeout );

timeout = setTimeout( function() {
if ( browserWidth < 600 ) {
if ( browserWidth < smallScreenWidth ) {
$.fn.smallMenu();
} else {
$masthead.find( '.site-navigation' ).removeClass( 'main-small-navigation' ).addClass( 'main-navigation' );
Expand All @@ -36,4 +37,4 @@ jQuery( document ).ready( function( $ ) {
}
}, 200 );
} );
} );
} );

1 comment on commit c1826b1

@iamtakashi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice but one nitpick:) I think it would be cleaner to define the smallScreenWidth inside the existing statement below with a comma.

Please sign in to comment.