- Timestamp:
- 03/15/2015 08:00:57 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentythirteen/js/functions.js
r28699 r31785 7 7 ( function( $ ) { 8 8 var body = $( 'body' ), 9 _window = $( window ); 9 _window = $( window ), 10 nav, button, menu; 11 12 nav = $( '#site-navigation' ); 13 button = nav.find( '.menu-toggle' ); 14 menu = nav.find( '.nav-menu' ); 10 15 11 16 /** … … 30 35 */ 31 36 ( function() { 32 var nav = $( '#site-navigation' ), button, menu; 33 if ( ! nav ) { 34 return; 35 } 36 37 button = nav.find( '.menu-toggle' ); 38 if ( ! button ) { 37 if ( ! nav || ! button ) { 39 38 return; 40 39 } 41 40 42 41 // Hide button if menu is missing or empty. 43 menu = nav.find( '.nav-menu' );44 42 if ( ! menu || ! menu.children().length ) { 45 43 button.hide(); … … 49 47 button.on( 'click.twentythirteen', function() { 50 48 nav.toggleClass( 'toggled-on' ); 49 if ( nav.hasClass( 'toggled-on' ) ) { 50 $( this ).attr( 'aria-expanded', 'true' ); 51 menu.attr( 'aria-expanded', 'true' ); 52 } else { 53 $( this ).attr( 'aria-expanded', 'false' ); 54 menu.attr( 'aria-expanded', 'false' ); 55 } 51 56 } ); 52 57 … … 69 74 } ); 70 75 } )(); 76 77 // Add or remove ARIA attributes. 78 function onResizeARIA() { 79 if ( 643 > _window.width() ) { 80 button.attr( 'aria-expanded', 'false' ); 81 menu.attr( 'aria-expanded', 'false' ); 82 button.attr( 'aria-controls', 'primary-menu' ); 83 } else { 84 button.removeAttr( 'aria-expanded' ); 85 menu.removeAttr( 'aria-expanded' ); 86 button.removeAttr( 'aria-controls' ); 87 } 88 } 89 90 _window 91 .on( 'load.twentythirteen', onResizeARIA ) 92 .on( 'resize.twentythirteen', function() { 93 onResizeARIA(); 94 } ); 71 95 72 96 /**
Note: See TracChangeset
for help on using the changeset viewer.