Make WordPress Core

Changeset 43332

Timestamp:
06/07/2018 02:39:43 PM (6 years ago)
Author:
atimmer
Message:

Docs: Improve JSDoc for admin-bar.js.

Props manuelaugustin, terwdan, sjardo, LisanneKluitmans.
Fixes #43871.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/lib/admin-bar.js

    r43309 r43332  
    1111        var adminbar = $('#wpadminbar'), refresh, touchOpen, touchClose, disableHoverIntent = false;
    1212
    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){
    1426            var node = $(el), tab = node.attr('tabindex');
    1527            if ( tab )
     
    1729        };
    1830
     31
     32
     33
     34
     35
     36
     37
     38
     39
    1940        touchOpen = function(unbind) {
    2041            adminbar.find('li.menupop').on('click.wp-mobile-hover', function(e) {
     
    4465        };
    4566
     67
     68
     69
     70
     71
     72
     73
    4674        touchClose = function() {
    4775            var mobileEvent = /Mobile\/.+Safari/.test(navigator.userAgent) ? 'touchstart' : 'click';
     
    5583        adminbar.removeClass('nojq').removeClass('nojs');
    5684
     85
     86
    5787        if ( 'ontouchstart' in window ) {
    5888            adminbar.on('touchstart', function(){
     
    6696        }
    6797
     98
    6899        adminbar.find('li.menupop').hoverIntent({
    69100            over: function() {
     
    84115        });
    85116
     117
     118
    86119        if ( window.location.hash )
    87120            window.scrollBy( 0, -32 );
    88121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
    89132        $('#wp-admin-bar-get-shortlink').click(function(e){
    90133            e.preventDefault();
     
    94137        });
    95138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
    96149        $('#wpadminbar li.menupop > .ab-item').bind('keydown.adminbar', function(e){
     150
    97151            if ( e.which != 13 )
    98152                return;
     
    117171        }).each(refresh);
    118172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
    119183        $('#wpadminbar .ab-item').bind('keydown.adminbar', function(e){
     184
    120185            if ( e.which != 27 )
    121186                return;
     
    130195        });
    131196
     197
     198
     199
     200
     201
     202
     203
    132204        adminbar.click( function(e) {
    133205            if ( e.target.id != 'wpadminbar' && e.target.id != 'wp-admin-bar-top-secondary' ) {
     
    140212        });
    141213
    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         */
    143223        $('.screen-reader-shortcut').keydown( function(e) {
    144224            var id, ua;
     
    159239
    160240        $( '#adminbar-search' ).on({
     241
     242
     243
     244
     245
    161246            focus: function() {
    162247                $( '#adminbarsearch' ).addClass( 'adminbar-focused' );
     248
     249
     250
     251
     252
    163253            }, blur: function() {
    164254                $( '#adminbarsearch' ).removeClass( 'adminbar-focused' );
     
    166256        } );
    167257
    168         // Empty sessionStorage on logging out
    169258        if ( 'sessionStorage' in window ) {
     259
     260
     261
     262
     263
    170264            $('#wp-admin-bar-logout a').click( function() {
    171265                try {
     
    185279    });
    186280} else {
     281
     282
     283
     284
     285
     286
     287
     288
    187289    (function(d, w) {
     290
     291
     292
     293
     294
     295
     296
     297
     298
     299
     300
    188301        var addEvent = function( obj, type, fn ) {
    189302            if ( obj.addEventListener )
     
    197310
    198311        /**
    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.
    200319         */
    201320        getTOID = function(el) {
     
    208327        },
    209328
     329
     330
     331
     332
     333
     334
     335
     336
     337
    210338        addHoverClass = function(t) {
    211339            var i, id, inA, hovering, ul, li,
     
    213341                ancestorLength = 0;
    214342
     343
    215344            while ( t && t != aB && t != d ) {
    216345                if ( 'LI' == t.nodeName.toUpperCase() ) {
     
    225354            }
    226355
    227             // Remove any selected classes.
     356            // Remove any selected classes.
    228357            if ( hovering && hovering.parentNode ) {
    229358                ul = hovering.parentNode;
     
    238367            }
    239368
    240             /* remove the hover class for any objects not in the immediate element's ancestry */
     369            /
    241370            i = q.length;
    242371            while ( i-- ) {
     
    253382        },
    254383
     384
     385
     386
     387
     388
     389
     390
     391
     392
    255393        removeHoverClass = function(t) {
    256394            while ( t && t != aB && t != d ) {
     
    267405        },
    268406
     407
     408
     409
     410
     411
     412
     413
     414
     415
    269416        clickShortlink = function(e) {
    270417            var i, l, node,
     
    305452        },
    306453
     454
     455
     456
     457
     458
     459
     460
     461
     462
    307463        scrollToTop = function(t) {
    308464            var distance, speed, step, steps, timer, speed_step;
Note: See TracChangeset for help on using the changeset viewer.