Fix double avatars and JS errors when spamming/trashing comments.
Props avryl, SergeyBiryukov. Fixes #27329. git-svn-id: https://develop.svn.wordpress.org/trunk@27759 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6b9eccd1f0
commit
4b21dcc825
|
@ -2,7 +2,7 @@
|
|||
var setCommentsList, theList, theExtraList, commentReply;
|
||||
|
||||
(function($) {
|
||||
var getCount, updateCount, updatePending, dashboardTotals;
|
||||
var getCount, updateCount, updatePending;
|
||||
|
||||
setCommentsList = function() {
|
||||
var totalInput, perPageInput, pageInput, dimAfter, delBefore, updateTotalCount, delAfter, refillTheExtraList, diff,
|
||||
|
@ -79,7 +79,7 @@ setCommentsList = function() {
|
|||
a.attr('href', 'comment.php?action=un' + action + 'comment&c=' + id + '&_wpnonce=' + settings.data._ajax_nonce);
|
||||
a.attr('data-wp-lists', 'delete:the-comment-list:comment-' + id + '::un' + action + '=1');
|
||||
a.attr('class', 'vim-z vim-destructive');
|
||||
$('.avatar', el).clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside');
|
||||
$('.avatar', el).first().clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside');
|
||||
|
||||
a.click(function(){
|
||||
list.wpList.del(this);
|
||||
|
@ -105,24 +105,6 @@ setCommentsList = function() {
|
|||
totalInput.val( total.toString() );
|
||||
};
|
||||
|
||||
dashboardTotals = function(n) {
|
||||
var total, appr, totalN, apprN,
|
||||
dash = $('#dashboard_right_now');
|
||||
|
||||
n = n || 0;
|
||||
if ( isNaN(n) || !dash.length )
|
||||
return;
|
||||
|
||||
total = $('span.total-count', dash);
|
||||
appr = $('span.approved-count', dash);
|
||||
totalN = getCount(total);
|
||||
|
||||
totalN = totalN + n;
|
||||
apprN = totalN - getCount( $('span.pending-count', dash) ) - getCount( $('span.spam-count', dash) );
|
||||
updateCount(total, totalN);
|
||||
updateCount(appr, apprN);
|
||||
};
|
||||
|
||||
getCount = function(el) {
|
||||
var n = parseInt( el.html().replace(/[^0-9]+/g, ''), 10 );
|
||||
if ( isNaN(n) )
|
||||
|
@ -153,13 +135,11 @@ setCommentsList = function() {
|
|||
a.closest('.awaiting-mod')[ 0 === n ? 'addClass' : 'removeClass' ]('count-0');
|
||||
updateCount( a, n );
|
||||
});
|
||||
|
||||
dashboardTotals();
|
||||
};
|
||||
|
||||
// In admin-ajax.php, we send back the unix time stamp instead of 1 on success
|
||||
delAfter = function( r, settings ) {
|
||||
var total_items_i18n, total, N, spam, trash, pending,
|
||||
var total_items_i18n, total, spam, trash, pending,
|
||||
untrash = $(settings.target).parent().is('span.untrash'),
|
||||
unspam = $(settings.target).parent().is('span.unspam'),
|
||||
unapproved = $('#' + settings.element).is('.unapproved');
|
||||
|
@ -205,10 +185,7 @@ setCommentsList = function() {
|
|||
updateCount(a, n);
|
||||
});
|
||||
|
||||
if ( $('#dashboard_right_now').length ) {
|
||||
N = trash ? -1 * trash : 0;
|
||||
dashboardTotals(N);
|
||||
} else {
|
||||
if ( ! $('#dashboard_right_now').length ) {
|
||||
total = totalInput.val() ? parseInt( totalInput.val(), 10 ) : 0;
|
||||
if ( $(settings.target).parent().is('span.undo') )
|
||||
total++;
|
||||
|
|
|
@ -309,7 +309,11 @@ wpList = {
|
|||
},
|
||||
|
||||
add: function( e, s ) {
|
||||
e = $( $.trim(e) ); // Trim leading whitespaces
|
||||
if ( 'string' == typeof e ) {
|
||||
e = $( $.trim( e ) ); // Trim leading whitespaces
|
||||
} else {
|
||||
e = $( e );
|
||||
}
|
||||
|
||||
var list = $(this), old = false, _s = { pos: 0, id: 0, oldId: null }, ba, ref, color;
|
||||
|
||||
|
|
Loading…
Reference in New Issue