X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/99a64b9fd0d5ebb21c33c3a0b5865e9c412b430c..5aa86a9053fb0fa15846bb60aac2fb8fdfff524a:/wp-includes/js/admin-bar.dev.js diff --git a/wp-includes/js/admin-bar.dev.js b/wp-includes/js/admin-bar.dev.js index cf13ca72..57f4a854 100644 --- a/wp-includes/js/admin-bar.dev.js +++ b/wp-includes/js/admin-bar.dev.js @@ -1,140 +1,209 @@ -(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 = [], - rselected = new RegExp('\\bselected\\b', 'g'), - - /** - * 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; - }, - - addHoverClass = function(t) { - var i, id, inA, hovering, ul, li, - ancestors = [], - ancestorLength = 0; - - 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; - } - - // 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, '' ) : ''; +// 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)) .ab-item').bind('keydown.adminbar', function(e){ + if ( e.which != 13 ) + return; + + var target = $(e.target), wrap = target.closest('ab-sub-wrapper'); + + e.stopPropagation(); + e.preventDefault(); + + if ( !wrap.length ) + wrap = $('#wpadminbar .quicklinks'); + + wrap.find('.menupop').removeClass('hover'); + target.parent().toggleClass('hover'); + target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh); + }).each(refresh); + + $('#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); + }); + + }); +} 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);}); + }, + + aB, hc = new RegExp('\\bhover\\b', 'g'), q = [], + rselected = new RegExp('\\bselected\\b', 'g'), + + /** + * 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; + }, + + addHoverClass = function(t) { + var i, id, inA, hovering, ul, li, + ancestors = [], + ancestorLength = 0; + + 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; } - } - - /* 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; + + // 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, '' ) : ''; + } + } } - if ( ! inA ) - q[i][1].className = q[i][1].className ? q[i][1].className.replace(hc, '') : ''; - } - }, - - 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); + /* 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; + } + + if ( ! inA ) + q[i][1].className = q[i][1].className ? q[i][1].className.replace(hc, '') : ''; } - t = t.parentNode; - } - }, - - clickShortlink = function(e) { - var i, l, node, - t = e.target || e.srcElement; - - // 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; - } - - // IE doesn't support preventDefault, and does support returnValue - 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; + }, + + 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; + } + }, + + clickShortlink = function(e) { + var i, l, node, + t = e.target || e.srcElement; + + // 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; } - } - return false; - }; - addEvent(w, 'load', function() { - aB = d.getElementById('wpadminbar'); + // IE doesn't support preventDefault, and does support returnValue + 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; + } + } + return false; + }; - if ( d.body && aB ) { - d.body.appendChild( aB ); + addEvent(w, 'load', function() { + aB = d.getElementById('wpadminbar'); - addEvent(aB, 'mouseover', function(e) { - addHoverClass( e.target || e.srcElement ); - }); + if ( d.body && aB ) { + d.body.appendChild( aB ); - addEvent(aB, 'mouseout', function(e) { - removeHoverClass( e.target || e.srcElement ); - }); + if ( aB.className ) + aB.className = aB.className.replace(/nojs/, ''); - addEvent(aB, 'click', clickShortlink ); - } + addEvent(aB, 'mouseover', function(e) { + addHoverClass( e.target || e.srcElement ); + }); + + addEvent(aB, 'mouseout', function(e) { + removeHoverClass( e.target || e.srcElement ); + }); + + addEvent(aB, 'click', clickShortlink ); + } + + if ( w.location.hash ) + w.scrollBy(0,-32); + }); + })(document, window); + +} - if ( w.location.hash ) - w.scrollBy(0,-32); - }); -})(document, window);