From 580048525d6a13cb94e668abf45c8e5a4143aa2d Mon Sep 17 00:00:00 2001 From: azaozz Date: Mon, 28 Nov 2011 00:31:11 +0000 Subject: [PATCH] Admin bar: change the tabbing to behave as if the admin bar menus were click-to-open (Tab to select, Enter to open/close), fixes #19088 git-svn-id: http://svn.automattic.com/wordpress/trunk@19458 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/admin-bar.dev.js | 39 +++++++++++++-------------------- wp-includes/js/admin-bar.js | 2 +- wp-includes/script-loader.php | 2 +- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/wp-includes/js/admin-bar.dev.js b/wp-includes/js/admin-bar.dev.js index 2cbd12a9ba..841dd6932c 100644 --- a/wp-includes/js/admin-bar.dev.js +++ b/wp-includes/js/admin-bar.dev.js @@ -4,6 +4,12 @@ if ( typeof(jQuery) != 'undefined' ) { (function(a){a.fn.hoverIntent=function(l,j){var m={sensitivity:7,interval:100,timeout:0};m=a.extend(m,j?{over:l,out:j}:l);var o,n,h,d;var e=function(f){o=f.pageX;n=f.pageY};var c=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);if((Math.abs(h-o)+Math.abs(d-n)) li > .ab-item').bind('focus.adminbar', function(){ - $(this).parent().addClass('hover').find('.ab-item').each(function(i, el){ - var node = $(el), tab = node.attr('tabindex'); - if ( tab ) - node.attr('tabindex', '0').attr('tabindex', tab); - }); - }).bind('blur.adminbar', function(){ - var t = $(this); + $('#wpadminbar li.menupop > .ab-item').bind('keydown.adminbar', function(e){ + if ( e.which != 13 ) + return; - setTimeout(function(){ - if ( !t.siblings('div').find('.ab-item:focus').length ) - t.parent().removeClass('hover'); - }, 200); - }); + var target = $(e.target); - $('.ab-top-menu li ul li .ab-item').bind('blur.adminbar', function(){ - var top = $(this).parents('li.menupop'); + e.stopPropagation(); + e.preventDefault(); + target.parent().toggleClass('hover'); - setTimeout(function(){ - top.each( function() { - var t = $(this); - - if ( ! t.find('.ab-item:focus').length ) - t.removeClass('hover'); - }); - }, 100); - }); + target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh); + }).each(refresh); }); } else { diff --git a/wp-includes/js/admin-bar.js b/wp-includes/js/admin-bar.js index faab6b8dc9..a667946e53 100644 --- a/wp-includes/js/admin-bar.js +++ b/wp-includes/js/admin-bar.js @@ -1 +1 @@ -if(typeof(jQuery)!="undefined"){if(typeof(jQuery.fn.hoverIntent)=="undefined"){(function(b){b.fn.hoverIntent=function(p,r){var g={sensitivity:7,interval:100,timeout:0};g=b.extend(g,r?{over:p,out:r}:p);var a,f,t,v;var u=function(c){a=c.pageX;f=c.pageY};var w=function(c,d){d.hoverIntent_t=clearTimeout(d.hoverIntent_t);if((Math.abs(t-a)+Math.abs(v-f)) li > .ab-item").bind("focus.adminbar",function(){a(this).parent().addClass("hover").find(".ab-item").each(function(b,d){var e=a(d),c=e.attr("tabindex");if(c){e.attr("tabindex","0").attr("tabindex",c)}})}).bind("blur.adminbar",function(){var b=a(this);setTimeout(function(){if(!b.siblings("div").find(".ab-item:focus").length){b.parent().removeClass("hover")}},200)});a(".ab-top-menu li ul li .ab-item").bind("blur.adminbar",function(){var b=a(this).parents("li.menupop");setTimeout(function(){b.each(function(){var c=a(this);if(!c.find(".ab-item:focus").length){c.removeClass("hover")}})},100)})})}else{(function(i,k){var c=function(n,m,d){if(n.addEventListener){n.addEventListener(m,d,false)}else{if(n.attachEvent){n.attachEvent("on"+m,function(){return d.call(n,window.event)})}}},e,f=new RegExp("\\bhover\\b","g"),a=[],j=new RegExp("\\bselected\\b","g"),g=function(m){var d=a.length;while(d--){if(a[d]&&m==a[d][1]){return a[d][0]}}return false},h=function(s){var n,d,q,m,p,r,u=[],o=0;while(s&&s!=e&&s!=i){if("LI"==s.nodeName.toUpperCase()){u[u.length]=s;d=g(s);if(d){clearTimeout(d)}s.className=s.className?(s.className.replace(f,"")+" hover"):"hover";m=s}s=s.parentNode}if(m&&m.parentNode){p=m.parentNode;if(p&&"UL"==p.nodeName.toUpperCase()){n=p.childNodes.length;while(n--){r=p.childNodes[n];if(r!=m){r.className=r.className?r.className.replace(j,""):""}}}}n=a.length;while(n--){q=false;o=u.length;while(o--){if(u[o]==a[n][1]){q=true}}if(!q){a[n][1].className=a[n][1].className?a[n][1].className.replace(f,""):""}}},l=function(d){while(d&&d!=e&&d!=i){if("LI"==d.nodeName.toUpperCase()){(function(m){var n=setTimeout(function(){m.className=m.className?m.className.replace(f,""):""},500);a[a.length]=[n,m]})(d)}d=d.parentNode}},b=function(p){var n,d,o,m=p.target||p.srcElement;while(true){if(!m||m==i||m==e){return}if(m.id&&m.id=="wp-admin-bar-get-shortlink"){break}m=m.parentNode}if(p.preventDefault){p.preventDefault()}p.returnValue=false;if(-1==m.className.indexOf("selected")){m.className+=" selected"}for(n=0,d=m.childNodes.length;n .ab-item").bind("keydown.adminbar",function(d){if(d.which!=13){return}var c=b(d.target);d.stopPropagation();d.preventDefault();c.parent().toggleClass("hover");c.siblings(".ab-sub-wrapper").find(".ab-item").each(a)}).each(a)})}else{(function(i,k){var c=function(n,m,d){if(n.addEventListener){n.addEventListener(m,d,false)}else{if(n.attachEvent){n.attachEvent("on"+m,function(){return d.call(n,window.event)})}}},e,f=new RegExp("\\bhover\\b","g"),a=[],j=new RegExp("\\bselected\\b","g"),g=function(m){var d=a.length;while(d--){if(a[d]&&m==a[d][1]){return a[d][0]}}return false},h=function(s){var n,d,q,m,p,r,u=[],o=0;while(s&&s!=e&&s!=i){if("LI"==s.nodeName.toUpperCase()){u[u.length]=s;d=g(s);if(d){clearTimeout(d)}s.className=s.className?(s.className.replace(f,"")+" hover"):"hover";m=s}s=s.parentNode}if(m&&m.parentNode){p=m.parentNode;if(p&&"UL"==p.nodeName.toUpperCase()){n=p.childNodes.length;while(n--){r=p.childNodes[n];if(r!=m){r.className=r.className?r.className.replace(j,""):""}}}}n=a.length;while(n--){q=false;o=u.length;while(o--){if(u[o]==a[n][1]){q=true}}if(!q){a[n][1].className=a[n][1].className?a[n][1].className.replace(f,""):""}}},l=function(d){while(d&&d!=e&&d!=i){if("LI"==d.nodeName.toUpperCase()){(function(m){var n=setTimeout(function(){m.className=m.className?m.className.replace(f,""):""},500);a[a.length]=[n,m]})(d)}d=d.parentNode}},b=function(p){var n,d,o,m=p.target||p.srcElement;while(true){if(!m||m==i||m==e){return}if(m.id&&m.id=="wp-admin-bar-get-shortlink"){break}m=m.parentNode}if(p.preventDefault){p.preventDefault()}p.returnValue=false;if(-1==m.className.indexOf("selected")){m.className+=" selected"}for(n=0,d=m.childNodes.length;nadd( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), '20110628', 1 ); - $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", false, '20111123', 1 ); + $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", false, '20111127', 1 ); $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wpdialogs' ), '20110929', 1 ); $scripts->localize( 'wplink', 'wpLinkL10n', array(