Make WordPress Core

Changeset 41311

Timestamp:
08/24/2017 05:51:19 PM (7 years ago)
Author:
wonderboymusic
Message:

Docs: improve JS docs for tags.js

Props atimmer, jipmoors.
Fixes #41069.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/tags.js

    r40655 r41311  
    11/* global ajaxurl, wpAjax, tagsl10n, showNotice, validateForm */
     2
     3
     4
     5
     6
     7
     8
    29
    310jQuery(document).ready(function($) {
    411
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
    522    $( '#the-list' ).on( 'click', '.delete-tag', function() {
    623        var t = $(this), tr = t.parents('tr'), r = true, data;
     24
    725        if ( 'undefined' != showNotice )
    826            r = showNotice.warn();
     27
    928        if ( r ) {
    1029            data = t.attr('href').replace(/[^?]*\?/, '').replace(/action=delete/, 'action=delete-tag');
     30
     31
     32
     33
     34
     35
     36
     37
     38
    1139            $.post(ajaxurl, data, function(r){
    1240                if ( '1' == r ) {
    1341                    $('#ajax-response').empty();
    1442                    tr.fadeOut('normal', function(){ tr.remove(); });
    15                     // Remove the term from the parent box and tag cloud
     43
     44                    /**
     45                     * @summary Remove the term from the parent box and the tag cloud
     46                     *
     47                     * `data.match(/tag_ID=(\d+)/)[1]` matches the term id from the data variable.
     48                     * This term id is then used to select the relevant HTML elements:
     49                     * The parent box and the tag cloud.
     50                     */
    1651                    $('select#parent option[value="' + data.match(/tag_ID=(\d+)/)[1] + '"]').remove();
    1752                    $('a.tag-link-' + data.match(/tag_ID=(\d+)/)[1]).remove();
     53
    1854                } else if ( '-1' == r ) {
    1955                    $('#ajax-response').empty().append('<div class="error"><p>' + tagsl10n.noPerm + '</p></div>');
    2056                    tr.children().css('backgroundColor', '');
     57
    2158                } else {
    2259                    $('#ajax-response').empty().append('<div class="error"><p>' + tagsl10n.broken + '</p></div>');
     
    2461                }
    2562            });
     63
    2664            tr.children().css('backgroundColor', '#f33');
    2765        }
     66
    2867        return false;
    2968    });
    3069
     70
     71
     72
     73
     74
     75
     76
    3177    $( '#edittag' ).on( 'click', '.delete', function( e ) {
    3278        if ( 'undefined' === typeof showNotice ) {
     
    3480        }
    3581
     82
    3683        var response = showNotice.warn();
    3784        if ( ! response ) {
     
    4087    });
    4188
     89
     90
     91
     92
     93
     94
     95
     96
     97
    4298    $('#submit').click(function(){
    4399        var form = $(this).parents('form');
     
    46102            return false;
    47103
     104
     105
     106
     107
     108
     109
     110
    48111        $.post(ajaxurl, $('#addtag').serialize(), function(r){
    49112            var res, parent, term, indent, i;
Note: See TracChangeset for help on using the changeset viewer.