2011-07-29 18:57:30 -04:00
|
|
|
// use jQuery and hoverIntent if loaded
|
|
|
|
if ( typeof(jQuery) != 'undefined' ) {
|
|
|
|
if ( typeof(jQuery.fn.hoverIntent) == '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))<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);
|
|
|
|
|
|
|
|
jQuery(document).ready(function($){
|
2011-11-27 19:31:11 -05:00
|
|
|
var 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);
|
|
|
|
};
|
|
|
|
|
2011-09-25 19:30:40 -04:00
|
|
|
$('#wpadminbar').removeClass('nojq').removeClass('nojs').find('li.menupop').hoverIntent({
|
2011-07-29 18:57:30 -04:00
|
|
|
over: function(e){
|
|
|
|
$(this).addClass('hover');
|
|
|
|
},
|
|
|
|
out: function(e){
|
|
|
|
$(this).removeClass('hover');
|
|
|
|
},
|
2011-09-30 18:31:15 -04:00
|
|
|
timeout: 180,
|
2011-07-29 18:57:30 -04:00
|
|
|
sensitivity: 7,
|
2011-09-30 18:31:15 -04:00
|
|
|
interval: 100
|
2011-07-29 18:57:30 -04:00
|
|
|
});
|
2011-08-01 19:33:56 -04:00
|
|
|
|
|
|
|
$('#wp-admin-bar-get-shortlink').click(function(e){
|
|
|
|
e.preventDefault();
|
|
|
|
$(this).addClass('selected').children('.shortlink-input').blur(function(){
|
|
|
|
$(this).parents('#wp-admin-bar-get-shortlink').removeClass('selected');
|
|
|
|
}).focus().select();
|
|
|
|
});
|
2011-11-04 21:13:18 -04:00
|
|
|
|
2011-11-27 19:31:11 -05:00
|
|
|
$('#wpadminbar li.menupop > .ab-item').bind('keydown.adminbar', function(e){
|
|
|
|
if ( e.which != 13 )
|
|
|
|
return;
|
2011-11-04 21:13:18 -04:00
|
|
|
|
2011-11-30 20:07:43 -05:00
|
|
|
var target = $(e.target), wrap = target.closest('ab-sub-wrapper');
|
2011-11-04 21:13:18 -04:00
|
|
|
|
2011-11-27 19:31:11 -05:00
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
2011-11-23 16:29:33 -05:00
|
|
|
|
2011-11-30 20:07:43 -05:00
|
|
|
if ( !wrap.length )
|
|
|
|
wrap = $('#wpadminbar .quicklinks');
|
|
|
|
|
|
|
|
wrap.find('.menupop').removeClass('hover');
|
|
|
|
target.parent().toggleClass('hover');
|
2011-11-27 19:31:11 -05:00
|
|
|
target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh);
|
|
|
|
}).each(refresh);
|
2011-11-07 15:38:38 -05:00
|
|
|
|
2011-11-29 20:21:38 -05:00
|
|
|
$('#wpadminbar .ab-item').bind('keydown.adminbar', function(e){
|
|
|
|
if ( e.which != 27 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
var target = $(e.target);
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
target.closest('.hover').removeClass('hover').children('.ab-item').focus();
|
|
|
|
target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh);
|
|
|
|
});
|
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
(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);});
|
|
|
|
},
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
aB, hc = new RegExp('\\bhover\\b', 'g'), q = [],
|
|
|
|
rselected = new RegExp('\\bselected\\b', 'g'),
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
/**
|
|
|
|
* Get the timeout ID of the given element
|
|
|
|
*/
|
|
|
|
getTOID = function(el) {
|
|
|
|
var i = q.length;
|
|
|
|
while( i-- )
|
|
|
|
if ( q[i] && el == q[i][1] )
|
|
|
|
return q[i][0];
|
|
|
|
return false;
|
|
|
|
},
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
addHoverClass = function(t) {
|
|
|
|
var i, id, inA, hovering, ul, li,
|
|
|
|
ancestors = [],
|
|
|
|
ancestorLength = 0;
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
while ( t && t != aB && t != d ) {
|
|
|
|
if( 'LI' == t.nodeName.toUpperCase() ) {
|
|
|
|
ancestors[ ancestors.length ] = t;
|
|
|
|
id = getTOID(t);
|
|
|
|
if ( id )
|
|
|
|
clearTimeout( id );
|
|
|
|
t.className = t.className ? ( t.className.replace(hc, '') + ' hover' ) : 'hover';
|
|
|
|
hovering = t;
|
|
|
|
}
|
|
|
|
t = t.parentNode;
|
2010-10-29 03:25:58 -04:00
|
|
|
}
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
// Remove any selected classes.
|
|
|
|
if ( hovering && hovering.parentNode ) {
|
|
|
|
ul = hovering.parentNode;
|
|
|
|
if ( ul && 'UL' == ul.nodeName.toUpperCase() ) {
|
|
|
|
i = ul.childNodes.length;
|
|
|
|
while ( i-- ) {
|
|
|
|
li = ul.childNodes[i];
|
|
|
|
if ( li != hovering )
|
|
|
|
li.className = li.className ? li.className.replace( rselected, '' ) : '';
|
|
|
|
}
|
2011-01-11 19:32:00 -05:00
|
|
|
}
|
2011-01-11 17:45:14 -05:00
|
|
|
}
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
/* remove the hover class for any objects not in the immediate element's ancestry */
|
|
|
|
i = q.length;
|
|
|
|
while ( i-- ) {
|
|
|
|
inA = false;
|
|
|
|
ancestorLength = ancestors.length;
|
|
|
|
while( ancestorLength-- ) {
|
|
|
|
if ( ancestors[ ancestorLength ] == q[i][1] )
|
|
|
|
inA = true;
|
|
|
|
}
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
if ( ! inA )
|
|
|
|
q[i][1].className = q[i][1].className ? q[i][1].className.replace(hc, '') : '';
|
2010-11-10 11:19:55 -05:00
|
|
|
}
|
2011-07-29 18:57:30 -04:00
|
|
|
},
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
removeHoverClass = 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;
|
2010-10-29 03:25:58 -04:00
|
|
|
}
|
2011-07-29 18:57:30 -04:00
|
|
|
},
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
clickShortlink = function(e) {
|
|
|
|
var i, l, node,
|
|
|
|
t = e.target || e.srcElement;
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
// Make t the shortlink menu item, or return.
|
|
|
|
while ( true ) {
|
|
|
|
// Check if we've gone past the shortlink node,
|
|
|
|
// or if the user is clicking on the input.
|
|
|
|
if ( ! t || t == d || t == aB )
|
|
|
|
return;
|
|
|
|
// Check if we've found the shortlink node.
|
|
|
|
if ( t.id && t.id == 'wp-admin-bar-get-shortlink' )
|
|
|
|
break;
|
|
|
|
t = t.parentNode;
|
2010-10-29 03:25:58 -04:00
|
|
|
}
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
// IE doesn't support preventDefault, and does support returnValue
|
|
|
|
if ( e.preventDefault )
|
|
|
|
e.preventDefault();
|
|
|
|
e.returnValue = false;
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
if ( -1 == t.className.indexOf('selected') )
|
|
|
|
t.className += ' selected';
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
for ( i = 0, l = t.childNodes.length; i < l; i++ ) {
|
|
|
|
node = t.childNodes[i];
|
|
|
|
if ( node.className && -1 != node.className.indexOf('shortlink-input') ) {
|
|
|
|
node.focus();
|
|
|
|
node.select();
|
|
|
|
node.onblur = function() {
|
|
|
|
t.className = t.className ? t.className.replace( rselected, '' ) : '';
|
|
|
|
};
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
addEvent(w, 'load', function() {
|
|
|
|
aB = d.getElementById('wpadminbar');
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
if ( d.body && aB ) {
|
|
|
|
d.body.appendChild( aB );
|
2011-09-25 19:30:40 -04:00
|
|
|
|
|
|
|
if ( aB.className )
|
|
|
|
aB.className = aB.className.replace(/nojs/, '');
|
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
addEvent(aB, 'mouseover', function(e) {
|
|
|
|
addHoverClass( e.target || e.srcElement );
|
|
|
|
});
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
addEvent(aB, 'mouseout', function(e) {
|
|
|
|
removeHoverClass( e.target || e.srcElement );
|
|
|
|
});
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
addEvent(aB, 'click', clickShortlink );
|
|
|
|
}
|
2011-09-25 19:30:40 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
if ( w.location.hash )
|
|
|
|
w.scrollBy(0,-32);
|
|
|
|
});
|
|
|
|
})(document, window);
|
2010-10-29 03:25:58 -04:00
|
|
|
|
2011-07-29 18:57:30 -04:00
|
|
|
}
|
2010-10-29 03:25:58 -04:00
|
|
|
|