1 // use jQuery and hoverIntent if loaded
2 if ( typeof(jQuery) != 'undefined' ) {
3 if ( typeof(jQuery.fn.hoverIntent) == 'undefined' )
4 (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))<m.sensitivity){a(f).unbind("mousemove",e);f.hoverIntent_s=1;return m.over.apply(f,[g])}else{h=o;d=n;f.hoverIntent_t=setTimeout(function(){c(g,f)},m.interval)}};var i=function(g,f){f.hoverIntent_t=clearTimeout(f.hoverIntent_t);f.hoverIntent_s=0;return m.out.apply(f,[g])};var b=function(q){var f=this;var g=(q.type=="mouseover"?q.fromElement:q.toElement)||q.relatedTarget;while(g&&g!=this){try{g=g.parentNode}catch(q){g=this}}if(g==this){if(a.browser.mozilla){if(q.type=="mouseout"){f.mtout=setTimeout(function(){k(q,f)},30)}else{if(f.mtout){f.mtout=clearTimeout(f.mtout)}}}return}else{if(f.mtout){f.mtout=clearTimeout(f.mtout)}k(q,f)}};var k=function(p,f){var g=jQuery.extend({},p);if(f.hoverIntent_t){f.hoverIntent_t=clearTimeout(f.hoverIntent_t)}if(p.type=="mouseover"){h=g.pageX;d=g.pageY;a(f).bind("mousemove",e);if(f.hoverIntent_s!=1){f.hoverIntent_t=setTimeout(function(){c(g,f)},m.interval)}}else{a(f).unbind("mousemove",e);if(f.hoverIntent_s==1){f.hoverIntent_t=setTimeout(function(){i(g,f)},m.timeout)}}};return this.mouseover(b).mouseout(b)}})(jQuery);
6 jQuery(document).ready(function($){
7 var refresh = function(i, el){ // force the browser to refresh the tabbing index
8 var node = $(el), tab = node.attr('tabindex');
10 node.attr('tabindex', '0').attr('tabindex', tab);
13 $('#wpadminbar').removeClass('nojq').removeClass('nojs').find('li.menupop').hoverIntent({
15 $(this).addClass('hover');
18 $(this).removeClass('hover');
25 $('#wp-admin-bar-get-shortlink').click(function(e){
27 $(this).addClass('selected').children('.shortlink-input').blur(function(){
28 $(this).parents('#wp-admin-bar-get-shortlink').removeClass('selected');
32 $('#wpadminbar li.menupop > .ab-item').bind('keydown.adminbar', function(e){
36 var target = $(e.target), wrap = target.closest('ab-sub-wrapper');
42 wrap = $('#wpadminbar .quicklinks');
44 wrap.find('.menupop').removeClass('hover');
45 target.parent().toggleClass('hover');
46 target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh);
49 $('#wpadminbar .ab-item').bind('keydown.adminbar', function(e){
53 var target = $(e.target);
58 target.closest('.hover').removeClass('hover').children('.ab-item').focus();
59 target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh);
65 var addEvent = function( obj, type, fn ) {
66 if (obj.addEventListener)
67 obj.addEventListener(type, fn, false);
68 else if (obj.attachEvent)
69 obj.attachEvent('on' + type, function() { return fn.call(obj, window.event);});
72 aB, hc = new RegExp('\\bhover\\b', 'g'), q = [],
73 rselected = new RegExp('\\bselected\\b', 'g'),
76 * Get the timeout ID of the given element
78 getTOID = function(el) {
81 if ( q[i] && el == q[i][1] )
86 addHoverClass = function(t) {
87 var i, id, inA, hovering, ul, li,
91 while ( t && t != aB && t != d ) {
92 if( 'LI' == t.nodeName.toUpperCase() ) {
93 ancestors[ ancestors.length ] = t;
97 t.className = t.className ? ( t.className.replace(hc, '') + ' hover' ) : 'hover';
103 // Remove any selected classes.
104 if ( hovering && hovering.parentNode ) {
105 ul = hovering.parentNode;
106 if ( ul && 'UL' == ul.nodeName.toUpperCase() ) {
107 i = ul.childNodes.length;
109 li = ul.childNodes[i];
110 if ( li != hovering )
111 li.className = li.className ? li.className.replace( rselected, '' ) : '';
116 /* remove the hover class for any objects not in the immediate element's ancestry */
120 ancestorLength = ancestors.length;
121 while( ancestorLength-- ) {
122 if ( ancestors[ ancestorLength ] == q[i][1] )
127 q[i][1].className = q[i][1].className ? q[i][1].className.replace(hc, '') : '';
131 removeHoverClass = function(t) {
132 while ( t && t != aB && t != d ) {
133 if( 'LI' == t.nodeName.toUpperCase() ) {
135 var to = setTimeout(function() {
136 t.className = t.className ? t.className.replace(hc, '') : '';
138 q[q.length] = [to, t];
145 clickShortlink = function(e) {
147 t = e.target || e.srcElement;
149 // Make t the shortlink menu item, or return.
151 // Check if we've gone past the shortlink node,
152 // or if the user is clicking on the input.
153 if ( ! t || t == d || t == aB )
155 // Check if we've found the shortlink node.
156 if ( t.id && t.id == 'wp-admin-bar-get-shortlink' )
161 // IE doesn't support preventDefault, and does support returnValue
162 if ( e.preventDefault )
164 e.returnValue = false;
166 if ( -1 == t.className.indexOf('selected') )
167 t.className += ' selected';
169 for ( i = 0, l = t.childNodes.length; i < l; i++ ) {
170 node = t.childNodes[i];
171 if ( node.className && -1 != node.className.indexOf('shortlink-input') ) {
174 node.onblur = function() {
175 t.className = t.className ? t.className.replace( rselected, '' ) : '';
183 addEvent(w, 'load', function() {
184 aB = d.getElementById('wpadminbar');
186 if ( d.body && aB ) {
187 d.body.appendChild( aB );
190 aB.className = aB.className.replace(/nojs/, '');
192 addEvent(aB, 'mouseover', function(e) {
193 addHoverClass( e.target || e.srcElement );
196 addEvent(aB, 'mouseout', function(e) {
197 removeHoverClass( e.target || e.srcElement );
200 addEvent(aB, 'click', clickShortlink );
203 if ( w.location.hash )
206 })(document, window);