Customizer: Improve descriptive text and focus for menu items reorder button.

props afercia.
fixes #32725.

git-svn-id: https://develop.svn.wordpress.org/trunk@33074 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2015-07-03 21:23:12 +00:00
parent e33229a237
commit 787016376a
4 changed files with 26 additions and 4 deletions

View File

@ -91,7 +91,14 @@
}
/* Menu-item reordering nav. */
#customize-theme-controls button.reorder-toggle {
#customize-theme-controls .reordering .reorder,
#customize-theme-controls .reorder-done {
display: none;
}
#customize-theme-controls .reorder,
#customize-theme-controls .reordering .reorder-done {
display: inline-block;
padding: 5px 8px;
}

View File

@ -1932,6 +1932,9 @@
* @param {Boolean} showOrHide to enable/disable reordering
*/
toggleReordering: function( showOrHide ) {
var addNewItemBtn = this.container.find( '.add-new-menu-item' ),
reorderBtn = this.container.find( '.reorder-toggle' );
showOrHide = Boolean( showOrHide );
if ( showOrHide === this.$sectionContent.hasClass( 'reordering' ) ) {
@ -1941,6 +1944,15 @@
this.isReordering = showOrHide;
this.$sectionContent.toggleClass( 'reordering', showOrHide );
this.$sectionContent.sortable( this.isReordering ? 'disable' : 'enable' );
if ( this.isReordering ) {
addNewItemBtn.attr( 'tabindex', '-1' );
reorderBtn.find( '.reorder-done' ).focus();
wp.a11y.speak( api.Menus.data.l10n.reorderModeOn );
} else {
addNewItemBtn.removeAttr( 'tabindex' );
reorderBtn.find( '.reorder' ).focus();
wp.a11y.speak( api.Menus.data.l10n.reorderModeOff );
}
if ( showOrHide ) {
_( this.getMenuItemControls() ).each( function( formControl ) {

View File

@ -1450,10 +1450,11 @@ class WP_Customize_Nav_Menu_Control extends WP_Customize_Control {
<button type="button" class="button-secondary add-new-menu-item" aria-label="<?php esc_attr_e( 'Add or remove menu items' ); ?>" aria-expanded="false" aria-controls="available-menu-items">
<?php _e( 'Add Items' ); ?>
</button>
<button type="button" class="not-a-button reorder-toggle">
<span class="reorder"><?php _ex( 'Reorder', 'Reorder menu items in Customizer' ); ?></span>
<span class="reorder-done"><?php _ex( 'Done', 'Cancel reordering menu items in Customizer' ); ?></span>
<button type="button" role="presentation" class="not-a-button reorder-toggle" tabindex="-1">
<span class="reorder" tabindex="0" role="button" aria-label="<?php esc_attr_e( 'Reorder menu items' ); ?>" aria-describedby="reorder-items-desc"><?php _ex( 'Reorder', 'Reorder menu items in Customizer' ); ?></span>
<span class="reorder-done" tabindex="0" role="button" aria-label="<?php esc_attr_e( 'Close reorder mode' ); ?>"><?php _ex( 'Done', 'Cancel reordering menu items in Customizer' ); ?></span>
</button>
<p class="screen-reader-text" id="reorder-items-desc"><?php _e( 'When in reorder mode, additional controls to reorder menu items will be available in the items list above.' ); ?></p>
<span class="add-menu-item-loading spinner"></span>
<span class="menu-delete-item">
<button type="button" class="not-a-button menu-delete">

View File

@ -305,6 +305,8 @@ final class WP_Customize_Nav_Menus {
'itemsFound' => __( 'Number of items found: %d' ),
'itemsFoundMore' => __( 'Additional items found: %d' ),
'itemsLoadingMore' => __( 'Loading more results... please wait.' ),
'reorderModeOn' => __( 'Reorder mode enabled' ),
'reorderModeOff' => __( 'Reorder mode closed' ),
),
'menuItemTransport' => 'postMessage',
'phpIntMax' => PHP_INT_MAX,