Ticket #31527: 31527.twentythirteen.2.patch
File 31527.twentythirteen.2.patch, 3.1 KB (added by , 10 years ago) |
---|
-
wp-content/themes/twentythirteen/header.php
42 42 <nav id="site-navigation" class="navigation main-navigation" role="navigation"> 43 43 <button class="menu-toggle"><?php _e( 'Menu', 'twentythirteen' ); ?></button> 44 44 <a class="screen-reader-text skip-link" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentythirteen' ); ?>"><?php _e( 'Skip to content', 'twentythirteen' ); ?></a> 45 <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>45 <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu', 'menu_id' => 'primary-menu' ) ); ?> 46 46 <?php get_search_form(); ?> 47 47 </nav><!-- #site-navigation --> 48 48 </div><!-- #navbar --> -
wp-content/themes/twentythirteen/js/functions.js
6 6 7 7 ( function( $ ) { 8 8 var body = $( 'body' ), 9 _window = $( window ); 9 _window = $( window ), 10 nav, button, menu, tertiary; 10 11 12 nav = $( '#site-navigation' ); 13 button = nav.find( '.menu-toggle' ); 14 menu = nav.find( '.nav-menu' ); 15 11 16 /** 12 17 * Adds a top margin to the footer if the sidebar widget area is higher 13 18 * than the rest of the page, to help the footer always visually clear … … 29 34 * Enables menu toggle for small screens. 30 35 */ 31 36 ( function() { 32 var nav = $( '#site-navigation' ), button, menu; 33 if ( ! nav ) { 37 if ( ! nav || ! button ) { 34 38 return; 35 39 } 36 40 37 button = nav.find( '.menu-toggle' );38 if ( ! button ) {39 return;40 }41 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(); 46 44 return; … … 48 46 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 53 58 // Fix sub-menus for touch devices. … … 69 74 } ); 70 75 } )(); 71 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 } ); 95 72 96 /** 73 97 * Makes "skip to content" link work correctly in IE9 and Chrome for better 74 98 * accessibility.