Make WordPress Core

Ticket #44362: 44362.diff

File 44362.diff, 3.5 KB (added by andg, 7 years ago)
  • src/js/_enqueues/admin/link.js

     
    11/* global postboxes, deleteUserSetting, setUserSetting, getUserSetting */
    22
     3/**
     4 * Binds to the document ready event.
     5 *
     6 * @since 2.5.0
     7 *
     8 * @param {jQuery} $ The jQuery object.
     9 */
    310jQuery(document).ready( function($) {
    411
    512        var newCat, noSyncChecks = false, syncChecks, catAddAfter;
     
    815        // postboxes
    916        postboxes.add_postbox_toggles('link');
    1017
    11         // category tabs
     18        /**
     19         * Adds event that opens a particular category tab.
     20         *
     21         * @listens $('#category-tabs a'):click
     22         *
     23         * @param {Event} event The event object.
     24         * @returns {Boolean} False, prevents regular link functionality.
     25         */
    1226        $('#category-tabs a').click(function(){
    1327                var t = $(this).attr('href');
    1428                $(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
     
    2539
    2640        // Ajax Cat
    2741        newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ); } );
     42
     43        /**
     44         * After adding a new category, focus on the category add input field.
     45         *
     46         * @listens $('#link-category-add-submit'):click
     47         *
     48         * @return {void}
     49         */
    2850        $('#link-category-add-submit').click( function() { newCat.focus(); } );
     51
     52        /**
     53         * Syncronize category checkboxes.
     54         *
     55         * @return {void}
     56         */
    2957        syncChecks = function() {
    3058                if ( noSyncChecks )
    3159                        return;
     
    3563                noSyncChecks = false;
    3664        };
    3765
     66        /**
     67         * Callback that's run after an item got added to the list.
     68         *
     69         * @param {XML} r Raw response returned from the server.
     70         * @param {Object} s List manager configuration object; settings for the Ajax request.
     71         *
     72         * @return {void}
     73         */
    3874        catAddAfter = function( r, s ) {
    3975                $(s.what + ' response_data', r).each( function() {
    4076                        var t = $($(this).text());
     
    4682                } );
    4783        };
    4884
     85        /**
     86         * List manager.
     87         *
     88         * @param {Object} List manager configuration object.
     89         *
     90         * @see wp-includes/js/wp-lists.js
     91         *
     92         * @type {wpList}
     93         */
    4994        $('#categorychecklist').wpList( {
     95                // CSS class name for alternate styling.
    5096                alt: '',
     97
     98                // The type of list.
    5199                what: 'link-category',
     100
     101                // ID of the element the parsed Ajax response will be stored in.
    52102                response: 'category-ajax-response',
     103
     104                // Callback that's run after an item got added to the list.
    53105                addAfter: catAddAfter
    54106        } );
    55107
     108        /**
     109         * Delete the user setting regarding which category tab should be shown.
     110         *
     111         * @listens $('a[href="#categories-all"]'):click
     112         *
     113         * @return {void}
     114         */
    56115        $('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');});
     116
     117        /**
     118         * Set the user setting regarding which category tab should be shown to display
     119         * popular categories.
     120         *
     121         * @listens $('a[href="#categories-pop"]'):click
     122         *
     123         * @return {void}
     124         */
    57125        $('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');});
     126
    58127        if ( 'pop' == getUserSetting('cats') )
    59128                $('a[href="#categories-pop"]').click();
    60129
     130        /**
     131         * Adds event that shows the interface controls to add a new category.
     132         *
     133         * @listens $('#category-add-toggle'):click
     134         *
     135         * @param {Event} event The event object.
     136         * @returns {Boolean} False, prevents regular link functionality.
     137         */
    61138        $('#category-add-toggle').click( function() {
    62139                $(this).parents('div:first').toggleClass( 'wp-hidden-children' );
    63140                $('#category-tabs a[href="#categories-all"]').click();