Add tabbing JS to the admin menu, same functionality as the top menu, see #19394

git-svn-id: http://svn.automattic.com/wordpress/trunk@19485 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2011-11-30 02:15:24 +00:00
parent 7f81dbfe3f
commit 4408443814
3 changed files with 32 additions and 6 deletions

View File

@ -160,9 +160,15 @@ $('.contextual-help-tabs').delegate('a', 'click focus', function(e) {
$(document).ready( function() {
var lastClicked = false, checks, first, last, checked, menu = $('#adminmenu'),
pageInput = $('input.current-page'), currentPage = pageInput.val(), folded;
pageInput = $('input.current-page'), currentPage = pageInput.val(), folded, refresh;
// admin menu
refresh = function(i, el){ // force the browser to refresh the tabbing index
var node = $(el), tab = node.attr('tabindex');
if ( tab )
node.attr('tabindex', '0').attr('tabindex', tab);
};
$('#collapse-menu', menu).click(function(){
var body = $(document.body);
@ -206,9 +212,29 @@ $(document).ready( function() {
interval: 90
});
// If the mouse is used on the menu, shift focus to the mouse.
menu.mouseover( function(e) {
$('li.focused', this).removeClass('focused');
// Tab to select, Enter to open sub, Esc to close sub and focus the top menu
$('li.wp-has-submenu > a.wp-not-current-submenu', menu).bind('keydown.adminmenu', function(e){
if ( e.which != 13 )
return;
var target = $(e.target);
e.stopPropagation();
e.preventDefault();
target.siblings('.wp-submenu').toggleClass('sub-open').find('a[role="menuitem"]').each(refresh);
}).each(refresh);
$('a[role="menuitem"]', menu).bind('keydown.adminmenu', function(e){
if ( e.which != 27 )
return;
var target = $(e.target);
e.stopPropagation();
e.preventDefault();
target.add( target.siblings() ).closest('.sub-open').removeClass('sub-open').siblings('a.wp-not-current-submenu').focus();
});
// Move .updated and .error alert boxes. Don't move boxes designed to be inline.

File diff suppressed because one or more lines are too long

View File

@ -61,7 +61,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20101110' );
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20111123', 1 );
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20111129', 1 );
$scripts->localize( 'common', 'commonL10n', array(
'warnDelete' => __("You are about to permanently delete the selected items.\n 'Cancel' to stop, 'OK' to delete.")
) );