Twenty Fourteen: add ARIA attributes to search toggle. See #31527.

git-svn-id: https://develop.svn.wordpress.org/trunk@31794 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Lance Willett 2015-03-16 18:50:50 +00:00
parent 12784e13d4
commit fce4ab09f2
2 changed files with 9 additions and 2 deletions

View File

@ -45,7 +45,7 @@
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<div class="search-toggle">
<a href="#search-container" class="screen-reader-text"><?php _e( 'Search', 'twentyfourteen' ); ?></a>
<a href="#search-container" class="screen-reader-text" aria-expanded="false" aria-controls="search-container"><?php _e( 'Search', 'twentyfourteen' ); ?></a>
</div>
<nav id="primary-navigation" class="site-navigation primary-navigation" role="navigation">

View File

@ -69,11 +69,18 @@
// Search toggle.
$( '.search-toggle' ).on( 'click.twentyfourteen', function( event ) {
var that = $( this ),
wrapper = $( '.search-box-wrapper' );
wrapper = $( '#search-container' ),
container = that.find( 'a' );
that.toggleClass( 'active' );
wrapper.toggleClass( 'hide' );
if ( that.hasClass( 'active' ) ) {
container.attr( 'aria-expanded', 'true' );
} else {
container.attr( 'aria-expanded', 'false' );
}
if ( that.is( '.active' ) || $( '.search-toggle .screen-reader-text' )[0] === event.target ) {
wrapper.find( '.search-field' ).focus();
}