Make WordPress Core

Changeset 43352 for trunk


Ignore:
Timestamp:
06/16/2018 10:11:57 AM (8 years ago)
Author:
atimmer
Message:

Docs: Improve JSDoc for admin/link.js.

Props andg.
Fixes #44362.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/link.js

    r43347 r43352  
    1313        postboxes.add_postbox_toggles('link');
    1414
    15         // category tabs
     15        /**
     16         * Adds event that opens a particular category tab.
     17         *
     18         * @ignore
     19         *
     20         * @return {boolean} Always returns false to prevent the default behavior.
     21         */
    1622        $('#category-tabs a').click(function(){
    1723                var t = $(this).attr('href');
     
    3036        // Ajax Cat
    3137        newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ); } );
     38
     39        /**
     40         * After adding a new category, focus on the category add input field.
     41         *
     42         * @return {void}
     43         */
    3244        $('#link-category-add-submit').click( function() { newCat.focus(); } );
     45
     46        /**
     47         * Synchronize category checkboxes.
     48         *
     49         * This function makes sure that the checkboxes are synced between the all
     50         * categories tab and the most used categories tab.
     51         *
     52         * @since 2.5.0
     53         *
     54         * @return {void}
     55         */
    3356        syncChecks = function() {
    3457                if ( noSyncChecks )
     
    4063        };
    4164
     65        /**
     66         * Adds event listeners to an added category.
     67         *
     68         * This is run on the addAfter event to make sure the correct event listeners
     69         * are bound to the DOM elements.
     70         *
     71         * @since 2.5.0
     72         *
     73         * @param {string} r Raw XML response returned from the server after adding a
     74         *                   category.
     75         * @param {Object} s List manager configuration object; settings for the Ajax
     76         *                   request.
     77         *
     78         * @return {void}
     79         */
    4280        catAddAfter = function( r, s ) {
    4381                $(s.what + ' response_data', r).each( function() {
     
    5189        };
    5290
     91        /*
     92         * Instantiates the list manager.
     93         *
     94         * @see js/_enqueues/lib/lists.js
     95         */
    5396        $('#categorychecklist').wpList( {
     97                // CSS class name for alternate styling.
    5498                alt: '',
     99
     100                // The type of list.
    55101                what: 'link-category',
     102
     103                // ID of the element the parsed Ajax response will be stored in.
    56104                response: 'category-ajax-response',
     105
     106                // Callback that's run after an item got added to the list.
    57107                addAfter: catAddAfter
    58108        } );
    59109
     110        // All categories is the default tab, so we delete the user setting.
    60111        $('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');});
     112
     113        // Set a preference for the popular categories to cookies.
    61114        $('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');});
     115
    62116        if ( 'pop' == getUserSetting('cats') )
    63117                $('a[href="#categories-pop"]').click();
    64118
     119        /**
     120         * Adds event handler that shows the interface controls to add a new category.
     121         *
     122         * @ignore
     123         *
     124         * @param {Event} event The event object.
     125         * @returns {boolean} Always returns false to prevent regular link
     126         *                    functionality.
     127         */
    65128        $('#category-add-toggle').click( function() {
    66129                $(this).parents('div:first').toggleClass( 'wp-hidden-children' );
Note: See TracChangeset for help on using the changeset viewer.