From 38c6bcbb55f6a3bbda7487f4ac4708a4769a08a0 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 10 Nov 2010 16:19:55 +0000 Subject: [PATCH] Admin bar hover fixes. Props filosofo. see #15307 git-svn-id: https://develop.svn.wordpress.org/trunk@16274 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/js/admin-bar.dev.js | 24 +++++++++++++++++++++++- wp-includes/js/admin-bar.js | 2 +- wp-includes/script-loader.php | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/wp-includes/js/admin-bar.dev.js b/wp-includes/js/admin-bar.dev.js index 0292dfb1b0..57c56fc1f0 100644 --- a/wp-includes/js/admin-bar.dev.js +++ b/wp-includes/js/admin-bar.dev.js @@ -8,6 +8,9 @@ aB, hc = new RegExp('\\bhover\\b', 'g'), q = [], + /** + * Get the timeout ID of the given element + */ getTOID = function(el) { var i = q.length; while( i-- ) @@ -17,15 +20,34 @@ }, addClass = function(t) { + var ancestors = [], + ancestorLength = 0, + id, + i = q.length, + inA; while ( t && t != aB && t != d ) { if( 'LI' == t.nodeName.toUpperCase() ) { - var id = getTOID(t); + ancestors[ ancestors.length ] = t; + id = getTOID(t); if ( id ) clearTimeout( id ); t.className = t.className ? ( t.className.replace(hc, '') + ' hover' ) : 'hover'; } t = t.parentNode; } + + /* remove the hover class for any objects not in the immediate element's ancestry */ + while ( i-- ) { + inA = false; + ancestorLength = ancestors.length; + while( ancestorLength-- ) { + if ( ancestors[ ancestorLength ] == q[i][1] ) + inA = true; + } + + if ( ! inA ) + q[i][1].className = q[i][1].className ? q[i][1].className.replace(hc, '') : ''; + } }, removeClass = function(t) { diff --git a/wp-includes/js/admin-bar.js b/wp-includes/js/admin-bar.js index 57eb333e18..33dcec4ffe 100644 --- a/wp-includes/js/admin-bar.js +++ b/wp-includes/js/admin-bar.js @@ -1 +1 @@ -(function(i,j){var c=function(m,l,d){if(m.addEventListener){m.addEventListener(l,d,false)}else{if(m.attachEvent){m.attachEvent("on"+l,function(){return d.call(m,window.event)})}}},e,f=new RegExp("\\bhover\\b","g"),a=[],g=function(l){var d=a.length;while(d--){if(a[d]&&l==a[d][1]){return a[d][0]}}return false},h=function(d){while(d&&d!=e&&d!=i){if("LI"==d.nodeName.toUpperCase()){var l=g(d);if(l){clearTimeout(l)}d.className=d.className?(d.className.replace(f,"")+" hover"):"hover"}d=d.parentNode}},k=function(d){while(d&&d!=e&&d!=i){if("LI"==d.nodeName.toUpperCase()){(function(l){var m=setTimeout(function(){l.className=l.className?l.className.replace(f,""):""},500);a[a.length]=[m,l]})(d)}d=d.parentNode}},b=function(n){var m=n.target||n.srcElement,d,l;if("undefined"==typeof adminBarL10n){return}while(m&&m!=e&&m!=i&&(!m.className||-1==m.className.indexOf("ab-get-shortlink"))){m=m.parentNode}if(m&&m.className&&-1!=m.className.indexOf("ab-get-shortlink")){d=i.getElementsByTagName("link");if(!d.length){d=i.links}l=d.length;if(n.preventDefault){n.preventDefault()}n.returnValue=false;while(l--){if(d[l]&&"shortlink"==d[l].getAttribute("rel")){prompt(adminBarL10n.url,d[l].href);return false}}alert(adminBarL10n.noShortlink);return false}};c(j,"load",function(){var d=i.getElementsByTagName("body")[0],l=i.getElementById("adminbar-search");e=i.getElementById("wpadminbar");if(d&&e){d.appendChild(e);c(e,"mouseover",function(m){h(m.target||m.srcElement)});c(e,"mouseout",function(m){k(m.target||m.srcElement)});c(e,"click",b)}if(l){if(""==l.value){l.value=l.getAttribute("title")}l.onblur=function(){this.value=""==this.value?this.getAttribute("title"):this.value};l.onfocus=function(){this.value=this.getAttribute("title")==this.value?"":this.value}}if(j.location.hash){j.scrollBy(0,-32)}})})(document,window); \ No newline at end of file +(function(i,j){var c=function(m,l,d){if(m.addEventListener){m.addEventListener(l,d,false)}else{if(m.attachEvent){m.attachEvent("on"+l,function(){return d.call(m,window.event)})}}},e,f=new RegExp("\\bhover\\b","g"),a=[],g=function(l){var d=a.length;while(d--){if(a[d]&&l==a[d][1]){return a[d][0]}}return false},h=function(l){var m=[],p=0,o,d=a.length,n;while(l&&l!=e&&l!=i){if("LI"==l.nodeName.toUpperCase()){m[m.length]=l;o=g(l);if(o){clearTimeout(o)}l.className=l.className?(l.className.replace(f,"")+" hover"):"hover"}l=l.parentNode}while(d--){n=false;p=m.length;while(p--){if(m[p]==a[d][1]){n=true}}if(!n){a[d][1].className=a[d][1].className?a[d][1].className.replace(f,""):""}}},k=function(d){while(d&&d!=e&&d!=i){if("LI"==d.nodeName.toUpperCase()){(function(l){var m=setTimeout(function(){l.className=l.className?l.className.replace(f,""):""},500);a[a.length]=[m,l]})(d)}d=d.parentNode}},b=function(n){var m=n.target||n.srcElement,d,l;if("undefined"==typeof adminBarL10n){return}while(m&&m!=e&&m!=i&&(!m.className||-1==m.className.indexOf("ab-get-shortlink"))){m=m.parentNode}if(m&&m.className&&-1!=m.className.indexOf("ab-get-shortlink")){d=i.getElementsByTagName("link");if(!d.length){d=i.links}l=d.length;if(n.preventDefault){n.preventDefault()}n.returnValue=false;while(l--){if(d[l]&&"shortlink"==d[l].getAttribute("rel")){prompt(adminBarL10n.url,d[l].href);return false}}alert(adminBarL10n.noShortlink);return false}};c(j,"load",function(){var d=i.getElementsByTagName("body")[0],l=i.getElementById("adminbar-search");e=i.getElementById("wpadminbar");if(d&&e){d.appendChild(e);c(e,"mouseover",function(m){h(m.target||m.srcElement)});c(e,"mouseout",function(m){k(m.target||m.srcElement)});c(e,"click",b)}if(l){if(""==l.value){l.value=l.getAttribute("title")}l.onblur=function(){this.value=""==this.value?this.getAttribute("title"):this.value};l.onfocus=function(){this.value=this.getAttribute("title")==this.value?"":this.value}}if(j.location.hash){j.scrollBy(0,-32)}})})(document,window); \ No newline at end of file diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index ac82df9be3..ca1e6d1576 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -499,7 +499,7 @@ function wp_default_styles( &$styles ) { $styles->add( 'nav-menu', "/wp-admin/css/nav-menu$suffix.css", array(), '20100907' ); // Admin bar - $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array(), '20101029' ); + $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array(), '20101110' ); foreach ( $rtl_styles as $rtl_style ) { $styles->add_data( $rtl_style, 'rtl', true );