Twenty Thirteen: add ARIA attributes to menu toggle. See #31527.
Built from https://develop.svn.wordpress.org/trunk@31785 git-svn-id: http://core.svn.wordpress.org/trunk@31765 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f81f253434
commit
c0c8c61d26
|
@ -170,7 +170,7 @@ function twentythirteen_scripts_styles() {
|
|||
wp_enqueue_script( 'jquery-masonry' );
|
||||
|
||||
// Loads JavaScript file with functionality specific to Twenty Thirteen.
|
||||
wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '2014-06-08', true );
|
||||
wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20150315', true );
|
||||
|
||||
// Add Source Sans Pro and Bitter fonts, used in the main stylesheet.
|
||||
wp_enqueue_style( 'twentythirteen-fonts', twentythirteen_fonts_url(), array(), null );
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<nav id="site-navigation" class="navigation main-navigation" role="navigation">
|
||||
<button class="menu-toggle"><?php _e( 'Menu', 'twentythirteen' ); ?></button>
|
||||
<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>
|
||||
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
|
||||
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu', 'menu_id' => 'primary-menu' ) ); ?>
|
||||
<?php get_search_form(); ?>
|
||||
</nav><!-- #site-navigation -->
|
||||
</div><!-- #navbar -->
|
||||
|
|
|
@ -6,7 +6,12 @@
|
|||
|
||||
( function( $ ) {
|
||||
var body = $( 'body' ),
|
||||
_window = $( window );
|
||||
_window = $( window ),
|
||||
nav, button, menu;
|
||||
|
||||
nav = $( '#site-navigation' );
|
||||
button = nav.find( '.menu-toggle' );
|
||||
menu = nav.find( '.nav-menu' );
|
||||
|
||||
/**
|
||||
* Adds a top margin to the footer if the sidebar widget area is higher
|
||||
|
@ -29,18 +34,11 @@
|
|||
* Enables menu toggle for small screens.
|
||||
*/
|
||||
( function() {
|
||||
var nav = $( '#site-navigation' ), button, menu;
|
||||
if ( ! nav ) {
|
||||
return;
|
||||
}
|
||||
|
||||
button = nav.find( '.menu-toggle' );
|
||||
if ( ! button ) {
|
||||
if ( ! nav || ! button ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide button if menu is missing or empty.
|
||||
menu = nav.find( '.nav-menu' );
|
||||
if ( ! menu || ! menu.children().length ) {
|
||||
button.hide();
|
||||
return;
|
||||
|
@ -48,6 +46,13 @@
|
|||
|
||||
button.on( 'click.twentythirteen', function() {
|
||||
nav.toggleClass( 'toggled-on' );
|
||||
if ( nav.hasClass( 'toggled-on' ) ) {
|
||||
$( this ).attr( 'aria-expanded', 'true' );
|
||||
menu.attr( 'aria-expanded', 'true' );
|
||||
} else {
|
||||
$( this ).attr( 'aria-expanded', 'false' );
|
||||
menu.attr( 'aria-expanded', 'false' );
|
||||
}
|
||||
} );
|
||||
|
||||
// Fix sub-menus for touch devices.
|
||||
|
@ -69,6 +74,25 @@
|
|||
} );
|
||||
} )();
|
||||
|
||||
// Add or remove ARIA attributes.
|
||||
function onResizeARIA() {
|
||||
if ( 643 > _window.width() ) {
|
||||
button.attr( 'aria-expanded', 'false' );
|
||||
menu.attr( 'aria-expanded', 'false' );
|
||||
button.attr( 'aria-controls', 'primary-menu' );
|
||||
} else {
|
||||
button.removeAttr( 'aria-expanded' );
|
||||
menu.removeAttr( 'aria-expanded' );
|
||||
button.removeAttr( 'aria-controls' );
|
||||
}
|
||||
}
|
||||
|
||||
_window
|
||||
.on( 'load.twentythirteen', onResizeARIA )
|
||||
.on( 'resize.twentythirteen', function() {
|
||||
onResizeARIA();
|
||||
} );
|
||||
|
||||
/**
|
||||
* Makes "skip to content" link work correctly in IE9 and Chrome for better
|
||||
* accessibility.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.2-beta1-31784';
|
||||
$wp_version = '4.2-beta1-31785';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue