Ticket #31527: 31527.twentyfourteen.2.patch
File 31527.twentyfourteen.2.patch, 2.8 KB (added by , 10 years ago) |
---|
-
wp-content/themes/twentyfourteen/header.php
51 51 <nav id="primary-navigation" class="site-navigation primary-navigation" role="navigation"> 52 52 <button class="menu-toggle"><?php _e( 'Primary Menu', 'twentyfourteen' ); ?></button> 53 53 <a class="screen-reader-text skip-link" href="#content"><?php _e( 'Skip to content', 'twentyfourteen' ); ?></a> 54 <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>54 <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu', 'menu_id' => 'primary-menu' ) ); ?> 55 55 </nav> 56 56 </div> 57 57 -
wp-content/themes/twentyfourteen/js/functions.js
7 7 */ 8 8 ( function( $ ) { 9 9 var body = $( 'body' ), 10 _window = $( window ); 10 _window = $( window ), 11 nav, button, menu; 11 12 13 nav = $( '#primary-navigation' ); 14 button = nav.find( '.menu-toggle' ); 15 menu = nav.find( '.nav-menu' ); 16 12 17 // Enable menu toggle for small screens. 13 18 ( function() { 14 var nav = $( '#primary-navigation' ), button, menu; 15 if ( ! nav ) { 19 if ( ! nav || ! button ) { 16 20 return; 17 21 } 18 22 19 button = nav.find( '.menu-toggle' );20 if ( ! button ) {21 return;22 }23 24 23 // Hide button if menu is missing or empty. 25 menu = nav.find( '.nav-menu' );26 24 if ( ! menu || ! menu.children().length ) { 27 25 button.hide(); 28 26 return; 29 27 } 30 28 31 $( '.menu-toggle' ).on( 'click.twentyfourteen', function() {29 button.on( 'click.twentyfourteen', function() { 32 30 nav.toggleClass( 'toggled-on' ); 31 if ( nav.hasClass( 'toggled-on' ) ) { 32 $( this ).attr( 'aria-expanded', 'true' ); 33 menu.attr( 'aria-expanded', 'true' ); 34 } else { 35 $( this ).attr( 'aria-expanded', 'false' ); 36 menu.attr( 'aria-expanded', 'false' ); 37 } 33 38 } ); 34 39 } )(); 35 40 … … 109 114 } ); 110 115 } ); 111 116 117 // Add or remove ARIA attributes. 118 function onResizeARIA() { 119 if ( 781 > _window.width() ) { 120 button.attr( 'aria-expanded', 'false' ); 121 menu.attr( 'aria-expanded', 'false' ); 122 button.attr( 'aria-controls', 'primary-menu' ); 123 } else { 124 button.removeAttr( 'aria-expanded' ); 125 menu.removeAttr( 'aria-expanded' ); 126 button.removeAttr( 'aria-controls' ); 127 } 128 } 129 130 _window 131 .on( 'load.twentyfourteen', onResizeARIA ) 132 .on( 'resize.twentyfourteen', function() { 133 onResizeARIA(); 134 } ); 135 112 136 _window.load( function() { 113 137 // Arrange footer widgets vertically. 114 138 if ( $.isFunction( $.fn.masonry ) ) {