diff --git src/wp-includes/js/admin-bar.js src/wp-includes/js/admin-bar.js
index 10d2954..d8d9fbb 100644
|
|
if ( typeof(jQuery) != 'undefined' ) { |
10 | 10 | jQuery(document).ready(function($){ |
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.5.0 |
| 17 | * |
| 18 | * @param {integer} i The index of the HTML element to remove the tab index from. |
| 19 | * @param {HTMLElement} el The HTML element to remove the tab index from. |
| 20 | * |
| 21 | * @returns {void} |
| 22 | */ |
| 23 | refresh = function(i, el){ |
14 | 24 | var node = $(el), tab = node.attr('tabindex'); |
15 | 25 | if ( tab ) |
16 | 26 | node.attr('tabindex', '0').attr('tabindex', tab); |
17 | 27 | }; |
18 | 28 | |
| 29 | /** |
| 30 | * Adds or removes the hover class on touch. |
| 31 | * |
| 32 | * @since 3.5.0 |
| 33 | * |
| 34 | * @param {bool} unbind If true removes the wp-mobile-hover class. |
| 35 | * |
| 36 | * @returns {void} |
| 37 | */ |
19 | 38 | touchOpen = function(unbind) { |
20 | 39 | adminbar.find('li.menupop').on('click.wp-mobile-hover', function(e) { |
21 | 40 | var el = $(this); |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
43 | 62 | }); |
44 | 63 | }; |
45 | 64 | |
| 65 | /** |
| 66 | * Removes the hover class if clicked or touched outside the adminbar. |
| 67 | * |
| 68 | * @since 3.5.0 |
| 69 | * |
| 70 | * @returns {void} |
| 71 | */ |
46 | 72 | touchClose = function() { |
47 | 73 | var mobileEvent = /Mobile\/.+Safari/.test(navigator.userAgent) ? 'touchstart' : 'click'; |
48 | 74 | // close any open drop-downs when the click/touch is not on the toolbar |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
54 | 80 | |
55 | 81 | adminbar.removeClass('nojq').removeClass('nojs'); |
56 | 82 | |
| 83 | // If clicked on the adminbar add the hoverclass, if clicked outside it remove it. |
57 | 84 | if ( 'ontouchstart' in window ) { |
58 | 85 | adminbar.on('touchstart', function(){ |
59 | 86 | touchOpen(true); |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
65 | 92 | touchClose(); |
66 | 93 | } |
67 | 94 | |
| 95 | // Adds or remove the hover class based on the hover intent. |
68 | 96 | adminbar.find('li.menupop').hoverIntent({ |
69 | 97 | over: function() { |
70 | 98 | if ( disableHoverIntent ) |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
83 | 111 | interval: 100 |
84 | 112 | }); |
85 | 113 | |
| 114 | // Prevents the toolbar from covering up content when a hash is present in the URL. |
86 | 115 | if ( window.location.hash ) |
87 | 116 | window.scrollBy( 0, -32 ); |
88 | 117 | |
| 118 | /** |
| 119 | * Adds selected class to shortlink in admin bar. |
| 120 | * |
| 121 | * Removes the selected class from the parents of the selected shortlink-input. |
| 122 | * |
| 123 | * @since 3.5.0 |
| 124 | * |
| 125 | * @param {event} e The click event. |
| 126 | * |
| 127 | * @returns {void} |
| 128 | **/ |
89 | 129 | $('#wp-admin-bar-get-shortlink').click(function(e){ |
90 | 130 | e.preventDefault(); |
91 | 131 | $(this).addClass('selected').children('.shortlink-input').blur(function(){ |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
93 | 133 | }).focus().select(); |
94 | 134 | }); |
95 | 135 | |
| 136 | /** |
| 137 | * It removes the hoverclass if the enter key is pressed. |
| 138 | * |
| 139 | * Makes sure the tab index is refreshed by refreshing each ab-item |
| 140 | * and its children. |
| 141 | * |
| 142 | * @since 3.5.0 |
| 143 | * |
| 144 | * @param {event} e The keydown event. |
| 145 | * |
| 146 | * @returns {void} |
| 147 | */ |
96 | 148 | $('#wpadminbar li.menupop > .ab-item').bind('keydown.adminbar', function(e){ |
| 149 | // Key code 13 is the enter key. |
97 | 150 | if ( e.which != 13 ) |
98 | 151 | return; |
99 | 152 | |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
116 | 169 | target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh); |
117 | 170 | }).each(refresh); |
118 | 171 | |
| 172 | /** |
| 173 | * Removes the hover class when the escape key is pressed. |
| 174 | * |
| 175 | * Makes sure the tab index is refreshed by refreshing each ab-item |
| 176 | * and its children. |
| 177 | * |
| 178 | * @since 3.5.0 |
| 179 | * |
| 180 | * @param {event} e The keydown event. |
| 181 | * |
| 182 | * @returns {void} |
| 183 | */ |
119 | 184 | $('#wpadminbar .ab-item').bind('keydown.adminbar', function(e){ |
| 185 | // Key code 27 is the escape key. |
120 | 186 | if ( e.which != 27 ) |
121 | 187 | return; |
122 | 188 | |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
129 | 195 | target.siblings('.ab-sub-wrapper').find('.ab-item').each(refresh); |
130 | 196 | }); |
131 | 197 | |
| 198 | /** |
| 199 | * Scrolls to top of page by clicking the adminbar. |
| 200 | * |
| 201 | * @since 4.3.0 |
| 202 | * |
| 203 | * @param {event} e The click event. |
| 204 | * |
| 205 | * @returns {void} |
| 206 | */ |
132 | 207 | adminbar.click( function(e) { |
133 | 208 | if ( e.target.id != 'wpadminbar' && e.target.id != 'wp-admin-bar-top-secondary' ) { |
134 | 209 | return; |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
139 | 214 | e.preventDefault(); |
140 | 215 | }); |
141 | 216 | |
142 | | // fix focus bug in WebKit |
| 217 | /** |
| 218 | * Sets the focus on an element with a href attribute. |
| 219 | * |
| 220 | * The timeout is used to fix a focus bug in WebKit. |
| 221 | * |
| 222 | * @since 3.5.0 |
| 223 | * |
| 224 | * @param {event} e The keydown event. |
| 225 | * |
| 226 | * @returns {void} |
| 227 | */ |
143 | 228 | $('.screen-reader-shortcut').keydown( function(e) { |
144 | 229 | var id, ua; |
145 | 230 | |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
158 | 243 | }); |
159 | 244 | |
160 | 245 | $( '#adminbar-search' ).on({ |
| 246 | /** |
| 247 | * Adds the adminbar-focused class on focus. |
| 248 | * |
| 249 | * @since 4.2.0 |
| 250 | * |
| 251 | * @returns {void} |
| 252 | */ |
161 | 253 | focus: function() { |
162 | 254 | $( '#adminbarsearch' ).addClass( 'adminbar-focused' ); |
| 255 | /** |
| 256 | * Remove the adminbar-focused class on blur. |
| 257 | * |
| 258 | * @since 4.2.0 |
| 259 | * |
| 260 | * @returns {void} |
| 261 | */ |
163 | 262 | }, blur: function() { |
164 | 263 | $( '#adminbarsearch' ).removeClass( 'adminbar-focused' ); |
165 | 264 | } |
166 | 265 | } ); |
167 | 266 | |
168 | | // Empty sessionStorage on logging out |
169 | 267 | if ( 'sessionStorage' in window ) { |
| 268 | /** |
| 269 | * Empties sessionStorage on logging out. |
| 270 | * |
| 271 | * @since 3.6.0 |
| 272 | * |
| 273 | * @returns {void} |
| 274 | */ |
170 | 275 | $('#wp-admin-bar-logout a').click( function() { |
171 | 276 | try { |
172 | 277 | for ( var key in sessionStorage ) { |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
184 | 289 | } |
185 | 290 | }); |
186 | 291 | } else { |
| 292 | /** |
| 293 | * Wrapper function for the adminbar that's used if jQuery isn't available. |
| 294 | * |
| 295 | * @since 3.5.0 |
| 296 | * |
| 297 | * @param {Object} d The document object. |
| 298 | * @param {Object} w The window object. |
| 299 | * |
| 300 | * @returns {void} |
| 301 | */ |
187 | 302 | (function(d, w) { |
| 303 | /** |
| 304 | * Adds an event listener to an object. |
| 305 | * |
| 306 | * @since 3.5.0 |
| 307 | * |
| 308 | * @param {Object} obj The object to add the event listener to. |
| 309 | * @param {string} type The type of event. |
| 310 | * @param {function} fn The function to bind to the event listener. |
| 311 | * |
| 312 | * @returns {void} |
| 313 | */ |
188 | 314 | var addEvent = function( obj, type, fn ) { |
189 | 315 | if ( obj.addEventListener ) |
190 | 316 | obj.addEventListener(type, fn, false); |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
195 | 321 | aB, hc = new RegExp('\\bhover\\b', 'g'), q = [], |
196 | 322 | rselected = new RegExp('\\bselected\\b', 'g'), |
197 | 323 | |
198 | | /** |
199 | | * Get the timeout ID of the given element |
| 324 | /** |
| 325 | * Gets the timeout ID of the given element. |
| 326 | * |
| 327 | * @since 3.5.0 |
| 328 | * |
| 329 | * @param {HTMLElement} el The HTML element. |
| 330 | * |
| 331 | * @returns {number|boolean} The ID value of the timer that is set or false. |
200 | 332 | */ |
201 | 333 | getTOID = function(el) { |
202 | 334 | var i = q.length; |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
207 | 339 | return false; |
208 | 340 | }, |
209 | 341 | |
| 342 | /** |
| 343 | * Adds the hoverclass to menu items. |
| 344 | * |
| 345 | * @since 3.5.0 |
| 346 | * |
| 347 | * @param {HTMLElement} t The HTML element. |
| 348 | * |
| 349 | * @returns {void} |
| 350 | */ |
210 | 351 | addHoverClass = function(t) { |
211 | 352 | var i, id, inA, hovering, ul, li, |
212 | 353 | ancestors = [], |
213 | 354 | ancestorLength = 0; |
214 | 355 | |
| 356 | // aB is adminbar. d is document. |
215 | 357 | while ( t && t != aB && t != d ) { |
216 | 358 | if ( 'LI' == t.nodeName.toUpperCase() ) { |
217 | 359 | ancestors[ ancestors.length ] = t; |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
224 | 366 | t = t.parentNode; |
225 | 367 | } |
226 | 368 | |
227 | | // Remove any selected classes. |
| 369 | // Removes any selected classes. |
228 | 370 | if ( hovering && hovering.parentNode ) { |
229 | 371 | ul = hovering.parentNode; |
230 | 372 | if ( ul && 'UL' == ul.nodeName.toUpperCase() ) { |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
237 | 379 | } |
238 | 380 | } |
239 | 381 | |
240 | | /* remove the hover class for any objects not in the immediate element's ancestry */ |
| 382 | // Removes the hover class for any objects not in the immediate element's ancestry. |
241 | 383 | i = q.length; |
242 | 384 | while ( i-- ) { |
243 | 385 | inA = false; |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
252 | 394 | } |
253 | 395 | }, |
254 | 396 | |
| 397 | /** |
| 398 | * Removes the hoverclass from menu items. |
| 399 | * |
| 400 | * @since 3.5.0 |
| 401 | * |
| 402 | * @param {HTMLElement} t The HTML element. |
| 403 | * |
| 404 | * @returns {void} |
| 405 | */ |
255 | 406 | removeHoverClass = function(t) { |
256 | 407 | while ( t && t != aB && t != d ) { |
257 | 408 | if ( 'LI' == t.nodeName.toUpperCase() ) { |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
266 | 417 | } |
267 | 418 | }, |
268 | 419 | |
| 420 | /** |
| 421 | * Handles the click on a shortlink in the adminbar. |
| 422 | * |
| 423 | * @since 3.5.0 |
| 424 | * |
| 425 | * @param {HTMLElement} e The HTML element. |
| 426 | * |
| 427 | * @returns {boolean} |
| 428 | */ |
269 | 429 | clickShortlink = function(e) { |
270 | 430 | var i, l, node, |
271 | 431 | t = e.target || e.srcElement; |
… |
… |
if ( typeof(jQuery) != 'undefined' ) { |
304 | 464 | return false; |
305 | 465 | }, |
306 | 466 | |
| 467 | /** |
| 468 | * Scrolls to the top of the page. |
| 469 | * |
| 470 | * @since 3.5.0 |
| 471 | * |
| 472 | * @param {HTMLElement} t The HTML element. |
| 473 | * |
| 474 | * @returns {void} |
| 475 | */ |
307 | 476 | scrollToTop = function(t) { |
308 | 477 | var distance, speed, step, steps, timer, speed_step; |
309 | 478 | |