The Twenty Twelve for WordPress.
props drewstrojny, lancewillett.
also props corvannoorloos, jeffsebring, kobenland, iandstewart, mfields,
mtdesign, op12no2, philiparthurmoore, sixhours, mamaduka.
see #19978.
git-svn-id: http://core.svn.wordpress.org/trunk@21261 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-07-12 00:20:46 -04:00
|
|
|
/**
|
|
|
|
* navigation.js
|
|
|
|
*
|
|
|
|
* Handles toggling the navigation menu for small screens.
|
|
|
|
*/
|
|
|
|
|
|
|
|
jQuery( document ).ready( function( $ ) {
|
|
|
|
var masthead = $( '#masthead' ),
|
|
|
|
largeWindow = window.matchMedia( 'screen and (min-width: 600px)' ),
|
|
|
|
timeout = false;
|
|
|
|
|
|
|
|
$.fn.smallMenu = function() {
|
2012-08-02 15:53:45 -04:00
|
|
|
masthead.find( '.site-navigation' ).removeClass( 'main-navigation' ).addClass( 'main-small-navigation' );
|
|
|
|
masthead.find( '.site-navigation h3' ).removeClass( 'assistive-text' ).addClass( 'menu-toggle' );
|
The Twenty Twelve for WordPress.
props drewstrojny, lancewillett.
also props corvannoorloos, jeffsebring, kobenland, iandstewart, mfields,
mtdesign, op12no2, philiparthurmoore, sixhours, mamaduka.
see #19978.
git-svn-id: http://core.svn.wordpress.org/trunk@21261 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-07-12 00:20:46 -04:00
|
|
|
|
|
|
|
$( '.menu-toggle' ).off( 'click' ).click( function() {
|
|
|
|
masthead.find( '.menu' ).slideToggle();
|
|
|
|
$( this ).toggleClass( 'toggled-on' );
|
|
|
|
} );
|
|
|
|
};
|
|
|
|
|
|
|
|
// Check viewport width on first load.
|
|
|
|
if ( ! largeWindow.matches )
|
|
|
|
$.fn.smallMenu();
|
|
|
|
|
|
|
|
// Check viewport width when user resizes the browser window.
|
|
|
|
$( window ).resize( function() {
|
|
|
|
if ( false !== timeout )
|
|
|
|
clearTimeout( timeout );
|
|
|
|
|
|
|
|
timeout = setTimeout( function() {
|
|
|
|
if ( ! largeWindow.matches ) {
|
|
|
|
$.fn.smallMenu();
|
|
|
|
} else {
|
2012-08-02 15:53:45 -04:00
|
|
|
masthead.find( '.site-navigation' ).removeClass( 'main-small-navigation' ).addClass( 'main-navigation' );
|
|
|
|
masthead.find( '.site-navigation h3' ).removeClass( 'menu-toggle' ).addClass( 'assistive-text' );
|
The Twenty Twelve for WordPress.
props drewstrojny, lancewillett.
also props corvannoorloos, jeffsebring, kobenland, iandstewart, mfields,
mtdesign, op12no2, philiparthurmoore, sixhours, mamaduka.
see #19978.
git-svn-id: http://core.svn.wordpress.org/trunk@21261 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-07-12 00:20:46 -04:00
|
|
|
masthead.find( '.menu' ).removeAttr( 'style' );
|
|
|
|
}
|
|
|
|
}, 200 );
|
|
|
|
} );
|
|
|
|
} );
|