diff options
author | Peter Westwood <westi@git.wordpress.org> | 2010-10-29 07:25:58 +0000 |
---|---|---|
committer | Peter Westwood <westi@git.wordpress.org> | 2010-10-29 07:25:58 +0000 |
commit | a80db4c779966a695d41b6bcb66b22b10ef70a39 (patch) | |
tree | ed76c203c2839f8333228d9154e08339272ba176 /wp-includes/js | |
parent | 743606fac146ff276a6c3729a4706b6c48e9af09 (diff) | |
download | wordpress-a80db4c779966a695d41b6bcb66b22b10ef70a39.tar.gz wordpress-a80db4c779966a695d41b6bcb66b22b10ef70a39.zip |
More admin bar updates. See #14772 props filosofo.
Moves js out into seperate file.
Respects WP_SHOW_ADMIN_BAR.
Moved shortlink to top-level
Removed admin bar from non-multisite admin pages.
Set eol-style on new files.
git-svn-id: https://develop.svn.wordpress.org/trunk@16070 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'wp-includes/js')
-rw-r--r-- | wp-includes/js/admin-bar.dev.js | 116 | ||||
-rw-r--r-- | wp-includes/js/admin-bar.js | 1 |
2 files changed, 117 insertions, 0 deletions
diff --git a/wp-includes/js/admin-bar.dev.js b/wp-includes/js/admin-bar.dev.js new file mode 100644 index 0000000000..d5839bf885 --- /dev/null +++ b/wp-includes/js/admin-bar.dev.js @@ -0,0 +1,116 @@ +(function(d, w) { + var addEvent = function( obj, type, fn ) { + if (obj.addEventListener) + obj.addEventListener(type, fn, false); + else if (obj.attachEvent) + obj.attachEvent('on' + type, function() { return fn.call(obj, window.event);}); + }, + + aB, hc = new RegExp('\\bhover\\b', 'g'), q = [], + + getTOID = function(el) { + var i = q.length; + while( i-- ) + if ( q[i] && el == q[i][1] ) + return q[i][0]; + return false; + }, + + addClass = function(t) { + while ( t && t != aB && t != d ) { + if( 'LI' == t.nodeName.toUpperCase() ) { + var id = getTOID(t); + if ( id ) + clearTimeout( id ); + t.className = t.className ? ( t.className.replace(hc, '') + ' hover' ) : 'hover'; + } + t = t.parentNode; + } + }, + + removeClass = function(t) { + while ( t && t != aB && t != d ) { + if( 'LI' == t.nodeName.toUpperCase() ) { + (function(t) { + var to = setTimeout(function() { + t.className = t.className ? t.className.replace(hc, '') : ''; + }, 500); + q[q.length] = [to, t]; + })(t); + } + t = t.parentNode; + } + } + + clickShortlink = function(e) { + var t = e.target || e.srcElement, links, i; + + + if ( 'undefined' == typeof adminBarL10n ) + return; + + while( t && t != aB && t != d && ( + ! t.className || + -1 == t.className.indexOf('ab-get-shortlink') + ) ) + t = t.parentNode; + + if ( t && t.className && -1 != t.className.indexOf('ab-get-shortlink') ) { + links = d.getElementsByTagName('link'); + if ( ! links.length ) + links = d.links; + + i = links.length; + + if ( e.preventDefault ) + e.preventDefault(); + e.returnValue = false; + + while( i-- ) { + if ( links[i] && 'shortlink' == links[i].getAttribute('rel') ) { + prompt( adminBarL10n.url, links[i].href ); + return false; + } + } + + alert( adminBarL10n.noShortlink ); + return false; + } + }, + + addEvent(w, 'load', function() { + var b = d.getElementsByTagName('body')[0], + s = d.getElementById('adminbar-search'); + + aB = d.getElementById('wpadminbar'); + + if ( b && aB ) { + b.appendChild( aB ); + + addEvent(aB, 'mouseover', function(e) { + addClass( e.target || e.srcElement ); + }); + + addEvent(aB, 'mouseout', function(e) { + removeClass( e.target || e.srcElement ); + }); + + addEvent(aB, 'click', clickShortlink ); + } + + if ( s ) { + if ( '' == s.value ) + s.value = s.getAttribute('title'); + + s.onblur = function() { + this.value = '' == this.value ? this.getAttribute('title') : this.value; + } + s.onfocus = function() { + this.value = this.getAttribute('title') == this.value ? '' : this.value; + } + } + + if ( w.location.hash ) + w.scrollBy(0,-32); + }); +})(document, window); diff --git a/wp-includes/js/admin-bar.js b/wp-includes/js/admin-bar.js new file mode 100644 index 0000000000..81fa4f7a1c --- /dev/null +++ b/wp-includes/js/admin-bar.js @@ -0,0 +1 @@ +(function(h,i){var b=function(l,k,d){if(l.addEventListener){l.addEventListener(k,d,false)}else{if(l.attachEvent){l.attachEvent("on"+k,function(){return d.call(l,window.event)})}}},c,e=new RegExp("\\bhover\\b","g"),a=[],f=function(k){var d=a.length;while(d--){if(a[d]&&k==a[d][1]){return a[d][0]}}return false},g=function(d){while(d&&d!=c&&d!=h){if("LI"==d.nodeName.toUpperCase()){var k=f(d);if(k){clearTimeout(k)}d.className=d.className?(d.className.replace(e,"")+" hover"):"hover"}d=d.parentNode}},j=function(d){while(d&&d!=c&&d!=h){if("LI"==d.nodeName.toUpperCase()){(function(k){var l=setTimeout(function(){k.className=k.className?k.className.replace(e,""):""},500);a[a.length]=[l,k]})(d)}d=d.parentNode}};clickShortlink=function(m){var l=m.target||m.srcElement,d,k;if("undefined"==typeof adminBarL10n){return}while(l&&l!=c&&l!=h&&(!l.className||-1==l.className.indexOf("ab-get-shortlink"))){l=l.parentNode}if(l&&l.className&&-1!=l.className.indexOf("ab-get-shortlink")){d=h.getElementsByTagName("link");if(!d.length){d=h.links}k=d.length;if(m.preventDefault){m.preventDefault()}m.returnValue=false;while(k--){if(d[k]&&"shortlink"==d[k].getAttribute("rel")){prompt(adminBarL10n.url,d[k].href);return false}}alert(adminBarL10n.noShortlink);return false}},b(i,"load",function(){var d=h.getElementsByTagName("body")[0],k=h.getElementById("adminbar-search");c=h.getElementById("wpadminbar");if(d&&c){d.appendChild(c);b(c,"mouseover",function(l){g(l.target||l.srcElement)});b(c,"mouseout",function(l){j(l.target||l.srcElement)});b(c,"click",clickShortlink)}if(k){if(""==k.value){k.value=k.getAttribute("title")}k.onblur=function(){this.value=""==this.value?this.getAttribute("title"):this.value};k.onfocus=function(){this.value=this.getAttribute("title")==this.value?"":this.value}}if(i.location.hash){i.scrollBy(0,-32)}})})(document,window);
\ No newline at end of file |