Fix incorrect pending comment count updates for filtered views. Fixes #19905.
Pass the difference (i.e. 1 or -1) to updatePending() so that the current pending count is changed for each element independently. Also move several functions back out of the global scope, see r17832 for their introduction. git-svn-id: http://svn.automattic.com/wordpress/trunk@19895 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
10222bac79
commit
0d06815963
|
@ -1,5 +1,7 @@
|
||||||
var theList, theExtraList, toggleWithKeyboard = false, getCount, updateCount, updatePending, dashboardTotals;
|
var theList, theExtraList, toggleWithKeyboard = false;
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
|
var getCount, updateCount, updatePending, dashboardTotals;
|
||||||
|
|
||||||
setCommentsList = function() {
|
setCommentsList = function() {
|
||||||
var totalInput, perPageInput, pageInput, lastConfidentTime = 0, dimAfter, delBefore, updateTotalCount, delAfter, refillTheExtraList;
|
var totalInput, perPageInput, pageInput, lastConfidentTime = 0, dimAfter, delBefore, updateTotalCount, delAfter, refillTheExtraList;
|
||||||
|
@ -27,25 +29,8 @@ setCommentsList = function() {
|
||||||
c.find('div.comment_status').html('1');
|
c.find('div.comment_status').html('1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$('span.pending-count').each( function() {
|
var diff = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1;
|
||||||
var a = $(this), n, dif;
|
updatePending( diff );
|
||||||
|
|
||||||
n = a.html().replace(/[^0-9]+/g, '');
|
|
||||||
n = parseInt(n, 10);
|
|
||||||
|
|
||||||
if ( isNaN(n) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
dif = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1;
|
|
||||||
n = n + dif;
|
|
||||||
|
|
||||||
if ( n < 0 )
|
|
||||||
n = 0;
|
|
||||||
|
|
||||||
a.closest('.awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
|
|
||||||
updateCount(a, n);
|
|
||||||
dashboardTotals();
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Send current total, page, per_page and url
|
// Send current total, page, per_page and url
|
||||||
|
@ -129,7 +114,6 @@ setCommentsList = function() {
|
||||||
apprN = totalN - getCount( $('span.pending-count', dash) ) - getCount( $('span.spam-count', dash) );
|
apprN = totalN - getCount( $('span.pending-count', dash) ) - getCount( $('span.spam-count', dash) );
|
||||||
updateCount(total, totalN);
|
updateCount(total, totalN);
|
||||||
updateCount(appr, apprN);
|
updateCount(appr, apprN);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
getCount = function(el) {
|
getCount = function(el) {
|
||||||
|
@ -154,17 +138,16 @@ setCommentsList = function() {
|
||||||
el.html(n);
|
el.html(n);
|
||||||
};
|
};
|
||||||
|
|
||||||
updatePending = function(n) {
|
updatePending = function( diff ) {
|
||||||
$('span.pending-count').each( function() {
|
$('span.pending-count').each(function() {
|
||||||
var a = $(this);
|
var a = $(this), n = getCount(a) + diff;
|
||||||
|
if ( n < 1 )
|
||||||
if ( n < 0 )
|
|
||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
a.closest('.awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
|
a.closest('.awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
|
||||||
updateCount(a, n);
|
updateCount( a, n );
|
||||||
dashboardTotals();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dashboardTotals();
|
||||||
};
|
};
|
||||||
|
|
||||||
// In admin-ajax.php, we send back the unix time stamp instead of 1 on success
|
// In admin-ajax.php, we send back the unix time stamp instead of 1 on success
|
||||||
|
@ -193,12 +176,13 @@ setCommentsList = function() {
|
||||||
else
|
else
|
||||||
spam = getUpdate('spam');
|
spam = getUpdate('spam');
|
||||||
|
|
||||||
pending = getCount( $('span.pending-count').eq(0) );
|
if ( $(settings.target).parent().is('span.unapprove') || ( ( untrash || unspam ) && unapproved ) ) {
|
||||||
|
// a comment was 'deleted' from another list (e.g. approved, spam, trash) and moved to pending,
|
||||||
if ( $(settings.target).parent().is('span.unapprove') || ( ( untrash || unspam ) && unapproved ) ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
|
// or a trash/spam of a pending comment was undone
|
||||||
pending = pending + 1;
|
pending = 1;
|
||||||
} else if ( unapproved ) { // we deleted a formerly unapproved comment
|
} else if ( unapproved ) {
|
||||||
pending = pending - 1;
|
// a pending comment was trashed/spammed/approved
|
||||||
|
pending = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePending(pending);
|
updatePending(pending);
|
||||||
|
@ -504,7 +488,7 @@ commentReply = {
|
||||||
|
|
||||||
if ( r.supplemental.parent_approved ) {
|
if ( r.supplemental.parent_approved ) {
|
||||||
pid = $('#comment-' + r.supplemental.parent_approved);
|
pid = $('#comment-' + r.supplemental.parent_approved);
|
||||||
updatePending( getCount( $('span.pending-count').eq(0) ) - 1 );
|
updatePending( -1 );
|
||||||
|
|
||||||
if ( this.comments_listing == 'moderated' ) {
|
if ( this.comments_listing == 'moderated' ) {
|
||||||
pid.animate( { 'backgroundColor':'#CCEEBB' }, 400, function(){
|
pid.animate( { 'backgroundColor':'#CCEEBB' }, 400, function(){
|
||||||
|
|
Loading…
Reference in New Issue