Changeset 43332
- Timestamp:
- 06/07/2018 02:39:43 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/lib/admin-bar.js
r43309 r43332 11 11 var adminbar = $('#wpadminbar'), refresh, touchOpen, touchClose, disableHoverIntent = false; 12 12 13 refresh = function(i, el){ // force the browser to refresh the tabbing index 13 /** 14 * Forces the browser to refresh the tabbing index. 15 * 16 * @since 3.3.0 17 * 18 * @param {number} i The index of the HTML element to remove the tab index 19 * from. This parameter is necessary because we use this 20 * function in .each calls. 21 * @param {HTMLElement} el The HTML element to remove the tab index from. 22 * 23 * @return {void} 24 */ 25 refresh = function(i, el){ 14 26 var node = $(el), tab = node.attr('tabindex'); 15 27 if ( tab ) … … 17 29 }; 18 30 31 32 33 34 35 36 37 38 39 19 40 touchOpen = function(unbind) { 20 41 adminbar.find('li.menupop').on('click.wp-mobile-hover', function(e) { … … 44 65 }; 45 66 67 68 69 70 71 72 73 46 74 touchClose = function() { 47 75 var mobileEvent = /Mobile\/.+Safari/.test(navigator.userAgent) ? 'touchstart' : 'click'; … … 55 83 adminbar.removeClass('nojq').removeClass('nojs'); 56 84 85 86 57 87 if ( 'ontouchstart' in window ) { 58 88 adminbar.on('touchstart', function(){ … … 66 96 } 67 97 98 68 99 adminbar.find('li.menupop').hoverIntent({ 69 100 over: function() { … … 84 115 }); 85 116 117 118 86 119 if ( window.location.hash ) 87 120 window.scrollBy( 0, -32 ); 88 121 122 123 124 125 126 127 128 129 130 131 89 132 $('#wp-admin-bar-get-shortlink').click(function(e){ 90 133 e.preventDefault(); … … 94 137 }); 95 138 139 140 141 142 143 144 145 146 147 148 96 149 $('#wpadminbar li.menupop > .ab-item').bind('keydown.adminbar', function(e){ 150 97 151 if ( e.which != 13 ) 98 152 return; … … 117 171 }).each(refresh); 118 172 173 174 175 176 177 178 179 180 181 182 119 183 $('#wpadminbar .ab-item').bind('keydown.adminbar', function(e){ 184 120 185 if ( e.which != 27 ) 121 186 return; … … 130 195 }); 131 196 197 198 199 200 201 202 203 132 204 adminbar.click( function(e) { 133 205 if ( e.target.id != 'wpadminbar' && e.target.id != 'wp-admin-bar-top-secondary' ) { … … 140 212 }); 141 213 142 // fix focus bug in WebKit 214 /** 215 * Sets the focus on an element with a href attribute. 216 * 217 * The timeout is used to fix a focus bug in WebKit. 218 * 219 * @param {Object} e The keydown event. 220 * 221 * @return {void} 222 */ 143 223 $('.screen-reader-shortcut').keydown( function(e) { 144 224 var id, ua; … … 159 239 160 240 $( '#adminbar-search' ).on({ 241 242 243 244 245 161 246 focus: function() { 162 247 $( '#adminbarsearch' ).addClass( 'adminbar-focused' ); 248 249 250 251 252 163 253 }, blur: function() { 164 254 $( '#adminbarsearch' ).removeClass( 'adminbar-focused' ); … … 166 256 } ); 167 257 168 // Empty sessionStorage on logging out169 258 if ( 'sessionStorage' in window ) { 259 260 261 262 263 170 264 $('#wp-admin-bar-logout a').click( function() { 171 265 try { … … 185 279 }); 186 280 } else { 281 282 283 284 285 286 287 288 187 289 (function(d, w) { 290 291 292 293 294 295 296 297 298 299 300 188 301 var addEvent = function( obj, type, fn ) { 189 302 if ( obj.addEventListener ) … … 197 310 198 311 /** 199 * Get the timeout ID of the given element 312 * Gets the timeout ID of the given element. 313 * 314 * @since 3.1.0 315 * 316 * @param {HTMLElement} el The HTML element. 317 * 318 * @return {number|boolean} The ID value of the timer that is set or false. 200 319 */ 201 320 getTOID = function(el) { … … 208 327 }, 209 328 329 330 331 332 333 334 335 336 337 210 338 addHoverClass = function(t) { 211 339 var i, id, inA, hovering, ul, li, … … 213 341 ancestorLength = 0; 214 342 343 215 344 while ( t && t != aB && t != d ) { 216 345 if ( 'LI' == t.nodeName.toUpperCase() ) { … … 225 354 } 226 355 227 // Remove any selected classes.356 // Remove any selected classes. 228 357 if ( hovering && hovering.parentNode ) { 229 358 ul = hovering.parentNode; … … 238 367 } 239 368 240 / * remove the hover class for any objects not in the immediate element's ancestry */369 / 241 370 i = q.length; 242 371 while ( i-- ) { … … 253 382 }, 254 383 384 385 386 387 388 389 390 391 392 255 393 removeHoverClass = function(t) { 256 394 while ( t && t != aB && t != d ) { … … 267 405 }, 268 406 407 408 409 410 411 412 413 414 415 269 416 clickShortlink = function(e) { 270 417 var i, l, node, … … 305 452 }, 306 453 454 455 456 457 458 459 460 461 462 307 463 scrollToTop = function(t) { 308 464 var distance, speed, step, steps, timer, speed_step;
Note: See TracChangeset
for help on using the changeset viewer.