mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
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' );
|
wp_enqueue_script( 'jquery-masonry' );
|
||||||
|
|
||||||
// Loads JavaScript file with functionality specific to Twenty Thirteen.
|
// 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.
|
// Add Source Sans Pro and Bitter fonts, used in the main stylesheet.
|
||||||
wp_enqueue_style( 'twentythirteen-fonts', twentythirteen_fonts_url(), array(), null );
|
wp_enqueue_style( 'twentythirteen-fonts', twentythirteen_fonts_url(), array(), null );
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
<nav id="site-navigation" class="navigation main-navigation" role="navigation">
|
<nav id="site-navigation" class="navigation main-navigation" role="navigation">
|
||||||
<button class="menu-toggle"><?php _e( 'Menu', 'twentythirteen' ); ?></button>
|
<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>
|
<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(); ?>
|
<?php get_search_form(); ?>
|
||||||
</nav><!-- #site-navigation -->
|
</nav><!-- #site-navigation -->
|
||||||
</div><!-- #navbar -->
|
</div><!-- #navbar -->
|
||||||
|
@ -6,7 +6,12 @@
|
|||||||
|
|
||||||
( function( $ ) {
|
( function( $ ) {
|
||||||
var body = $( 'body' ),
|
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
|
* Adds a top margin to the footer if the sidebar widget area is higher
|
||||||
@ -29,18 +34,11 @@
|
|||||||
* Enables menu toggle for small screens.
|
* Enables menu toggle for small screens.
|
||||||
*/
|
*/
|
||||||
( function() {
|
( function() {
|
||||||
var nav = $( '#site-navigation' ), button, menu;
|
if ( ! nav || ! button ) {
|
||||||
if ( ! nav ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
button = nav.find( '.menu-toggle' );
|
|
||||||
if ( ! button ) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide button if menu is missing or empty.
|
// Hide button if menu is missing or empty.
|
||||||
menu = nav.find( '.nav-menu' );
|
|
||||||
if ( ! menu || ! menu.children().length ) {
|
if ( ! menu || ! menu.children().length ) {
|
||||||
button.hide();
|
button.hide();
|
||||||
return;
|
return;
|
||||||
@ -48,6 +46,13 @@
|
|||||||
|
|
||||||
button.on( 'click.twentythirteen', function() {
|
button.on( 'click.twentythirteen', function() {
|
||||||
nav.toggleClass( 'toggled-on' );
|
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.
|
// 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
|
* Makes "skip to content" link work correctly in IE9 and Chrome for better
|
||||||
* accessibility.
|
* accessibility.
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user