Make WordPress Core

Changeset 45558

Timestamp:
06/20/2019 02:44:30 PM (5 years ago)
Author:
atimmer
Message:

Docs: Improve JSDoc for admin/edit-comments.js.

Props manuelaugustin, diedeexterkate, thulshof, Xyfi, ireneyoast.
Fixes #47581.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/edit-comments.js

    r45553 r45558  
    11/**
     2
     3
     4
     5
    26 * @output wp-admin/js/edit-comments.js
    37 */
     
    1216    titleDiv, titleRegEx;
    1317
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
    1428    getCount = function(el) {
    1529        var n = parseInt( el.html().replace(/[^0-9]+/g, ''), 10 );
     
    2034    };
    2135
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
    2247    updateCount = function(el, n) {
    2348        var n1 = '';
     
    3661    };
    3762
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
    3874    updateApproved = function( diff, commentPostId ) {
    3975        var postSelector = '.post-com-count-' + commentPostId,
     
    4985        }
    5086
    51         // cache selectors to not get dupes
     87        //
    5288        approved = $( 'span.' + approvedClass, postSelector );
    5389        noComments = $( 'span.' + noClass, postSelector );
     
    77113    };
    78114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
    79127    updateCountText = function( selector, diff ) {
    80128        $( selector ).each(function() {
     
    87135    };
    88136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
    89148    updateDashboardText = function( response ) {
    90149        if ( ! isDashboard || ! response || ! response.i18n_comments_text ) {
     
    100159     * @since 5.2.0
    101160     *
    102      * @param {object} response Ajax response from the server.
     161     * @param {object} response Ajax response from the server that includes a
     162     *                          translated "comments in moderation" message.
    103163     *
    104164     * @return {void}
     
    118178    };
    119179
     180
     181
     182
     183
     184
     185
     186
     187
     188
     189
     190
    120191    updateHtmlTitle = function( diff ) {
    121192        var newTitle, regExMatch, titleCount, commentFrag;
     
    151222    };
    152223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
    153235    updatePending = function( diff, commentPostId ) {
    154236        var postSelector = '.post-com-count-' + commentPostId,
     
    207289    };
    208290
     291
     292
     293
     294
     295
     296
     297
     298
     299
    209300window.setCommentsList = function() {
    210301    var totalInput, perPageInput, pageInput, dimAfter, delBefore, updateTotalCount, delAfter, refillTheExtraList, diff,
     
    215306    pageInput = $('input[name="_page"]', '#comments-form');
    216307
    217     // Updates the current total (stored in the _total input)
     308    /**
     309     * Updates the total with the latest count.
     310     *
     311     * The time parameter makes sure that we only update the total if this value is
     312     * a newer value than we previously received.
     313     *
     314     * The time and setConfidentTime parameters make sure that we only update the
     315     * total when necessary. So a value that has been generated earlier will not
     316     * update the total.
     317     *
     318     * @since 2.8.0
     319     * @access private
     320     *
     321     * @param {number} total Total number of comments.
     322     * @param {number} time Unix timestamp of response.
     323     * @param {boolean} setConfidentTime Whether to update the last confident time
     324     *                                   with the given time.
     325     *
     326     * @return {void}
     327     */
    218328    updateTotalCount = function( total, time, setConfidentTime ) {
    219329        if ( time < lastConfidentTime )
     
    226336    };
    227337
    228     // this fires when viewing "All"
     338    /**
     339     * Changes DOM that need to be changed after a list item has been dimmed.
     340     *
     341     * @since 2.5.0
     342     * @access private
     343     *
     344     * @param {Object} r Ajax response object.
     345     * @param {Object} settings Settings for the wpList object.
     346     *
     347     * @return {void}
     348     */
    229349    dimAfter = function( r, settings ) {
    230350        var editRow, replyID, replyButton, response,
     
    266386    };
    267387
    268     // Send current total, page, per_page and url
     388    /**
     389     * Handles marking a comment as spam or trashing the comment.
     390     *
     391     * Is executed in the list delBefore hook.
     392     *
     393     * @since 2.8.0
     394     * @access private
     395     *
     396     * @param {Object} settings Settings for the wpList object.
     397     * @param {HTMLElement} list Comments table element.
     398     *
     399     * @return {Object} The settings object.
     400     */
    269401    delBefore = function( settings, list ) {
    270402        var note, id, el, n, h, a, author,
     
    325457    };
    326458
    327     // In admin-ajax.php, we send back the unix time stamp instead of 1 on success
     459    /**
     460     * Handles actions that need to be done after marking as spam or thrashing a
     461     * comment.
     462     *
     463     * The ajax requests return the unix time stamp a comment was marked as spam or
     464     * trashed. We use this to have a correct total amount of comments.
     465     *
     466     * @since 2.5.0
     467     * @access private
     468     *
     469     * @param {Object} r Ajax response object.
     470     * @param {Object} settings Settings for the wpList object.
     471     *
     472     * @return {void}
     473     */
    328474    delAfter = function( r, settings ) {
    329475        var total_items_i18n, total, animated, animatedCallback,
     
    546692    };
    547693
     694
     695
     696
     697
     698
     699
     700
     701
     702
     703
    548704    refillTheExtraList = function(ev) {
    549705        var args = $.query.get(), total_pages = $('.total-pages').text(), per_page = $('input[name="_per_page"]', '#comments-form').val();
     
    589745    };
    590746
     747
     748
     749
     750
     751
    591752    window.theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
     753
     754
     755
     756
     757
     758
    592759    window.theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } )
    593760        .bind('wpListDelEnd', function(e, s){
     
    599766};
    600767
     768
     769
     770
     771
     772
     773
     774
     775
    601776window.commentReply = {
    602777    cid : '',
     
    604779    originalContent : '',
    605780
     781
     782
     783
     784
     785
     786
     787
    606788    init : function() {
    607789        var row = $('#replyrow');
     
    630812    },
    631813
     814
     815
     816
     817
     818
     819
     820
     821
     822
     823
     824
     825
     826
    632827    addEvents : function(r) {
    633828        r.each(function() {
     
    638833    },
    639834
     835
     836
     837
     838
     839
     840
     841
     842
     843
     844
     845
    640846    toggle : function(el) {
    641847        if ( 'none' !== $( el ).css( 'display' ) && ( $( '#replyrow' ).parent().is('#com-reply') || window.confirm( adminCommentsL10n.warnQuickEdit ) ) ) {
     
    644850    },
    645851
     852
     853
     854
     855
     856
     857
     858
     859
     860
    646861    revert : function() {
    647862
     
    654869    },
    655870
     871
     872
     873
     874
     875
     876
     877
     878
     879
    656880    close : function() {
    657881        var commentRow = $(),
    658882            replyRow = $( '#replyrow' );
    659883
    660         // replyrow is not showing?
     884        //
    661885        if ( replyRow.parent().is( '#com-reply' ) ) {
    662886            return;
     
    689913
    690914        // reset the Quicktags buttons
    691         if ( typeof QTags != 'undefined' )
     915       if ( typeof QTags != 'undefined' )
    692916            QTags.closeAllTags('replycontent');
    693917
     
    707931    },
    708932
     933
     934
     935
     936
     937
     938
     939
     940
     941
     942
     943
     944
     945
    709946    open : function(comment_id, post_id, action) {
    710947        var editRow, rowData, act, replyButton, editHeight,
     
    8001037    },
    8011038
     1039
     1040
     1041
     1042
     1043
     1044
     1045
     1046
     1047
    8021048    send : function() {
    8031049        var post = {},
     
    8291075    },
    8301076
     1077
     1078
     1079
     1080
     1081
     1082
     1083
     1084
     1085
     1086
     1087
     1088
     1089
     1090
     1091
    8311092    show : function(xml) {
    8321093        var t = this, r, c, id, bg, pid;
     
    8901151    },
    8911152
     1153
     1154
     1155
     1156
     1157
     1158
     1159
     1160
     1161
     1162
     1163
    8921164    error : function(r) {
    8931165        var er = r.statusText,
     
    9061178    },
    9071179
     1180
     1181
     1182
     1183
     1184
     1185
     1186
     1187
     1188
     1189
     1190
    9081191    addcomment: function(post_id) {
    9091192        var t = this;
     
    9171200
    9181201    /**
    919      * Alert the user if they have unsaved changes on a comment that will be
    920      * lost if they proceed.
    921      *
    922      * @returns {boolean}
     1202     * Alert the user if they have unsaved changes on a comment that will be lost if
     1203     * they proceed with the intended action.
     1204     *
     1205     * @since 4.6.0
     1206     *
     1207     * @memberof commentReply
     1208     *
     1209     * @return {boolean} Whether it is safe the continue with the intended action.
    9231210     */
    9241211    discardCommentChanges: function() {
     
    9441231
    9451232    if ( typeof $.table_hotkeys != 'undefined' ) {
     1233
     1234
     1235
     1236
     1237
     1238
     1239
     1240
     1241
     1242
    9461243        make_hotkeys_redirect = function(which) {
    9471244            return function() {
     
    9551252        };
    9561253
     1254
     1255
     1256
     1257
     1258
     1259
     1260
     1261
     1262
     1263
     1264
    9571265        edit_comment = function(event, current_row) {
    9581266            window.location = $('span.edit a', current_row).attr('href');
    9591267        };
    9601268
     1269
     1270
     1271
     1272
     1273
     1274
     1275
     1276
    9611277        toggle_all = function() {
    9621278            $('#cb-select-all-1').data( 'wp-toggle', 1 ).trigger( 'click' ).removeData( 'wp-toggle' );
    9631279        };
    9641280
     1281
     1282
     1283
     1284
     1285
     1286
     1287
     1288
     1289
     1290
    9651291        make_bulk = function(value) {
    9661292            return function() {
Note: See TracChangeset for help on using the changeset viewer.