~canonical-sysadmins/wordpress/4.5.2

« back to all changes in this revision

Viewing changes to wp-admin/js/edit-comments.js

  • Committer: Manuel Seelaus
  • Date: 2015-12-09 17:47:18 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: manuel.seelaus@canonical.com-20151209174718-coxethm2swbeqksy
Merge WP4.4 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
var setCommentsList, theList, theExtraList, commentReply;
3
3
 
4
4
(function($) {
5
 
var getCount, updateCount, updatePending;
 
5
var getCount, updateCount, updateCountText, updatePending, updateApproved,
 
6
        updateHtmlTitle, updateDashboardText, adminTitle = document.title,
 
7
        isDashboard = $('#dashboard_right_now').length,
 
8
        titleDiv, titleRegEx;
 
9
 
 
10
        getCount = function(el) {
 
11
                var n = parseInt( el.html().replace(/[^0-9]+/g, ''), 10 );
 
12
                if ( isNaN(n) ) {
 
13
                        return 0;
 
14
                }
 
15
                return n;
 
16
        };
 
17
 
 
18
        updateCount = function(el, n) {
 
19
                var n1 = '';
 
20
                if ( isNaN(n) ) {
 
21
                        return;
 
22
                }
 
23
                n = n < 1 ? '0' : n.toString();
 
24
                if ( n.length > 3 ) {
 
25
                        while ( n.length > 3 ) {
 
26
                                n1 = thousandsSeparator + n.substr(n.length - 3) + n1;
 
27
                                n = n.substr(0, n.length - 3);
 
28
                        }
 
29
                        n = n + n1;
 
30
                }
 
31
                el.html(n);
 
32
        };
 
33
 
 
34
        updateApproved = function( diff, commentPostId ) {
 
35
                var postSelector = '.post-com-count-' + commentPostId,
 
36
                        noClass = 'comment-count-no-comments',
 
37
                        approvedClass = 'comment-count-approved',
 
38
                        approved,
 
39
                        noComments;
 
40
 
 
41
                updateCountText( 'span.approved-count', diff );
 
42
 
 
43
                if ( ! commentPostId ) {
 
44
                        return;
 
45
                }
 
46
 
 
47
                // cache selectors to not get dupes
 
48
                approved = $( 'span.' + approvedClass, postSelector );
 
49
                noComments = $( 'span.' + noClass, postSelector );
 
50
 
 
51
                approved.each(function() {
 
52
                        var a = $(this), n = getCount(a) + diff;
 
53
                        if ( n < 1 )
 
54
                                n = 0;
 
55
 
 
56
                        if ( 0 === n ) {
 
57
                                a.removeClass( approvedClass ).addClass( noClass );
 
58
                        } else {
 
59
                                a.addClass( approvedClass ).removeClass( noClass );
 
60
                        }
 
61
                        updateCount( a, n );
 
62
                });
 
63
 
 
64
                noComments.each(function() {
 
65
                        var a = $(this);
 
66
                        if ( diff > 0 ) {
 
67
                                a.removeClass( noClass ).addClass( approvedClass );
 
68
                        } else {
 
69
                                a.addClass( noClass ).removeClass( approvedClass );
 
70
                        }
 
71
                        updateCount( a, diff );
 
72
                });
 
73
        };
 
74
 
 
75
        updateCountText = function( selector, diff ) {
 
76
                $( selector ).each(function() {
 
77
                        var a = $(this), n = getCount(a) + diff;
 
78
                        if ( n < 1 ) {
 
79
                                n = 0;
 
80
                        }
 
81
                        updateCount( a, n );
 
82
                });
 
83
        };
 
84
 
 
85
        updateDashboardText = function ( response ) {
 
86
                if ( ! isDashboard || ! response || ! response.i18n_comments_text ) {
 
87
                        return;
 
88
                }
 
89
 
 
90
                var rightNow = $( '#dashboard_right_now' );
 
91
 
 
92
                $( '.comment-count a', rightNow ).text( response.i18n_comments_text );
 
93
                $( '.comment-mod-count a', rightNow ).text( response.i18n_moderation_text )
 
94
                        .parent()
 
95
                        [ response.in_moderation > 0 ? 'removeClass' : 'addClass' ]( 'hidden' );
 
96
        };
 
97
 
 
98
        updateHtmlTitle = function ( diff ) {
 
99
                var newTitle, regExMatch, titleCount, commentFrag;
 
100
 
 
101
                titleRegEx = titleRegEx || new RegExp( adminCommentsL10n.docTitleCommentsCount.replace( '%s', '\\([0-9' + thousandsSeparator + ']+\\)' ) + '?' );
 
102
                // count funcs operate on a $'d element
 
103
                titleDiv = titleDiv || $( '<div />' );
 
104
                newTitle = adminTitle;
 
105
 
 
106
                commentFrag = titleRegEx.exec( document.title );
 
107
                if ( commentFrag ) {
 
108
                        commentFrag = commentFrag[0];
 
109
                        titleDiv.html( commentFrag );
 
110
                        titleCount = getCount( titleDiv ) + diff;
 
111
                } else {
 
112
                        titleDiv.html( 0 );
 
113
                        titleCount = diff;
 
114
                }
 
115
 
 
116
                if ( titleCount >= 1 ) {
 
117
                        updateCount( titleDiv, titleCount );
 
118
                        regExMatch = titleRegEx.exec( document.title );
 
119
                        if ( regExMatch ) {
 
120
                                newTitle = document.title.replace( regExMatch[0], adminCommentsL10n.docTitleCommentsCount.replace( '%s', titleDiv.text() ) + ' ' );
 
121
                        }
 
122
                } else {
 
123
                        regExMatch = titleRegEx.exec( newTitle );
 
124
                        if ( regExMatch ) {
 
125
                                newTitle = newTitle.replace( regExMatch[0], adminCommentsL10n.docTitleComments );
 
126
                        }
 
127
                }
 
128
                document.title = newTitle;
 
129
        };
 
130
 
 
131
        updatePending = function( diff, commentPostId ) {
 
132
                var postSelector = '.post-com-count-' + commentPostId,
 
133
                        noClass = 'comment-count-no-pending',
 
134
                        noParentClass = 'post-com-count-no-pending',
 
135
                        pendingClass = 'comment-count-pending',
 
136
                        pending,
 
137
                        noPending;
 
138
 
 
139
                if ( ! isDashboard ) {
 
140
                        updateHtmlTitle( diff );
 
141
                }
 
142
 
 
143
                $( 'span.pending-count' ).each(function() {
 
144
                        var a = $(this), n = getCount(a) + diff;
 
145
                        if ( n < 1 )
 
146
                                n = 0;
 
147
                        a.closest('.awaiting-mod')[ 0 === n ? 'addClass' : 'removeClass' ]('count-0');
 
148
                        updateCount( a, n );
 
149
                });
 
150
 
 
151
                if ( ! commentPostId ) {
 
152
                        return;
 
153
                }
 
154
 
 
155
                // cache selectors to not get dupes
 
156
                pending = $( 'span.' + pendingClass, postSelector );
 
157
                noPending = $( 'span.' + noClass, postSelector );
 
158
 
 
159
                pending.each(function() {
 
160
                        var a = $(this), n = getCount(a) + diff;
 
161
                        if ( n < 1 )
 
162
                                n = 0;
 
163
 
 
164
                        if ( 0 === n ) {
 
165
                                a.parent().addClass( noParentClass );
 
166
                                a.removeClass( pendingClass ).addClass( noClass );
 
167
                        } else {
 
168
                                a.parent().removeClass( noParentClass );
 
169
                                a.addClass( pendingClass ).removeClass( noClass );
 
170
                        }
 
171
                        updateCount( a, n );
 
172
                });
 
173
 
 
174
                noPending.each(function() {
 
175
                        var a = $(this);
 
176
                        if ( diff > 0 ) {
 
177
                                a.parent().removeClass( noParentClass );
 
178
                                a.removeClass( noClass ).addClass( pendingClass );
 
179
                        } else {
 
180
                                a.parent().addClass( noParentClass );
 
181
                                a.addClass( noClass ).removeClass( pendingClass );
 
182
                        }
 
183
                        updateCount( a, diff );
 
184
                });
 
185
        };
6
186
 
7
187
setCommentsList = function() {
8
188
        var totalInput, perPageInput, pageInput, dimAfter, delBefore, updateTotalCount, delAfter, refillTheExtraList, diff,
12
192
        perPageInput = $('input[name="_per_page"]', '#comments-form');
13
193
        pageInput = $('input[name="_page"]', '#comments-form');
14
194
 
 
195
        // Updates the current total (stored in the _total input)
 
196
        updateTotalCount = function( total, time, setConfidentTime ) {
 
197
                if ( time < lastConfidentTime )
 
198
                        return;
 
199
 
 
200
                if ( setConfidentTime )
 
201
                        lastConfidentTime = time;
 
202
 
 
203
                totalInput.val( total.toString() );
 
204
        };
 
205
 
 
206
        // this fires when viewing "All"
15
207
        dimAfter = function( r, settings ) {
16
 
                var editRow, replyID, replyButton,
 
208
                var editRow, replyID, replyButton, response,
17
209
                        c = $( '#' + settings.element );
18
210
 
 
211
                if ( true !== settings.parsed ) {
 
212
                        response = settings.parsed.responses[0];
 
213
                }
 
214
 
19
215
                editRow = $('#replyrow');
20
216
                replyID = $('#comment_ID', editRow).val();
21
217
                replyButton = $('#replybtn', editRow);
33
229
                }
34
230
 
35
231
                diff = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1;
36
 
                updatePending( diff );
 
232
                if ( response ) {
 
233
                        updateDashboardText( response.supplemental );
 
234
                        updatePending( diff, response.supplemental.postId );
 
235
                        updateApproved( -1 * diff, response.supplemental.postId );
 
236
                } else {
 
237
                        updatePending( diff );
 
238
                        updateApproved( -1 * diff  );
 
239
                }
37
240
        };
38
241
 
39
242
        // Send current total, page, per_page and url
81
284
                        a.attr('class', 'vim-z vim-destructive');
82
285
                        $('.avatar', el).first().clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside');
83
286
 
84
 
                        a.click(function(){
 
287
                        a.click(function( e ){
 
288
                                e.preventDefault();
85
289
                                list.wpList.del(this);
86
290
                                $('#undo-' + id).css( {backgroundColor:'#ceb'} ).fadeOut(350, function(){
87
291
                                        $(this).remove();
88
292
                                        $('#comment-' + id).css('backgroundColor', '').fadeIn(300, function(){ $(this).show(); });
89
293
                                });
90
 
                                return false;
91
294
                        });
92
295
                }
93
296
 
94
297
                return settings;
95
298
        };
96
299
 
97
 
        // Updates the current total (stored in the _total input)
98
 
        updateTotalCount = function( total, time, setConfidentTime ) {
99
 
                if ( time < lastConfidentTime )
100
 
                        return;
101
 
 
102
 
                if ( setConfidentTime )
103
 
                        lastConfidentTime = time;
104
 
 
105
 
                totalInput.val( total.toString() );
106
 
        };
107
 
 
108
 
        getCount = function(el) {
109
 
                var n = parseInt( el.html().replace(/[^0-9]+/g, ''), 10 );
110
 
                if ( isNaN(n) )
111
 
                        return 0;
112
 
                return n;
113
 
        };
114
 
 
115
 
        updateCount = function(el, n) {
116
 
                var n1 = '';
117
 
                if ( isNaN(n) )
118
 
                        return;
119
 
                n = n < 1 ? '0' : n.toString();
120
 
                if ( n.length > 3 ) {
121
 
                        while ( n.length > 3 ) {
122
 
                                n1 = thousandsSeparator + n.substr(n.length - 3) + n1;
123
 
                                n = n.substr(0, n.length - 3);
124
 
                        }
125
 
                        n = n + n1;
126
 
                }
127
 
                el.html(n);
128
 
        };
129
 
 
130
 
        updatePending = function( diff ) {
131
 
                $('span.pending-count').each(function() {
132
 
                        var a = $(this), n = getCount(a) + diff;
133
 
                        if ( n < 1 )
134
 
                                n = 0;
135
 
                        a.closest('.awaiting-mod')[ 0 === n ? 'addClass' : 'removeClass' ]('count-0');
136
 
                        updateCount( a, n );
137
 
                });
138
 
        };
139
 
 
140
300
        // In admin-ajax.php, we send back the unix time stamp instead of 1 on success
141
301
        delAfter = function( r, settings ) {
142
 
                var total_items_i18n, total, spam, trash, pending,
143
 
                        untrash = $(settings.target).parent().is('span.untrash'),
144
 
                        unspam = $(settings.target).parent().is('span.unspam'),
145
 
                        unapproved = $('#' + settings.element).is('.unapproved');
146
 
 
147
 
                function getUpdate(s) {
148
 
                        if ( $(settings.target).parent().is('span.' + s) )
149
 
                                return 1;
150
 
                        else if ( $('#' + settings.element).is('.' + s) )
151
 
                                return -1;
152
 
 
153
 
                        return 0;
154
 
                }
155
 
 
156
 
                if ( untrash )
157
 
                        trash = -1;
158
 
                else
159
 
                        trash = getUpdate('trash');
160
 
 
161
 
                if ( unspam )
162
 
                        spam = -1;
163
 
                else
164
 
                        spam = getUpdate('spam');
165
 
 
166
 
                if ( $(settings.target).parent().is('span.unapprove') || ( ( untrash || unspam ) && unapproved ) ) {
167
 
                        // a comment was 'deleted' from another list (e.g. approved, spam, trash) and moved to pending,
168
 
                        // or a trash/spam of a pending comment was undone
169
 
                        pending = 1;
170
 
                } else if ( unapproved ) {
171
 
                        // a pending comment was trashed/spammed/approved
172
 
                        pending = -1;
173
 
                }
174
 
 
175
 
                if ( pending )
176
 
                        updatePending(pending);
177
 
 
178
 
                $('span.spam-count').each( function() {
179
 
                        var a = $(this), n = getCount(a) + spam;
180
 
                        updateCount(a, n);
181
 
                });
182
 
 
183
 
                $('span.trash-count').each( function() {
184
 
                        var a = $(this), n = getCount(a) + trash;
185
 
                        updateCount(a, n);
186
 
                });
187
 
 
188
 
                if ( ! $('#dashboard_right_now').length ) {
 
302
                var total_items_i18n, total, animated, animatedCallback,
 
303
                        response = true === settings.parsed ? {} : settings.parsed.responses[0],
 
304
                        commentStatus = true === settings.parsed ? '' : response.supplemental.status,
 
305
                        commentPostId = true === settings.parsed ? '' : response.supplemental.postId,
 
306
                        newTotal = true === settings.parsed ? '' : response.supplemental,
 
307
 
 
308
                        targetParent = $( settings.target ).parent(),
 
309
                        commentRow = $('#' + settings.element),
 
310
 
 
311
                        spamDiff, trashDiff, pendingDiff, approvedDiff,
 
312
 
 
313
                        approved = commentRow.hasClass( 'approved' ),
 
314
                        unapproved = commentRow.hasClass( 'unapproved' ),
 
315
                        spammed = commentRow.hasClass( 'spam' ),
 
316
                        trashed = commentRow.hasClass( 'trash' );
 
317
 
 
318
                updateDashboardText( newTotal );
 
319
 
 
320
                // the order of these checks is important
 
321
                // .unspam can also have .approve or .unapprove
 
322
                // .untrash can also have .approve or .unapprove
 
323
 
 
324
                if ( targetParent.is( 'span.undo' ) ) {
 
325
                        // the comment was spammed
 
326
                        if ( targetParent.hasClass( 'unspam' ) ) {
 
327
                                spamDiff = -1;
 
328
 
 
329
                                if ( 'trash' === commentStatus ) {
 
330
                                        trashDiff = 1;
 
331
                                } else if ( '1' === commentStatus ) {
 
332
                                        approvedDiff = 1;
 
333
                                } else if ( '0' === commentStatus ) {
 
334
                                        pendingDiff = 1;
 
335
                                }
 
336
 
 
337
                        // the comment was trashed
 
338
                        } else if ( targetParent.hasClass( 'untrash' ) ) {
 
339
                                trashDiff = -1;
 
340
 
 
341
                                if ( 'spam' === commentStatus ) {
 
342
                                        spamDiff = 1;
 
343
                                } else if ( '1' === commentStatus ) {
 
344
                                        approvedDiff = 1;
 
345
                                } else if ( '0' === commentStatus ) {
 
346
                                        pendingDiff = 1;
 
347
                                }
 
348
                        }
 
349
 
 
350
                // user clicked "Spam"
 
351
                } else if ( targetParent.is( 'span.spam' ) ) {
 
352
                        // the comment is currently approved
 
353
                        if ( approved ) {
 
354
                                approvedDiff = -1;
 
355
                        // the comment is currently pending
 
356
                        } else if ( unapproved ) {
 
357
                                pendingDiff = -1;
 
358
                        // the comment was in the trash
 
359
                        } else if ( trashed ) {
 
360
                                trashDiff = -1;
 
361
                        }
 
362
                        // you can't spam an item on the spam screen
 
363
                        spamDiff = 1;
 
364
 
 
365
                // user clicked "Unspam"
 
366
                } else if ( targetParent.is( 'span.unspam' ) ) {
 
367
                        if ( approved ) {
 
368
                                pendingDiff = 1;
 
369
                        } else if ( unapproved ) {
 
370
                                approvedDiff = 1;
 
371
                        } else if ( trashed ) {
 
372
                                // the comment was previously approved
 
373
                                if ( targetParent.hasClass( 'approve' ) ) {
 
374
                                        approvedDiff = 1;
 
375
                                // the comment was previously pending
 
376
                                } else if ( targetParent.hasClass( 'unapprove' ) ) {
 
377
                                        pendingDiff = 1;
 
378
                                }
 
379
                        } else if ( spammed ) {
 
380
                                if ( targetParent.hasClass( 'approve' ) ) {
 
381
                                        approvedDiff = 1;
 
382
 
 
383
                                } else if ( targetParent.hasClass( 'unapprove' ) ) {
 
384
                                        pendingDiff = 1;
 
385
                                }
 
386
                        }
 
387
                        // you can Unspam an item on the spam screen
 
388
                        spamDiff = -1;
 
389
 
 
390
                // user clicked "Trash"
 
391
                } else if ( targetParent.is( 'span.trash' ) ) {
 
392
                        if ( approved ) {
 
393
                                approvedDiff = -1;
 
394
                        } else if ( unapproved ) {
 
395
                                pendingDiff = -1;
 
396
                        // the comment was in the spam queue
 
397
                        } else if ( spammed ) {
 
398
                                spamDiff = -1;
 
399
                        }
 
400
                        // you can't trash an item on the trash screen
 
401
                        trashDiff = 1;
 
402
 
 
403
                // user clicked "Restore"
 
404
                } else if ( targetParent.is( 'span.untrash' ) ) {
 
405
                        if ( approved ) {
 
406
                                pendingDiff = 1;
 
407
                        } else if ( unapproved ) {
 
408
                                approvedDiff = 1;
 
409
                        } else if ( trashed ) {
 
410
                                if ( targetParent.hasClass( 'approve' ) ) {
 
411
                                        approvedDiff = 1;
 
412
                                } else if ( targetParent.hasClass( 'unapprove' ) ) {
 
413
                                        pendingDiff = 1;
 
414
                                }
 
415
                        }
 
416
                        // you can't go from trash to spam
 
417
                        // you can untrash on the trash screen
 
418
                        trashDiff = -1;
 
419
 
 
420
                // User clicked "Approve"
 
421
                } else if ( targetParent.is( 'span.approve:not(.unspam):not(.untrash)' ) ) {
 
422
                        approvedDiff = 1;
 
423
                        pendingDiff = -1;
 
424
 
 
425
                // User clicked "Unapprove"
 
426
                } else if ( targetParent.is( 'span.unapprove:not(.unspam):not(.untrash)' ) ) {
 
427
                        approvedDiff = -1;
 
428
                        pendingDiff = 1;
 
429
 
 
430
                // User clicked "Delete Permanently"
 
431
                } else if ( targetParent.is( 'span.delete' ) ) {
 
432
                        if ( spammed ) {
 
433
                                spamDiff = -1;
 
434
                        } else if ( trashed ) {
 
435
                                trashDiff = -1;
 
436
                        }
 
437
                }
 
438
 
 
439
                if ( pendingDiff ) {
 
440
                        updatePending( pendingDiff, commentPostId );
 
441
                        updateCountText( 'span.all-count', pendingDiff );
 
442
                }
 
443
 
 
444
                if ( approvedDiff ) {
 
445
                        updateApproved( approvedDiff, commentPostId );
 
446
                        updateCountText( 'span.all-count', approvedDiff );
 
447
                }
 
448
 
 
449
                if ( spamDiff ) {
 
450
                        updateCountText( 'span.spam-count', spamDiff );
 
451
                }
 
452
 
 
453
                if ( trashDiff ) {
 
454
                        updateCountText( 'span.trash-count', trashDiff );
 
455
                }
 
456
 
 
457
                if ( ! isDashboard ) {
189
458
                        total = totalInput.val() ? parseInt( totalInput.val(), 10 ) : 0;
190
459
                        if ( $(settings.target).parent().is('span.undo') )
191
460
                                total++;
195
464
                        if ( total < 0 )
196
465
                                total = 0;
197
466
 
198
 
                        if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) {
199
 
                                total_items_i18n = settings.parsed.responses[0].supplemental.total_items_i18n || '';
200
 
                                if ( total_items_i18n ) {
201
 
                                        $('.displaying-num').text( total_items_i18n );
202
 
                                        $('.total-pages').text( settings.parsed.responses[0].supplemental.total_pages_i18n );
203
 
                                        $('.tablenav-pages').find('.next-page, .last-page').toggleClass('disabled', settings.parsed.responses[0].supplemental.total_pages == $('.current-page').val());
 
467
                        if ( 'object' === typeof r ) {
 
468
                                if ( response.supplemental.total_items_i18n && lastConfidentTime < response.supplemental.time ) {
 
469
                                        total_items_i18n = response.supplemental.total_items_i18n || '';
 
470
                                        if ( total_items_i18n ) {
 
471
                                                $('.displaying-num').text( total_items_i18n );
 
472
                                                $('.total-pages').text( response.supplemental.total_pages_i18n );
 
473
                                                $('.tablenav-pages').find('.next-page, .last-page').toggleClass('disabled', response.supplemental.total_pages == $('.current-page').val());
 
474
                                        }
 
475
                                        updateTotalCount( total, response.supplemental.time, true );
 
476
                                } else if ( response.supplemental.time ) {
 
477
                                        updateTotalCount( total, response.supplemental.time, false );
204
478
                                }
205
 
                                updateTotalCount( total, settings.parsed.responses[0].supplemental.time, true );
206
479
                        } else {
207
480
                                updateTotalCount( total, r, false );
208
481
                        }
209
482
                }
210
483
 
211
 
                if ( ! theExtraList || theExtraList.size() === 0 || theExtraList.children().size() === 0 || untrash || unspam ) {
 
484
                if ( ! theExtraList || theExtraList.size() === 0 || theExtraList.children().size() === 0 ) {
212
485
                        return;
213
486
                }
214
487
 
215
 
                theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() );
 
488
                theList.get(0).wpList.add( theExtraList.children( ':eq(0):not(.no-items)' ).remove().clone() );
216
489
 
217
490
                refillTheExtraList();
 
491
 
 
492
                animated = $( ':animated', '#the-comment-list' );
 
493
                animatedCallback = function () {
 
494
                        if ( ! $( '#the-comment-list tr:visible' ).length ) {
 
495
                                theList.get(0).wpList.add( theExtraList.find( '.no-items' ).clone() );
 
496
                        }
 
497
                };
 
498
 
 
499
                if ( animated.length ) {
 
500
                        animated.promise().done( animatedCallback );
 
501
                } else {
 
502
                        animatedCallback();
 
503
                }
218
504
        };
219
505
 
220
506
        refillTheExtraList = function(ev) {
279
565
 
280
566
                $('a.cancel', row).click(function() { return commentReply.revert(); });
281
567
                $('a.save', row).click(function() { return commentReply.send(); });
282
 
                $('input#author, input#author-email, input#author-url', row).keypress(function(e){
 
568
                $( 'input#author-name, input#author-email, input#author-url', row ).keypress( function( e ) {
283
569
                        if ( e.which == 13 ) {
284
570
                                commentReply.send();
285
571
                                e.preventDefault();
373
659
                action = action || 'replyto';
374
660
                act = 'edit' == action ? 'edit' : 'replyto';
375
661
                act = t.act = act + '-comment';
376
 
                colspanVal = $( 'th:visible, td:visible', c ).length;
 
662
                colspanVal = $( '> th:visible, > td:visible', c ).length;
377
663
 
378
664
                // Make sure it's actually a table and there's a `colspan` value to apply.
379
665
                if ( editRow.hasClass( 'inline-edit-row' ) && 0 !== colspanVal ) {
385
671
                $('#comment_ID', editRow).val(comment_id);
386
672
 
387
673
                if ( action == 'edit' ) {
388
 
                        $('#author', editRow).val( $('div.author', rowData).text() );
 
674
                        $( '#author-name', editRow ).val( $( 'div.author', rowData ).text() );
389
675
                        $('#author-email', editRow).val( $('div.author-email', rowData).text() );
390
676
                        $('#author-url', editRow).val( $('div.author-url', rowData).text() );
391
677
                        $('#status', editRow).val( $('div.comment_status', rowData).text() );
392
678
                        $('#replycontent', editRow).val( $('textarea.comment', rowData).val() );
393
 
                        $('#edithead, #savebtn', editRow).show();
 
679
                        $( '#edithead, #editlegend, #savebtn', editRow ).show();
394
680
                        $('#replyhead, #replybtn, #addhead, #addbtn', editRow).hide();
395
681
 
396
682
                        if ( h > 120 ) {
405
691
                        });
406
692
                } else if ( action == 'add' ) {
407
693
                        $('#addhead, #addbtn', editRow).show();
408
 
                        $('#replyhead, #replybtn, #edithead, #savebtn', editRow).hide();
 
694
                        $( '#replyhead, #replybtn, #edithead, #editlegend, #savebtn', editRow ) .hide();
409
695
                        $('#the-comment-list').prepend(editRow);
410
696
                        $('#replyrow').fadeIn(300);
411
697
                } else {
412
698
                        replyButton = $('#replybtn', editRow);
413
 
                        $('#edithead, #savebtn, #addhead, #addbtn', editRow).hide();
 
699
                        $( '#edithead, #editlegend, #savebtn, #addhead, #addbtn', editRow ).hide();
414
700
                        $('#replyhead, #replybtn', editRow).show();
415
701
                        c.after(editRow);
416
702
 
500
786
 
501
787
                if ( r.supplemental.parent_approved ) {
502
788
                        pid = $('#comment-' + r.supplemental.parent_approved);
503
 
                        updatePending( -1 );
 
789
                        updatePending( -1, r.supplemental.parent_post_id );
504
790
 
505
791
                        if ( this.comments_listing == 'moderated' ) {
506
792
                                pid.animate( { 'backgroundColor':'#CCEEBB' }, 400, function(){
510
796
                        }
511
797
                }
512
798
 
 
799
                if ( r.supplemental.i18n_comments_text ) {
 
800
                        if ( isDashboard ) {
 
801
                                updateDashboardText( r.supplemental );
 
802
                        } else {
 
803
                                updateApproved( 1, r.supplemental.parent_post_id );
 
804
                                updateCountText( 'span.all-count', 1 );
 
805
                        }
 
806
                }
 
807
 
513
808
                c = $.trim(r.data); // Trim leading whitespaces
514
809
                $(c).hide();
515
810
                $('#replyrow').after(c);
559
854
 
560
855
        setCommentsList();
561
856
        commentReply.init();
562
 
        $(document).delegate('span.delete a.delete', 'click', function(){return false;});
 
857
 
 
858
        $(document).on( 'click', 'span.delete a.delete', function( e ) {
 
859
                e.preventDefault();
 
860
        });
563
861
 
564
862
        if ( typeof $.table_hotkeys != 'undefined' ) {
565
863
                make_hotkeys_redirect = function(which) {