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:
parent
12784e13d4
commit
fce4ab09f2
@ -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">
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user