2018-06-27 22:30:15 -04:00
|
|
|
/**
|
|
|
|
* @output wp-includes/js/admin-bar.js
|
|
|
|
*/
|
|
|
|
|
2013-11-14 00:51:10 -05:00
|
|
|
/* jshint loopfunc: true */
|
2012-08-22 20:04:18 -04:00
|
|
|
// use jQuery and hoverIntent if loaded
|
|
|
|
if ( typeof(jQuery) != 'undefined' ) {
|
2013-02-28 13:05:28 -05:00
|
|
|
if ( typeof(jQuery.fn.hoverIntent) == 'undefined' ) {
|
2013-11-14 00:51:10 -05:00
|
|
|
/* jshint ignore:start */
|
2015-03-11 13:15:27 -04:00
|
|
|
// hoverIntent v1.8.1 - Copy of wp-includes/js/hoverIntent.min.js
|
|
|
|
!function(a){a.fn.hoverIntent=function(b,c,d){var e={interval:100,sensitivity:6,timeout:0};e="object"==typeof b?a.extend(e,b):a.isFunction(c)?a.extend(e,{over:b,out:c,selector:d}):a.extend(e,{over:b,out:b,selector:c});var f,g,h,i,j=function(a){f=a.pageX,g=a.pageY},k=function(b,c){return c.hoverIntent_t=clearTimeout(c.hoverIntent_t),Math.sqrt((h-f)*(h-f)+(i-g)*(i-g))<e.sensitivity?(a(c).off("mousemove.hoverIntent",j),c.hoverIntent_s=!0,e.over.apply(c,[b])):(h=f,i=g,c.hoverIntent_t=setTimeout(function(){k(b,c)},e.interval),void 0)},l=function(a,b){return b.hoverIntent_t=clearTimeout(b.hoverIntent_t),b.hoverIntent_s=!1,e.out.apply(b,[a])},m=function(b){var c=a.extend({},b),d=this;d.hoverIntent_t&&(d.hoverIntent_t=clearTimeout(d.hoverIntent_t)),"mouseenter"===b.type?(h=c.pageX,i=c.pageY,a(d).on("mousemove.hoverIntent",j),d.hoverIntent_s||(d.hoverIntent_t=setTimeout(function(){k(c,d)},e.interval))):(a(d).off("mousemove.hoverIntent",j),d.hoverIntent_s&&(d.hoverIntent_t=setTimeout(function(){l(c,d)},e.timeout)))};return this.on({"mouseenter.hoverIntent":m,"mouseleave.hoverIntent":m},e.selector)}}(jQuery);
|
2013-11-14 00:51:10 -05:00
|
|
|
/* jshint ignore:end */
|
2013-02-28 13:05:28 -05:00
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
jQuery(document).ready(function($){
|
2012-11-17 15:14:17 -05:00
|
|
|
var adminbar = $('#wpadminbar'), refresh, touchOpen, touchClose, disableHoverIntent = false;
|
2012-10-19 14:31:21 -04:00
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Forces the browser to refresh the tabbing index.
|
|
|
|
*
|
|
|
|
* @since 3.3.0
|
|
|
|
*
|
|
|
|
* @param {number} i The index of the HTML element to remove the tab index
|
|
|
|
* from. This parameter is necessary because we use this
|
|
|
|
* function in .each calls.
|
|
|
|
* @param {HTMLElement} el The HTML element to remove the tab index from.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
|
|
|
refresh = function(i, el){
|
2012-08-22 20:04:18 -04:00
|
|
|
var node = $(el), tab = node.attr('tabindex');
|
|
|
|
if ( tab )
|
|
|
|
node.attr('tabindex', '0').attr('tabindex', tab);
|
|
|
|
};
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Adds or removes the hover class on touch.
|
|
|
|
*
|
|
|
|
* @since 3.5.0
|
|
|
|
*
|
|
|
|
* @param {boolean} unbind If true removes the wp-mobile-hover class.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2012-11-17 15:14:17 -05:00
|
|
|
touchOpen = function(unbind) {
|
2012-10-19 14:31:21 -04:00
|
|
|
adminbar.find('li.menupop').on('click.wp-mobile-hover', function(e) {
|
|
|
|
var el = $(this);
|
|
|
|
|
2013-12-06 00:28:11 -05:00
|
|
|
if ( el.parent().is('#wp-admin-bar-root-default') && !el.hasClass('hover') ) {
|
2012-10-19 14:31:21 -04:00
|
|
|
e.preventDefault();
|
|
|
|
adminbar.find('li.menupop.hover').removeClass('hover');
|
|
|
|
el.addClass('hover');
|
2013-12-06 00:28:11 -05:00
|
|
|
} else if ( !el.hasClass('hover') ) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
el.addClass('hover');
|
2015-07-02 23:29:25 -04:00
|
|
|
} else if ( ! $( e.target ).closest( 'div' ).hasClass( 'ab-sub-wrapper' ) ) {
|
|
|
|
// We're dealing with an already-touch-opened menu genericon (we know el.hasClass('hover')),
|
|
|
|
// so close it on a second tap and prevent propag and defaults. See #29906
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
el.removeClass('hover');
|
2012-10-19 14:31:21 -04:00
|
|
|
}
|
2012-11-17 15:14:17 -05:00
|
|
|
|
|
|
|
if ( unbind ) {
|
|
|
|
$('li.menupop').off('click.wp-mobile-hover');
|
|
|
|
disableHoverIntent = false;
|
|
|
|
}
|
2012-10-19 14:31:21 -04:00
|
|
|
});
|
2012-11-17 15:14:17 -05:00
|
|
|
};
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Removes the hover class if clicked or touched outside the admin bar.
|
|
|
|
*
|
|
|
|
* @since 3.5.0
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2012-11-17 15:14:17 -05:00
|
|
|
touchClose = function() {
|
|
|
|
var mobileEvent = /Mobile\/.+Safari/.test(navigator.userAgent) ? 'touchstart' : 'click';
|
|
|
|
// close any open drop-downs when the click/touch is not on the toolbar
|
|
|
|
$(document.body).on( mobileEvent+'.wp-mobile-hover', function(e) {
|
|
|
|
if ( !$(e.target).closest('#wpadminbar').length )
|
|
|
|
adminbar.find('li.menupop.hover').removeClass('hover');
|
2012-10-19 14:31:21 -04:00
|
|
|
});
|
2012-11-17 15:14:17 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
adminbar.removeClass('nojq').removeClass('nojs');
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
// If clicked on the adminbar add the hoverclass, if clicked outside it remove
|
|
|
|
// it.
|
2012-11-17 15:14:17 -05:00
|
|
|
if ( 'ontouchstart' in window ) {
|
|
|
|
adminbar.on('touchstart', function(){
|
|
|
|
touchOpen(true);
|
|
|
|
disableHoverIntent = true;
|
|
|
|
});
|
|
|
|
touchClose();
|
|
|
|
} else if ( /IEMobile\/[1-9]/.test(navigator.userAgent) ) {
|
|
|
|
touchOpen();
|
|
|
|
touchClose();
|
2012-10-19 14:31:21 -04:00
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
// Adds or removes the hover class based on the hover intent.
|
2012-11-17 15:14:17 -05:00
|
|
|
adminbar.find('li.menupop').hoverIntent({
|
2013-11-14 00:51:10 -05:00
|
|
|
over: function() {
|
2012-11-17 15:14:17 -05:00
|
|
|
if ( disableHoverIntent )
|
|
|
|
return;
|
|
|
|
|
|
|
|
$(this).addClass('hover');
|
|
|
|
},
|
2013-11-14 00:51:10 -05:00
|
|
|
out: function() {
|
2012-11-17 15:14:17 -05:00
|
|
|
if ( disableHoverIntent )
|
|
|
|
return;
|
|
|
|
|
|
|
|
$(this).removeClass('hover');
|
|
|
|
},
|
|
|
|
timeout: 180,
|
|
|
|
sensitivity: 7,
|
|
|
|
interval: 100
|
|
|
|
});
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
// Prevents the toolbar from covering up content when a hash is present in the
|
|
|
|
// URL.
|
2012-11-20 15:45:03 -05:00
|
|
|
if ( window.location.hash )
|
|
|
|
window.scrollBy( 0, -32 );
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Handles the selected state of the Shortlink link.
|
|
|
|
*
|
|
|
|
* When the input is visible the link should be selected, when the input is
|
|
|
|
* unfocused the link should be unselected.
|
|
|
|
*
|
|
|
|
* @param {Object} e The click event.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
**/
|
2012-08-22 20:04:18 -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();
|
|
|
|
});
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Removes the hoverclass if the enter key is pressed.
|
|
|
|
*
|
|
|
|
* Makes sure the tab index is refreshed by refreshing each ab-item
|
|
|
|
* and its children.
|
|
|
|
*
|
|
|
|
* @param {Object} e The keydown event.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2012-08-22 20:04:18 -04:00
|
|
|
$('#wpadminbar li.menupop > .ab-item').bind('keydown.adminbar', function(e){
|
2018-06-27 22:23:53 -04:00
|
|
|
// Key code 13 is the enter key.
|
2012-08-22 20:04:18 -04:00
|
|
|
if ( e.which != 13 )
|
|
|
|
return;
|
|
|
|
|
2015-01-09 04:51:22 -05:00
|
|
|
var target = $(e.target),
|
|
|
|
wrap = target.closest('.ab-sub-wrapper'),
|
|
|
|
parentHasHover = target.parent().hasClass('hover');
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
if ( !wrap.length )
|
|
|
|
wrap = $('#wpadminbar .quicklinks');
|
|
|
|
|
|
|
|
wrap.find('.menupop').removeClass('hover');
|
2015-01-09 04:51:22 -05:00
|
|
|
|
|
|
|
if ( ! parentHasHover ) {
|
|
|
|
target.parent().toggleClass('hover');
|
|
|
|
}
|
|
|
|
|
2012-08-22 20:04:18 -04:00
|
|
|
target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh);
|
|
|
|
}).each(refresh);
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Removes the hover class when the escape key is pressed.
|
|
|
|
*
|
|
|
|
* Makes sure the tab index is refreshed by refreshing each ab-item
|
|
|
|
* and its children.
|
|
|
|
*
|
|
|
|
* @param {Object} e The keydown event.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2012-08-22 20:04:18 -04:00
|
|
|
$('#wpadminbar .ab-item').bind('keydown.adminbar', function(e){
|
2018-06-27 22:23:53 -04:00
|
|
|
// Key code 27 is the escape key.
|
2012-08-22 20:04:18 -04:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Scrolls to top of page by clicking the adminbar.
|
|
|
|
*
|
|
|
|
* @param {Object} e The click event.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2015-07-20 16:02:24 -04:00
|
|
|
adminbar.click( function(e) {
|
2015-07-02 23:29:25 -04:00
|
|
|
if ( e.target.id != 'wpadminbar' && e.target.id != 'wp-admin-bar-top-secondary' ) {
|
2012-08-22 20:04:18 -04:00
|
|
|
return;
|
2015-07-02 23:29:25 -04:00
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2015-07-20 16:02:24 -04:00
|
|
|
adminbar.find( 'li.menupop.hover' ).removeClass( 'hover' );
|
|
|
|
$( 'html, body' ).animate( { scrollTop: 0 }, 'fast' );
|
2012-08-22 20:04:18 -04:00
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Sets the focus on an element with a href attribute.
|
|
|
|
*
|
|
|
|
* The timeout is used to fix a focus bug in WebKit.
|
|
|
|
*
|
|
|
|
* @param {Object} e The keydown event.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2012-10-16 17:26:59 -04:00
|
|
|
$('.screen-reader-shortcut').keydown( function(e) {
|
2013-11-14 00:51:10 -05:00
|
|
|
var id, ua;
|
|
|
|
|
2012-10-16 17:26:59 -04:00
|
|
|
if ( 13 != e.which )
|
|
|
|
return;
|
|
|
|
|
2013-11-14 00:51:10 -05:00
|
|
|
id = $( this ).attr( 'href' );
|
|
|
|
|
|
|
|
ua = navigator.userAgent.toLowerCase();
|
2012-10-16 17:26:59 -04:00
|
|
|
|
2013-02-28 13:05:28 -05:00
|
|
|
if ( ua.indexOf('applewebkit') != -1 && id && id.charAt(0) == '#' ) {
|
2012-10-16 17:26:59 -04:00
|
|
|
setTimeout(function () {
|
|
|
|
$(id).focus();
|
|
|
|
}, 100);
|
|
|
|
}
|
|
|
|
});
|
2013-03-13 06:08:16 -04:00
|
|
|
|
2015-04-08 12:08:28 -04:00
|
|
|
$( '#adminbar-search' ).on({
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Adds the adminbar-focused class on focus.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2015-04-08 12:08:28 -04:00
|
|
|
focus: function() {
|
|
|
|
$( '#adminbarsearch' ).addClass( 'adminbar-focused' );
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Removes the adminbar-focused class on blur.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2015-04-08 12:08:28 -04:00
|
|
|
}, blur: function() {
|
|
|
|
$( '#adminbarsearch' ).removeClass( 'adminbar-focused' );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2013-03-13 06:08:16 -04:00
|
|
|
if ( 'sessionStorage' in window ) {
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Empties sessionStorage on logging out.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2013-03-13 06:08:16 -04:00
|
|
|
$('#wp-admin-bar-logout a').click( function() {
|
|
|
|
try {
|
|
|
|
for ( var key in sessionStorage ) {
|
|
|
|
if ( key.indexOf('wp-autosave-') != -1 )
|
|
|
|
sessionStorage.removeItem(key);
|
|
|
|
}
|
|
|
|
} catch(e) {}
|
|
|
|
});
|
|
|
|
}
|
2013-12-08 21:41:10 -05:00
|
|
|
|
|
|
|
if ( navigator.userAgent && document.body.className.indexOf( 'no-font-face' ) === -1 &&
|
|
|
|
/Android (1.0|1.1|1.5|1.6|2.0|2.1)|Nokia|Opera Mini|w(eb)?OSBrowser|webOS|UCWEB|Windows Phone OS 7|XBLWP7|ZuneWP7|MSIE 7/.test( navigator.userAgent ) ) {
|
|
|
|
|
|
|
|
document.body.className += ' no-font-face';
|
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
});
|
|
|
|
} else {
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Wrapper function for the adminbar that's used if jQuery isn't available.
|
|
|
|
*
|
|
|
|
* @param {Object} d The document object.
|
|
|
|
* @param {Object} w The window object.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2012-08-22 20:04:18 -04:00
|
|
|
(function(d, w) {
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Adds an event listener to an object.
|
|
|
|
*
|
|
|
|
* @since 3.1.0
|
|
|
|
*
|
|
|
|
* @param {Object} obj The object to add the event listener to.
|
|
|
|
* @param {string} type The type of event.
|
|
|
|
* @param {function} fn The function to bind to the event listener.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2012-08-22 20:04:18 -04:00
|
|
|
var addEvent = function( obj, type, fn ) {
|
2018-08-06 15:33:28 -04:00
|
|
|
if ( obj && typeof obj.addEventListener === 'function' ) {
|
2018-07-19 18:00:25 -04:00
|
|
|
obj.addEventListener( type, fn, false );
|
2018-08-06 15:33:28 -04:00
|
|
|
} else if ( obj && typeof obj.attachEvent === 'function' ) {
|
2018-07-19 18:00:25 -04:00
|
|
|
obj.attachEvent( 'on' + type, function() {
|
|
|
|
return fn.call( obj, window.event );
|
|
|
|
} );
|
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
aB, hc = new RegExp('\\bhover\\b', 'g'), q = [],
|
|
|
|
rselected = new RegExp('\\bselected\\b', 'g'),
|
|
|
|
|
|
|
|
/**
|
2018-06-27 22:23:53 -04:00
|
|
|
* Gets the timeout ID of the given element.
|
|
|
|
*
|
|
|
|
* @since 3.1.0
|
|
|
|
*
|
|
|
|
* @param {HTMLElement} el The HTML element.
|
|
|
|
*
|
|
|
|
* @return {number|boolean} The ID value of the timer that is set or false.
|
2012-08-22 20:04:18 -04:00
|
|
|
*/
|
|
|
|
getTOID = function(el) {
|
|
|
|
var i = q.length;
|
2012-10-19 14:31:21 -04:00
|
|
|
while ( i-- ) {
|
2012-08-22 20:04:18 -04:00
|
|
|
if ( q[i] && el == q[i][1] )
|
|
|
|
return q[i][0];
|
2012-10-19 14:31:21 -04:00
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Adds the hoverclass to menu items.
|
|
|
|
*
|
|
|
|
* @since 3.1.0
|
|
|
|
*
|
|
|
|
* @param {HTMLElement} t The HTML element.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2012-08-22 20:04:18 -04:00
|
|
|
addHoverClass = function(t) {
|
|
|
|
var i, id, inA, hovering, ul, li,
|
|
|
|
ancestors = [],
|
|
|
|
ancestorLength = 0;
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
// aB is adminbar. d is document.
|
2012-08-22 20:04:18 -04:00
|
|
|
while ( t && t != aB && t != d ) {
|
2012-10-19 14:31:21 -04:00
|
|
|
if ( 'LI' == t.nodeName.toUpperCase() ) {
|
2012-08-22 20:04:18 -04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
// Removes any selected classes.
|
2012-08-22 20:04:18 -04:00
|
|
|
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, '' ) : '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
// Removes the hover class for any objects not in the immediate element's ancestry.
|
2012-08-22 20:04:18 -04:00
|
|
|
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, '') : '';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Removes the hoverclass from menu items.
|
|
|
|
*
|
|
|
|
* @since 3.1.0
|
|
|
|
*
|
|
|
|
* @param {HTMLElement} t The HTML element.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2012-08-22 20:04:18 -04:00
|
|
|
removeHoverClass = function(t) {
|
|
|
|
while ( t && t != aB && t != d ) {
|
2012-10-19 14:31:21 -04:00
|
|
|
if ( 'LI' == t.nodeName.toUpperCase() ) {
|
2012-08-22 20:04:18 -04:00
|
|
|
(function(t) {
|
|
|
|
var to = setTimeout(function() {
|
|
|
|
t.className = t.className ? t.className.replace(hc, '') : '';
|
|
|
|
}, 500);
|
|
|
|
q[q.length] = [to, t];
|
|
|
|
})(t);
|
|
|
|
}
|
|
|
|
t = t.parentNode;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Handles the click on the Shortlink link in the adminbar.
|
|
|
|
*
|
|
|
|
* @since 3.1.0
|
|
|
|
*
|
2018-06-27 22:27:38 -04:00
|
|
|
* @param {Object} e The click event.
|
2018-06-27 22:23:53 -04:00
|
|
|
*
|
|
|
|
* @return {boolean} Returns false to prevent default click behavior.
|
|
|
|
*/
|
2012-08-22 20:04:18 -04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2018-06-27 22:23:53 -04:00
|
|
|
/**
|
|
|
|
* Scrolls to the top of the page.
|
|
|
|
*
|
|
|
|
* @since 3.4.0
|
|
|
|
*
|
|
|
|
* @param {HTMLElement} t The HTML element.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
2012-08-22 20:04:18 -04:00
|
|
|
scrollToTop = function(t) {
|
|
|
|
var distance, speed, step, steps, timer, speed_step;
|
|
|
|
|
|
|
|
// Ensure that the #wpadminbar was the target of the click.
|
|
|
|
if ( t.id != 'wpadminbar' && t.id != 'wp-admin-bar-top-secondary' )
|
|
|
|
return;
|
|
|
|
|
|
|
|
distance = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
|
|
|
|
|
|
if ( distance < 1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
speed_step = distance > 800 ? 130 : 100;
|
|
|
|
speed = Math.min( 12, Math.round( distance / speed_step ) );
|
|
|
|
step = distance > 800 ? Math.round( distance / 30 ) : Math.round( distance / 20 );
|
|
|
|
steps = [];
|
|
|
|
timer = 0;
|
|
|
|
|
|
|
|
// Animate scrolling to the top of the page by generating steps to
|
|
|
|
// the top of the page and shifting to each step at a set interval.
|
|
|
|
while ( distance ) {
|
|
|
|
distance -= step;
|
|
|
|
if ( distance < 0 )
|
|
|
|
distance = 0;
|
|
|
|
steps.push( distance );
|
|
|
|
|
|
|
|
setTimeout( function() {
|
|
|
|
window.scrollTo( 0, steps.shift() );
|
|
|
|
}, timer * speed );
|
|
|
|
|
|
|
|
timer++;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
addEvent(w, 'load', function() {
|
|
|
|
aB = d.getElementById('wpadminbar');
|
|
|
|
|
|
|
|
if ( d.body && aB ) {
|
|
|
|
d.body.appendChild( aB );
|
|
|
|
|
|
|
|
if ( aB.className )
|
|
|
|
aB.className = aB.className.replace(/nojs/, '');
|
|
|
|
|
|
|
|
addEvent(aB, 'mouseover', function(e) {
|
|
|
|
addHoverClass( e.target || e.srcElement );
|
|
|
|
});
|
|
|
|
|
|
|
|
addEvent(aB, 'mouseout', function(e) {
|
|
|
|
removeHoverClass( e.target || e.srcElement );
|
|
|
|
});
|
|
|
|
|
|
|
|
addEvent(aB, 'click', clickShortlink );
|
|
|
|
|
|
|
|
addEvent(aB, 'click', function(e) {
|
|
|
|
scrollToTop( e.target || e.srcElement );
|
|
|
|
});
|
2013-03-13 06:08:16 -04:00
|
|
|
|
|
|
|
addEvent( document.getElementById('wp-admin-bar-logout'), 'click', function() {
|
|
|
|
if ( 'sessionStorage' in window ) {
|
|
|
|
try {
|
|
|
|
for ( var key in sessionStorage ) {
|
|
|
|
if ( key.indexOf('wp-autosave-') != -1 )
|
|
|
|
sessionStorage.removeItem(key);
|
|
|
|
}
|
|
|
|
} catch(e) {}
|
|
|
|
}
|
|
|
|
});
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( w.location.hash )
|
|
|
|
w.scrollBy(0,-32);
|
2013-12-08 21:41:10 -05:00
|
|
|
|
|
|
|
if ( navigator.userAgent && document.body.className.indexOf( 'no-font-face' ) === -1 &&
|
|
|
|
/Android (1.0|1.1|1.5|1.6|2.0|2.1)|Nokia|Opera Mini|w(eb)?OSBrowser|webOS|UCWEB|Windows Phone OS 7|XBLWP7|ZuneWP7|MSIE 7/.test( navigator.userAgent ) ) {
|
|
|
|
|
|
|
|
document.body.className += ' no-font-face';
|
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
});
|
|
|
|
})(document, window);
|
|
|
|
|
|
|
|
}
|