- Timestamp:
- 03/19/2014 05:28:24 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentytwelve/js/navigation.js
r22574 r27606 1 1 /** 2 * navigation.js 3 * 4 * Handles toggling the navigation menu for small screens. 2 * Handles toggling the navigation menu for small screens and 3 * accessibility for submenu items. 5 4 */ 6 5 ( function() { 7 6 var nav = document.getElementById( 'site-navigation' ), button, menu; 8 if ( ! nav ) 7 if ( ! nav ) { 9 8 return; 9 } 10 10 11 button = nav.getElementsByTagName( 'h3' )[0]; 11 12 menu = nav.getElementsByTagName( 'ul' )[0]; 12 if ( ! button ) 13 if ( ! button ) { 13 14 return; 15 } 14 16 15 17 // Hide button if menu is missing or empty. … … 20 22 21 23 button.onclick = function() { 22 if ( -1 == menu.className.indexOf( 'nav-menu' ) )24 if ( -1 === menu.className.indexOf( 'nav-menu' ) ) { 23 25 menu.className = 'nav-menu'; 26 } 24 27 25 if ( -1 != button.className.indexOf( 'toggled-on' ) ) {28 if ( -1 !== button.className.indexOf( 'toggled-on' ) ) { 26 29 button.className = button.className.replace( ' toggled-on', '' ); 27 30 menu.className = menu.className.replace( ' toggled-on', '' ); … … 32 35 }; 33 36 } )(); 37 38 // Better focus for hidden submenu items for accessibility. 39 ( function( $ ) { 40 $( '.main-navigation' ).find( 'a' ).on( 'focus.twentytwelve blur.twentytwelve', function() { 41 $( this ).parents( '.menu-item, .page_item' ).toggleClass( 'focus' ); 42 } ); 43 } )( jQuery );
Note: See TracChangeset
for help on using the changeset viewer.