Ticket #47069: 47069.11.diff
File 47069.11.diff, 32.4 KB (added by , 5 years ago) |
---|
-
Gruntfile.js
162 162 [ WORKING_DIR + 'wp-includes/js/backbone.js' ]: [ './node_modules/backbone/backbone.js' ], 163 163 [ WORKING_DIR + 'wp-includes/js/clipboard.js' ]: [ './node_modules/clipboard/dist/clipboard.js' ], 164 164 [ WORKING_DIR + 'wp-includes/js/hoverIntent.js' ]: [ './node_modules/jquery-hoverintent/jquery.hoverIntent.js' ], 165 166 // Renamed to avoid conflict with jQuery hoverIntent.min.js (after minifying) 167 [ WORKING_DIR + 'wp-includes/js/hoverintent-js.min.js' ]: [ './node_modules/hoverintent/dist/hoverintent.min.js' ], 165 168 [ WORKING_DIR + 'wp-includes/js/imagesloaded.min.js' ]: [ './node_modules/imagesloaded/imagesloaded.pkgd.min.js' ], 166 169 [ WORKING_DIR + 'wp-includes/js/jquery/jquery-migrate.js' ]: [ './node_modules/jquery-migrate/dist/jquery-migrate.js' ], 167 170 [ WORKING_DIR + 'wp-includes/js/jquery/jquery-migrate.min.js' ]: [ './node_modules/jquery-migrate/dist/jquery-migrate.min.js' ], -
package-lock.json
13217 13217 "jquery": ">=1.7" 13218 13218 } 13219 13219 }, 13220 "hoverintent": { 13221 "version": "2.2.1", 13222 "resolved": "https://registry.npmjs.org/hoverintent/-/hoverintent-2.2.1.tgz", 13223 "integrity": "sha512-VyU54L1xW5rSqpsv/LJ6ecymGXsXXeGs9iVEKot4kKBCq5UodSAuy3DqX686LZxEpaMEfeCHPu4LndsMX5Q9eQ==" 13224 }, 13220 13225 "jquery-hoverintent": { 13221 13226 "version": "1.8.3", 13222 13227 "resolved": "https://registry.npmjs.org/jquery-hoverintent/-/jquery-hoverintent-1.8.3.tgz", -
package.json
122 122 "jquery-form": "4.2.1", 123 123 "jquery-hoverintent": "1.8.3", 124 124 "jquery-ui": "https://github.com/jquery/jquery-ui/archive/1.11.4.tar.gz", 125 "hoverintent": "2.2.1", 125 126 "lodash": "4.17.15", 126 127 "masonry-layout": "3.3.2", 127 128 "moment": "2.22.2", -
src/js/_enqueues/admin/common.js
652 652 } 653 653 654 654 if ( ! isIOS && ! isAndroid ) { 655 $adminmenu.find( 'li.wp-has-submenu' ).hoverIntent({ 655 $adminmenu.find( 'li.wp-has-submenu' ).each( function( i, el ) { 656 hoverintent( 657 el, 658 /** 659 * Opens the submenu when hovered over the menu item for desktops. 660 * 661 * @returns {void} 662 */ 663 function() { 664 var $menuItem = $( this ), 665 $submenu = $menuItem.find( '.wp-submenu' ), 666 top = parseInt( $submenu.css( 'top' ), 10 ); 656 667 657 /** 658 * Opens the submenu when hovered over the menu item for desktops. 659 * 660 * @return {void} 661 */ 662 over: function() { 663 var $menuItem = $( this ), 664 $submenu = $menuItem.find( '.wp-submenu' ), 665 top = parseInt( $submenu.css( 'top' ), 10 ); 666 667 if ( isNaN( top ) || top > -5 ) { // the submenu is visible 668 return; 669 } 668 if ( isNaN( top ) || top > -5 ) { // the submenu is visible 669 return; 670 } 670 671 671 if ( $adminmenu.data( 'wp-responsive' ) ) {672 // The menu is in responsive mode, bail673 return;674 }672 if ( $adminmenu.data( 'wp-responsive' ) ) { 673 // The menu is in responsive mode, bail 674 return; 675 } 675 676 676 adjustSubmenu( $menuItem ); 677 $adminmenu.find( 'li.opensub' ).removeClass( 'opensub' ); 678 $menuItem.addClass( 'opensub' ); 679 }, 677 adjustSubmenu( $menuItem ); 678 $adminmenu.find( 'li.opensub' ).removeClass( 'opensub' ); 679 $menuItem.addClass( 'opensub' ); 680 }, 681 /** 682 * Closes the submenu when no longer hovering the menu item. 683 * 684 * @returns {void} 685 */ 686 function() { 687 if ( $adminmenu.data( 'wp-responsive' ) ) { 688 // The menu is in responsive mode, bail 689 return; 690 } 680 691 681 /** 682 * Closes the submenu when no longer hovering the menu item. 683 * 684 * @return {void} 685 */ 686 out: function(){ 687 if ( $adminmenu.data( 'wp-responsive' ) ) { 688 // The menu is in responsive mode, bail 689 return; 692 $( this ).removeClass( 'opensub' ).find( '.wp-submenu' ).css( 'margin-top', '' ); 690 693 } 691 692 $( this ).removeClass( 'opensub' ).find( '.wp-submenu' ).css( 'margin-top', '' ); 693 }, 694 timeout: 200, 695 sensitivity: 7, 696 interval: 90 697 }); 694 ).options( { 695 timeout: 200, 696 sensitivity: 7, 697 interval: 90 698 } ); 699 } ); 698 700 699 701 /** 700 702 * Opens the submenu on when focused on the menu item. -
src/js/_enqueues/lib/admin-bar.js
1 1 /** 2 2 * @output wp-includes/js/admin-bar.js 3 3 */ 4 5 /* jshint loopfunc: true */ 6 // use jQuery and hoverIntent if loaded 7 if ( typeof(jQuery) != 'undefined' ) { 8 if ( typeof(jQuery.fn.hoverIntent) == 'undefined' ) { 9 /* jshint ignore:start */ 10 // hoverIntent v1.8.1 - Copy of wp-includes/js/hoverIntent.min.js 11 !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); 12 /* jshint ignore:end */ 13 } 14 jQuery(document).ready(function($){ 15 var adminbar = $('#wpadminbar'), refresh, touchOpen, touchClose, disableHoverIntent = false; 4 /** 5 * Admin bar with Vanilla JS, no external dependencies. 6 * 7 * @param {Object} document The document object. 8 * @param {Object} window The window object. 9 * @param {Object} navigator The navigator object. 10 * 11 * @return {void} 12 */ 13 ( function( document, window, navigator ) { 14 document.addEventListener( 'DOMContentLoaded', function() { 15 var adminBar = document.getElementById( 'wpadminbar' ), 16 topMenuItems = adminBar.querySelectorAll( 'li.menupop' ), 17 allMenuItems = adminBar.querySelectorAll( '.ab-item' ), 18 adminBarLogout = document.getElementById( 'wp-admin-bar-logout' ), 19 adminBarSearchForm = document.getElementById( 'adminbarsearch' ), 20 shortlink = document.getElementById( 'wp-admin-bar-get-shortlink' ), 21 skipLink = adminBar.querySelector( '.screen-reader-shortcut' ), 22 mobileEvent = /Mobile\/.+Safari/.test( navigator.userAgent ) ? 'touchstart' : 'click', 23 adminBarSearchInput, 24 i; 16 25 17 26 /** 18 * Forces the browser to refresh the tabbing index. 19 * 20 * @since 3.3.0 21 * 22 * @param {number} i The index of the HTML element to remove the tab index 23 * from. This parameter is necessary because we use this 24 * function in .each calls. 25 * @param {HTMLElement} el The HTML element to remove the tab index from. 26 * 27 * @return {void} 27 * Remove nojs class after the DOM is loaded. 28 28 */ 29 refresh = function(i, el){ 30 var node = $(el), tab = node.attr('tabindex'); 31 if ( tab ) 32 node.attr('tabindex', '0').attr('tabindex', tab); 33 }; 29 adminBar.classList.remove( 'nojs' ); 34 30 35 /** 36 * Adds or removes the hover class on touch. 37 * 38 * @since 3.5.0 39 * 40 * @param {boolean} unbind If true removes the wp-mobile-hover class. 41 * 42 * @return {void} 43 */ 44 touchOpen = function(unbind) { 45 adminbar.find('li.menupop').on('click.wp-mobile-hover', function(e) { 46 var el = $(this); 47 48 if ( el.parent().is('#wp-admin-bar-root-default') && !el.hasClass('hover') ) { 49 e.preventDefault(); 50 adminbar.find('li.menupop.hover').removeClass('hover'); 51 el.addClass('hover'); 52 } else if ( !el.hasClass('hover') ) { 53 e.stopPropagation(); 54 e.preventDefault(); 55 el.addClass('hover'); 56 } else if ( ! $( e.target ).closest( 'div' ).hasClass( 'ab-sub-wrapper' ) ) { 57 // We're dealing with an already-touch-opened menu genericon (we know el.hasClass('hover')), 58 // so close it on a second tap and prevent propag and defaults. See #29906 59 e.stopPropagation(); 60 e.preventDefault(); 61 el.removeClass('hover'); 31 if ( 'ontouchstart' in window ) { 32 /** 33 * Remove hover class when the user touches outside the menu items. 34 */ 35 document.body.addEventListener( mobileEvent, function( e ) { 36 if ( ! getClosest( e.target, 'li.menupop' ) ) { 37 removeAllHoverClass( topMenuItems ); 62 38 } 39 } ); 63 40 64 if ( unbind ) { 65 $('li.menupop').off('click.wp-mobile-hover'); 66 disableHoverIntent = false; 41 /** 42 * Add listener for menu items to toggle hover class by touches. 43 * Remove the callback later for better performance. 44 */ 45 adminBar.addEventListener( 'touchstart', function bindMobileEvents() { 46 for ( var i = 0; i < topMenuItems.length; i++ ) { 47 topMenuItems[i].addEventListener( 'click', mobileHover.bind( null, topMenuItems ) ); 67 48 } 68 }); 69 }; 49 50 adminBar.removeEventListener( 'touchstart', bindMobileEvents ); 51 } ); 52 } 70 53 71 54 /** 72 * Removes the hover class if clicked or touched outside the admin bar. 73 * 74 * @since 3.5.0 75 * 76 * @return {void} 55 * Scroll page to top when clicking on the admin bar. 77 56 */ 78 touchClose = function() { 79 var mobileEvent = /Mobile\/.+Safari/.test(navigator.userAgent) ? 'touchstart' : 'click'; 80 // close any open drop-downs when the click/touch is not on the toolbar 81 $(document.body).on( mobileEvent+'.wp-mobile-hover', function(e) { 82 if ( !$(e.target).closest('#wpadminbar').length ) 83 adminbar.find('li.menupop.hover').removeClass('hover'); 84 }); 85 }; 86 87 adminbar.removeClass('nojq').removeClass('nojs'); 57 adminBar.addEventListener( 'click', scrollToTop ); 88 58 89 // If clicked on the adminbar add the hoverclass, if clicked outside it remove 90 // it. 91 if ( 'ontouchstart' in window ) { 92 adminbar.on('touchstart', function(){ 93 touchOpen(true); 94 disableHoverIntent = true; 95 }); 96 touchClose(); 97 } else if ( /IEMobile\/[1-9]/.test(navigator.userAgent) ) { 98 touchOpen(); 99 touchClose(); 100 } 101 102 // Adds or removes the hover class based on the hover intent. 103 adminbar.find('li.menupop').hoverIntent({ 104 over: function() { 105 if ( disableHoverIntent ) 106 return; 107 108 $(this).addClass('hover'); 109 }, 110 out: function() { 111 if ( disableHoverIntent ) 112 return; 113 114 $(this).removeClass('hover'); 115 }, 116 timeout: 180, 117 sensitivity: 7, 118 interval: 100 119 }); 120 121 // Prevents the toolbar from covering up content when a hash is present in the 122 // URL. 123 if ( window.location.hash ) 124 window.scrollBy( 0, -32 ); 59 for ( i = 0; i < topMenuItems.length; i++ ) { 60 /** 61 * Adds or removes the hover class based on the hover intent. 62 */ 63 hoverintent( 64 topMenuItems[i], 65 addHoverClass.bind( null, topMenuItems[i] ), 66 removeHoverClass.bind( null, topMenuItems[i] ) 67 ).options( { 68 timeout: 180, 69 } ); 125 70 126 /** 127 * Handles the selected state of the Shortlink link. 128 * 129 * When the input is visible the link should be selected, when the input is 130 * unfocused the link should be unselected. 131 * 132 * @param {Object} e The click event. 133 * 134 * @return {void} 135 **/ 136 $('#wp-admin-bar-get-shortlink').click(function(e){ 137 e.preventDefault(); 138 $(this).addClass('selected').children('.shortlink-input').blur(function(){ 139 $(this).parents('#wp-admin-bar-get-shortlink').removeClass('selected'); 140 }).focus().select(); 141 }); 71 /** 72 * Toggle hover class if the enter key is pressed. 73 */ 74 topMenuItems[i].addEventListener( 'keydown', toggleHoverIfEnter ); 75 } 142 76 143 77 /** 144 * Removes the hoverclass if the enter key is pressed. 145 * 146 * Makes sure the tab index is refreshed by refreshing each ab-item 147 * and its children. 148 * 149 * @param {Object} e The keydown event. 150 * 151 * @return {void} 78 * Remove hover class if the escape key is pressed. 152 79 */ 153 $('#wpadminbar li.menupop > .ab-item').bind('keydown.adminbar', function(e){ 154 // Key code 13 is the enter key. 155 if ( e.which != 13 ) 156 return; 157 158 var target = $(e.target), 159 wrap = target.closest('.ab-sub-wrapper'), 160 parentHasHover = target.parent().hasClass('hover'); 161 162 e.stopPropagation(); 163 e.preventDefault(); 164 165 if ( !wrap.length ) 166 wrap = $('#wpadminbar .quicklinks'); 80 for ( i = 0; i < allMenuItems.length; i++ ) { 81 allMenuItems[i].addEventListener( 'keydown', removeHoverIfEscape ); 82 } 167 83 168 wrap.find('.menupop').removeClass('hover'); 84 if ( adminBarSearchForm ) { 85 adminBarSearchInput = document.getElementById( 'adminbar-search' ); 169 86 170 if ( ! parentHasHover ) { 171 target.parent().toggleClass('hover'); 172 } 87 /** 88 * Adds the adminbar-focused class on focus. 89 */ 90 adminBarSearchInput.addEventListener( 'focus', function() { 91 adminBarSearchForm.classList.add( 'adminbar-focused' ); 92 } ); 173 93 174 target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh); 175 }).each(refresh); 94 /** 95 * Removes the adminbar-focused class on blur. 96 */ 97 adminBarSearchInput.addEventListener( 'blur', function() { 98 adminBarSearchForm.classList.remove( 'adminbar-focused' ); 99 } ); 100 } 176 101 177 102 /** 178 * Removes the hover class when the escape key is pressed. 179 * 180 * Makes sure the tab index is refreshed by refreshing each ab-item 181 * and its children. 182 * 183 * @param {Object} e The keydown event. 184 * 185 * @return {void} 103 * Focus the target of skip link after pressing Enter. 186 104 */ 187 $('#wpadminbar .ab-item').bind('keydown.adminbar', function(e){ 188 // Key code 27 is the escape key. 189 if ( e.which != 27 ) 190 return; 191 192 var target = $(e.target); 193 194 e.stopPropagation(); 195 e.preventDefault(); 105 skipLink.addEventListener( 'keydown', focusTargetAfterEnter ); 196 106 197 target.closest('.hover').removeClass('hover').children('.ab-item').focus();198 target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh);199 } );107 if ( shortlink ) { 108 shortlink.addEventListener( 'click', clickShortlink ); 109 } 200 110 201 111 /** 202 * Scrolls to top of page by clicking the adminbar. 203 * 204 * @param {Object} e The click event. 205 * 206 * @return {void} 112 * Prevents the toolbar from covering up content when a hash is present 113 * in the URL. 207 114 */ 208 adminbar.click( function(e) { 209 if ( e.target.id != 'wpadminbar' && e.target.id != 'wp-admin-bar-top-secondary' ) { 210 return; 211 } 115 if ( window.location.hash ) { 116 window.scrollBy( 0, -32 ); 117 } 212 118 213 adminbar.find( 'li.menupop.hover' ).removeClass( 'hover' ); 214 $( 'html, body' ).animate( { scrollTop: 0 }, 'fast' ); 215 e.preventDefault(); 216 }); 119 /** 120 * Add no-font-face class to body if needed. 121 */ 122 if ( navigator.userAgent && document.body.className.indexOf( 'no-font-face' ) === -1 && 123 /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 ) ) { 124 document.body.className += ' no-font-face'; 125 } 217 126 218 127 /** 219 * Sets the focus on an element with a href attribute. 220 * 221 * The timeout is used to fix a focus bug in WebKit. 222 * 223 * @param {Object} e The keydown event. 224 * 225 * @return {void} 128 * Clear sessionStorage on logging out. 226 129 */ 227 $('.screen-reader-shortcut').keydown( function(e) {228 var id, ua;130 adminBarLogout.addEventListener( 'click', emptySessionStorage ); 131 } ); 229 132 230 if ( 13 != e.which ) 231 return; 133 /** 134 * Remove hover class for top level menu item when escape is pressed. 135 * 136 * @since 5.3.0 137 * 138 * @param {Event} e The keydown event. 139 */ 140 function removeHoverIfEscape( e ) { 141 var wrapper; 232 142 233 id = $( this ).attr( 'href' ); 143 if ( e.which != 27 ) { 144 return; 145 } 234 146 235 ua = navigator.userAgent.toLowerCase();147 wrapper = getClosest( e.target, '.menupop' ); 236 148 237 if ( ua.indexOf('applewebkit') != -1 && id && id.charAt(0) == '#' ) { 238 setTimeout(function () { 239 $(id).focus(); 240 }, 100); 241 } 242 }); 149 if ( ! wrapper ) { 150 return; 151 } 243 152 244 $( '#adminbar-search' ).on({ 245 /** 246 * Adds the adminbar-focused class on focus. 247 * 248 * @return {void} 249 */ 250 focus: function() { 251 $( '#adminbarsearch' ).addClass( 'adminbar-focused' ); 252 /** 253 * Removes the adminbar-focused class on blur. 254 * 255 * @return {void} 256 */ 257 }, blur: function() { 258 $( '#adminbarsearch' ).removeClass( 'adminbar-focused' ); 259 } 260 } ); 153 wrapper.querySelector( '.menupop > .ab-item' ).focus(); 154 removeHoverClass( wrapper ); 155 } 261 156 262 if ( 'sessionStorage' in window ) { 263 /** 264 * Empties sessionStorage on logging out. 265 * 266 * @return {void} 267 */ 268 $('#wp-admin-bar-logout a').click( function() { 269 try { 270 for ( var key in sessionStorage ) { 271 if ( key.indexOf('wp-autosave-') != -1 ) 272 sessionStorage.removeItem(key); 273 } 274 } catch(e) {} 275 }); 157 /** 158 * Toggle hover class for top level menu item when enter is pressed. 159 * 160 * @since 5.3.0 161 * 162 * @param {Event} e The keydown event. 163 */ 164 function toggleHoverIfEnter( e ) { 165 var wrapper; 166 167 if ( e.which != 13 ) { 168 return; 276 169 } 277 170 278 if ( navigator.userAgent && document.body.className.indexOf( 'no-font-face' ) === -1 && 279 /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 ) ) { 171 if ( !! getClosest( e.target, '.ab-sub-wrapper' ) ) { 172 return; 173 } 280 174 281 document.body.className += ' no-font-face'; 175 wrapper = getClosest( e.target, '.menupop' ); 176 177 if ( ! wrapper ) { 178 return; 179 } 180 181 e.preventDefault(); 182 if ( hasHoverClass( wrapper ) ) { 183 removeHoverClass( wrapper ); 184 } else { 185 addHoverClass( wrapper ); 282 186 } 283 } );284 } else { 187 } 188 285 189 /** 286 * Wrapper function for the adminbar that's used if jQuery isn't available.190 * Focus the target of skip link after pressing Enter. 287 191 * 288 * @param {Object} d The document object. 289 * @param {Object} w The window object. 192 * @since 5.3.0 290 193 * 291 * @ return {void}194 * @param {Event} e The keydown event. 292 195 */ 293 (function(d, w) { 294 /** 295 * Adds an event listener to an object. 296 * 297 * @since 3.1.0 298 * 299 * @param {Object} obj The object to add the event listener to. 300 * @param {string} type The type of event. 301 * @param {function} fn The function to bind to the event listener. 302 * 303 * @return {void} 304 */ 305 var addEvent = function( obj, type, fn ) { 306 if ( obj && typeof obj.addEventListener === 'function' ) { 307 obj.addEventListener( type, fn, false ); 308 } else if ( obj && typeof obj.attachEvent === 'function' ) { 309 obj.attachEvent( 'on' + type, function() { 310 return fn.call( obj, window.event ); 311 } ); 312 } 313 }, 196 function focusTargetAfterEnter( e ) { 197 var id, userAgent; 314 198 315 aB, hc = new RegExp('\\bhover\\b', 'g'), q = [], 316 rselected = new RegExp('\\bselected\\b', 'g'), 199 if ( 13 !== e.which ) { 200 return; 201 } 317 202 318 /** 319 * Gets the timeout ID of the given element. 320 * 321 * @since 3.1.0 322 * 323 * @param {HTMLElement} el The HTML element. 324 * 325 * @return {number|boolean} The ID value of the timer that is set or false. 326 */ 327 getTOID = function(el) { 328 var i = q.length; 329 while ( i-- ) { 330 if ( q[i] && el == q[i][1] ) 331 return q[i][0]; 332 } 333 return false; 334 }, 203 id = e.target.getAttribute( 'href' ); 204 userAgent = navigator.userAgent.toLowerCase(); 335 205 336 /** 337 * Adds the hoverclass to menu items. 338 * 339 * @since 3.1.0 340 * 341 * @param {HTMLElement} t The HTML element. 342 * 343 * @return {void} 344 */ 345 addHoverClass = function(t) { 346 var i, id, inA, hovering, ul, li, 347 ancestors = [], 348 ancestorLength = 0; 349 350 // aB is adminbar. d is document. 351 while ( t && t != aB && t != d ) { 352 if ( 'LI' == t.nodeName.toUpperCase() ) { 353 ancestors[ ancestors.length ] = t; 354 id = getTOID(t); 355 if ( id ) 356 clearTimeout( id ); 357 t.className = t.className ? ( t.className.replace(hc, '') + ' hover' ) : 'hover'; 358 hovering = t; 359 } 360 t = t.parentNode; 361 } 206 if ( userAgent.indexOf( 'applewebkit' ) != -1 && id && id.charAt( 0 ) == '#' ) { 207 setTimeout( function() { 208 var target = document.getElementById( id.replace( '#', '' ) ); 209 210 target.setAttribute( 'tabIndex', '0' ); 211 target.focus(); 212 }, 100 ); 213 } 214 } 362 215 363 // Removes any selected classes. 364 if ( hovering && hovering.parentNode ) { 365 ul = hovering.parentNode; 366 if ( ul && 'UL' == ul.nodeName.toUpperCase() ) { 367 i = ul.childNodes.length; 368 while ( i-- ) { 369 li = ul.childNodes[i]; 370 if ( li != hovering ) 371 li.className = li.className ? li.className.replace( rselected, '' ) : ''; 372 } 373 } 374 } 216 /** 217 * Toogle hover class for mobile devices. 218 * 219 * @since 5.3.0 220 * 221 * @param {NodeList} topMenuItems All menu items. 222 * @param {Event} e The click event. 223 */ 224 function mobileHover( topMenuItems, e ) { 225 var wrapper; 375 226 376 // Removes the hover class for any objects not in the immediate element's ancestry. 377 i = q.length; 378 while ( i-- ) { 379 inA = false; 380 ancestorLength = ancestors.length; 381 while( ancestorLength-- ) { 382 if ( ancestors[ ancestorLength ] == q[i][1] ) 383 inA = true; 384 } 227 if ( !! getClosest( e.target, '.ab-sub-wrapper' ) ) { 228 return; 229 } 385 230 386 if ( ! inA ) 387 q[i][1].className = q[i][1].className ? q[i][1].className.replace(hc, '') : ''; 388 } 389 }, 231 e.preventDefault(); 390 232 391 /** 392 * Removes the hoverclass from menu items. 393 * 394 * @since 3.1.0 395 * 396 * @param {HTMLElement} t The HTML element. 397 * 398 * @return {void} 399 */ 400 removeHoverClass = function(t) { 401 while ( t && t != aB && t != d ) { 402 if ( 'LI' == t.nodeName.toUpperCase() ) { 403 (function(t) { 404 var to = setTimeout(function() { 405 t.className = t.className ? t.className.replace(hc, '') : ''; 406 }, 500); 407 q[q.length] = [to, t]; 408 })(t); 409 } 410 t = t.parentNode; 411 } 412 }, 233 wrapper = getClosest( e.target, '.menupop' ); 413 234 414 /** 415 * Handles the click on the Shortlink link in the adminbar. 416 * 417 * @since 3.1.0 418 * 419 * @param {Object} e The click event. 420 * 421 * @return {boolean} Returns false to prevent default click behavior. 422 */ 423 clickShortlink = function(e) { 424 var i, l, node, 425 t = e.target || e.srcElement; 426 427 // Make t the shortlink menu item, or return. 428 while ( true ) { 429 // Check if we've gone past the shortlink node, 430 // or if the user is clicking on the input. 431 if ( ! t || t == d || t == aB ) 432 return; 433 // Check if we've found the shortlink node. 434 if ( t.id && t.id == 'wp-admin-bar-get-shortlink' ) 435 break; 436 t = t.parentNode; 437 } 235 if ( ! wrapper ) { 236 return; 237 } 438 238 439 // IE doesn't support preventDefault, and does support returnValue 440 if ( e.preventDefault ) 441 e.preventDefault(); 442 e.returnValue = false; 443 444 if ( -1 == t.className.indexOf('selected') ) 445 t.className += ' selected'; 446 447 for ( i = 0, l = t.childNodes.length; i < l; i++ ) { 448 node = t.childNodes[i]; 449 if ( node.className && -1 != node.className.indexOf('shortlink-input') ) { 450 node.focus(); 451 node.select(); 452 node.onblur = function() { 453 t.className = t.className ? t.className.replace( rselected, '' ) : ''; 454 }; 455 break; 456 } 457 } 458 return false; 459 }, 239 if ( hasHoverClass( wrapper ) ) { 240 removeHoverClass( wrapper ); 241 } else { 242 removeAllHoverClass( topMenuItems ); 243 addHoverClass( wrapper ); 244 } 245 } 460 246 461 /** 462 * Scrolls to the top of the page. 463 * 464 * @since 3.4.0 465 * 466 * @param {HTMLElement} t The HTML element. 467 * 468 * @return {void} 469 */ 470 scrollToTop = function(t) { 471 var distance, speed, step, steps, timer, speed_step; 247 /** 248 * Handles the click on the Shortlink link in the adminbar. 249 * 250 * @since 3.1.0 251 * @since 5.3.0 Use querySelector to clean up the function. 252 * 253 * @param {Event} e The click event. 254 * 255 * @return {boolean} Returns false to prevent default click behavior. 256 */ 257 function clickShortlink( e ) { 258 var wrapper = e.target.parentNode, 259 input = wrapper.querySelector( '.shortlink-input' ); 472 260 473 // Ensure that the #wpadminbar was the target of the click. 474 if ( t.id != 'wpadminbar' && t.id != 'wp-admin-bar-top-secondary' ) 475 return; 476 477 distance = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0; 478 479 if ( distance < 1 ) 480 return; 481 482 speed_step = distance > 800 ? 130 : 100; 483 speed = Math.min( 12, Math.round( distance / speed_step ) ); 484 step = distance > 800 ? Math.round( distance / 30 ) : Math.round( distance / 20 ); 485 steps = []; 486 timer = 0; 487 488 // Animate scrolling to the top of the page by generating steps to 489 // the top of the page and shifting to each step at a set interval. 490 while ( distance ) { 491 distance -= step; 492 if ( distance < 0 ) 493 distance = 0; 494 steps.push( distance ); 495 496 setTimeout( function() { 497 window.scrollTo( 0, steps.shift() ); 498 }, timer * speed ); 261 // IE doesn't support preventDefault, and does support returnValue 262 if ( e.preventDefault ) { 263 e.preventDefault(); 264 } 265 e.returnValue = false; 499 266 500 timer++; 501 } 267 wrapper.classList.add( 'selected' ); 268 input.focus(); 269 input.select(); 270 input.onblur = function() { 271 wrapper.classList.remove( 'selected' ); 502 272 }; 503 273 504 addEvent(w, 'load', function() { 505 aB = d.getElementById('wpadminbar'); 274 return false; 275 } 276 277 /** 278 * Clear sessionStorage on logging out. 279 * 280 * @since 5.3.0 281 */ 282 function emptySessionStorage() { 283 if ( 'sessionStorage' in window ) { 284 try { 285 for ( var key in sessionStorage ) { 286 if ( key.indexOf( 'wp-autosave-' ) != -1 ) { 287 sessionStorage.removeItem( key ); 288 } 289 } 290 } catch ( e ) {} 291 } 292 } 293 294 /** 295 * Check if menu item has hover class. 296 * 297 * @since 5.3.0 298 * 299 * @param {HTMLElement} item Menu item Element. 300 */ 301 function hasHoverClass( item ) { 302 return item.classList.contains( 'hover' ); 303 } 506 304 507 if ( d.body && aB ) { 508 d.body.appendChild( aB ); 305 /** 306 * Add hover class for menu item. 307 * 308 * @since 5.3.0 309 * 310 * @param {HTMLElement} item Menu item Element. 311 */ 312 function addHoverClass( item ) { 313 item.classList.add( 'hover' ); 314 } 509 315 510 if ( aB.className ) 511 aB.className = aB.className.replace(/nojs/, ''); 316 /** 317 * Remove hover class for menu item. 318 * 319 * @since 5.3.0 320 * 321 * @param {HTMLElement} item Menu item Element. 322 */ 323 function removeHoverClass( item ) { 324 item.classList.remove( 'hover' ); 325 } 512 326 513 addEvent(aB, 'mouseover', function(e) { 514 addHoverClass( e.target || e.srcElement ); 515 }); 516 517 addEvent(aB, 'mouseout', function(e) { 518 removeHoverClass( e.target || e.srcElement ); 519 }); 520 521 addEvent(aB, 'click', clickShortlink ); 522 523 addEvent(aB, 'click', function(e) { 524 scrollToTop( e.target || e.srcElement ); 525 }); 526 527 addEvent( document.getElementById('wp-admin-bar-logout'), 'click', function() { 528 if ( 'sessionStorage' in window ) { 529 try { 530 for ( var key in sessionStorage ) { 531 if ( key.indexOf('wp-autosave-') != -1 ) 532 sessionStorage.removeItem(key); 533 } 534 } catch(e) {} 535 } 536 }); 327 /** 328 * Remove hover class for all menu items. 329 * 330 * @since 5.3.0 331 * 332 * @param {NodeList} topMenuItems All menu items. 333 */ 334 function removeAllHoverClass( topMenuItems ) { 335 for ( var i = 0; i < topMenuItems.length; i++ ) { 336 if ( hasHoverClass( topMenuItems[i] ) ) { 337 removeHoverClass( topMenuItems[i] ); 537 338 } 339 } 340 } 538 341 539 if ( w.location.hash ) 540 w.scrollBy(0,-32); 342 /** 343 * Scrolls to the top of the page. 344 * 345 * @since 3.4.0 346 * 347 * @param {Event} e The Click event. 348 * 349 * @return {void} 350 */ 351 function scrollToTop( e ) { 352 document.body.scrollIntoView( { 353 behavior: 'smooth' 354 } ); 355 } 541 356 542 if ( navigator.userAgent && document.body.className.indexOf( 'no-font-face' ) === -1 && 543 /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 ) ) { 357 /** 358 * Get closest Element. 359 * 360 * @since 5.3.0 361 * 362 * @param {HTMLElement} el Element to get parent. 363 * @param {string} selector CSS selector to match. 364 */ 365 function getClosest( el, selector ) { 366 if ( ! Element.prototype.matches ) { 367 Element.prototype.matches = 368 Element.prototype.matchesSelector || 369 Element.prototype.mozMatchesSelector || 370 Element.prototype.msMatchesSelector || 371 Element.prototype.oMatchesSelector || 372 Element.prototype.webkitMatchesSelector || 373 function( s ) { 374 var matches = ( this.document || this.ownerDocument ).querySelectorAll( s ), 375 i = matches.length; 376 while ( --i >= 0 && matches.item( i ) !== this ) { } 377 return i > -1; 378 }; 379 } 544 380 545 document.body.className += ' no-font-face'; 381 // Get the closest matching elent 382 for ( ; el && el !== document; el = el.parentNode ) { 383 if ( el.matches( selector ) ) { 384 return el; 546 385 } 547 } );548 })(document, window);549 550 } 386 } 387 return null; 388 } 389 } )( document, window, navigator ); -
src/js/_enqueues/wp/revisions.js
946 946 stop: this.stop 947 947 }) ); 948 948 949 this.$el.hoverIntent({ 950 over: this.mouseEnter, 951 out: this.mouseLeave, 949 hoverintent( 950 this.$el[0], 951 this.mouseEnter, 952 this.mouseLeave 953 ).options( { 952 954 timeout: 800 953 } );955 } ); 954 956 955 957 this.applySliderSettings(); 956 958 }, -
src/wp-includes/script-loader.php
976 976 ) 977 977 ); 978 978 979 $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array( 'jquery', 'hover Intent', 'utils' ), false, 1 );979 $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array( 'jquery', 'hoverintent-js', 'utils' ), false, 1 ); 980 980 did_action( 'init' ) && $scripts->localize( 981 981 'common', 982 982 'commonL10n', … … 1291 1291 1292 1292 $scripts->add( 'wp-backbone', "/wp-includes/js/wp-backbone$suffix.js", array( 'backbone', 'wp-util' ), false, 1 ); 1293 1293 1294 $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'wp-backbone', 'jquery-ui-slider', 'hover Intent' ), false, 1 );1294 $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'wp-backbone', 'jquery-ui-slider', 'hoverintent-js' ), false, 1 ); 1295 1295 1296 1296 $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array( 'jquery' ), false, 1 ); 1297 1297 … … 1490 1490 1491 1491 $scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 ); 1492 1492 1493 $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array( ), false, 1 );1493 $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array( 'hoverintent-js' ), false, 1 ); 1494 1494 1495 1495 $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wp-a11y' ), false, 1 ); 1496 1496 did_action( 'init' ) && $scripts->localize( … … 1514 1514 $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox', 'shortcode' ), false, 1 ); 1515 1515 1516 1516 $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array( 'jquery' ), '1.8.1', 1 ); 1517 1518 // JS-only version of hoverintent (no dependencies). 1519 $scripts->add( 'hoverintent-js', "/wp-includes/js/hoverintent-js.min.js", array(), '2.2.1', 1 ); 1517 1520 1518 1521 $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2', 'underscore' ), false, 1 ); 1519 1522 $scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 );