2010-10-29 09:25:58 +02:00
|
|
|
(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 = [],
|
2011-01-11 23:45:14 +01:00
|
|
|
rselected = new RegExp('\\bselected\\b', 'g'),
|
2010-10-29 09:25:58 +02:00
|
|
|
|
2010-11-10 17:19:55 +01:00
|
|
|
/**
|
|
|
|
* Get the timeout ID of the given element
|
|
|
|
*/
|
2010-10-29 09:25:58 +02:00
|
|
|
getTOID = function(el) {
|
|
|
|
var i = q.length;
|
|
|
|
while( i-- )
|
|
|
|
if ( q[i] && el == q[i][1] )
|
|
|
|
return q[i][0];
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2011-01-11 23:45:14 +01:00
|
|
|
addHoverClass = function(t) {
|
|
|
|
var i, id, inA, hovering, ul, li,
|
|
|
|
ancestors = [],
|
|
|
|
ancestorLength = 0;
|
|
|
|
|
2010-10-29 09:25:58 +02:00
|
|
|
while ( t && t != aB && t != d ) {
|
|
|
|
if( 'LI' == t.nodeName.toUpperCase() ) {
|
2010-11-10 17:19:55 +01:00
|
|
|
ancestors[ ancestors.length ] = t;
|
2010-12-10 19:47:21 +01:00
|
|
|
id = getTOID(t);
|
2010-10-29 09:25:58 +02:00
|
|
|
if ( id )
|
|
|
|
clearTimeout( id );
|
|
|
|
t.className = t.className ? ( t.className.replace(hc, '') + ' hover' ) : 'hover';
|
2011-01-11 23:45:14 +01:00
|
|
|
hovering = t;
|
2010-10-29 09:25:58 +02:00
|
|
|
}
|
|
|
|
t = t.parentNode;
|
|
|
|
}
|
2010-12-10 19:47:21 +01:00
|
|
|
|
2011-01-11 23:45:14 +01:00
|
|
|
// Remove any selected classes.
|
|
|
|
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, '' ) : '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-10 17:19:55 +01:00
|
|
|
/* remove the hover class for any objects not in the immediate element's ancestry */
|
2011-01-11 23:45:14 +01:00
|
|
|
i = q.length;
|
2010-11-10 17:19:55 +01:00
|
|
|
while ( i-- ) {
|
|
|
|
inA = false;
|
|
|
|
ancestorLength = ancestors.length;
|
|
|
|
while( ancestorLength-- ) {
|
|
|
|
if ( ancestors[ ancestorLength ] == q[i][1] )
|
|
|
|
inA = true;
|
|
|
|
}
|
2010-12-10 19:47:21 +01:00
|
|
|
|
|
|
|
if ( ! inA )
|
2010-11-10 17:19:55 +01:00
|
|
|
q[i][1].className = q[i][1].className ? q[i][1].className.replace(hc, '') : '';
|
|
|
|
}
|
2010-10-29 09:25:58 +02:00
|
|
|
},
|
|
|
|
|
2011-01-11 23:45:14 +01:00
|
|
|
removeHoverClass = function(t) {
|
2010-10-29 09:25:58 +02:00
|
|
|
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 15:27:52 +02:00
|
|
|
},
|
2010-10-29 09:25:58 +02:00
|
|
|
|
|
|
|
clickShortlink = function(e) {
|
2011-01-11 23:45:14 +01:00
|
|
|
var i, l, node, className,
|
|
|
|
t = e.target || e.srcElement,
|
|
|
|
shortlink = t.href;
|
|
|
|
|
|
|
|
// 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 || -1 != t.className.indexOf('shortlink-input') )
|
|
|
|
return;
|
|
|
|
// Check if we've found the shortlink node.
|
|
|
|
if ( t.className && -1 != t.className.indexOf('ab-get-shortlink') )
|
|
|
|
break;
|
2010-10-29 09:25:58 +02:00
|
|
|
t = t.parentNode;
|
2011-01-11 23:45:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( e.preventDefault )
|
|
|
|
e.preventDefault();
|
|
|
|
e.returnValue = false;
|
|
|
|
|
|
|
|
if ( -1 == t.className.indexOf('selected') )
|
|
|
|
t.className += ' selected';
|
|
|
|
|
|
|
|
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;
|
2010-10-29 09:25:58 +02:00
|
|
|
}
|
|
|
|
}
|
2011-01-11 23:45:14 +01:00
|
|
|
return false;
|
|
|
|
};
|
2010-10-29 09:25:58 +02:00
|
|
|
|
|
|
|
addEvent(w, 'load', function() {
|
|
|
|
aB = d.getElementById('wpadminbar');
|
|
|
|
|
2011-01-11 23:45:14 +01:00
|
|
|
if ( d.body && aB ) {
|
|
|
|
d.body.appendChild( aB );
|
2010-10-29 09:25:58 +02:00
|
|
|
|
|
|
|
addEvent(aB, 'mouseover', function(e) {
|
2011-01-11 23:45:14 +01:00
|
|
|
addHoverClass( e.target || e.srcElement );
|
2010-10-29 09:25:58 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
addEvent(aB, 'mouseout', function(e) {
|
2011-01-11 23:45:14 +01:00
|
|
|
removeHoverClass( e.target || e.srcElement );
|
2010-10-29 09:25:58 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
addEvent(aB, 'click', clickShortlink );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( w.location.hash )
|
|
|
|
w.scrollBy(0,-32);
|
|
|
|
});
|
|
|
|
})(document, window);
|