Changeset 19895
- Timestamp:
- 02/09/2012 11:29:24 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/js/edit-comments.dev.js
r19804 r19895 1 var theList, theExtraList, toggleWithKeyboard = false, getCount, updateCount, updatePending, dashboardTotals; 1 var theList, theExtraList, toggleWithKeyboard = false; 2 2 3 (function($) { 4 var getCount, updateCount, updatePending, dashboardTotals; 3 5 4 6 setCommentsList = function() { … … 28 30 } 29 31 30 $('span.pending-count').each( function() { 31 var a = $(this), n, dif; 32 33 n = a.html().replace(/[^0-9]+/g, ''); 34 n = parseInt(n, 10); 35 36 if ( isNaN(n) ) 37 return; 38 39 dif = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1; 40 n = n + dif; 41 42 if ( n < 0 ) 43 n = 0; 44 45 a.closest('.awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); 46 updateCount(a, n); 47 dashboardTotals(); 48 }); 32 var diff = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1; 33 updatePending( diff ); 49 34 }; 50 35 … … 130 115 updateCount(total, totalN); 131 116 updateCount(appr, apprN); 132 133 117 }; 134 118 … … 155 139 }; 156 140 157 updatePending = function(n) { 158 $('span.pending-count').each( function() { 159 var a = $(this); 160 161 if ( n < 0 ) 141 updatePending = function( diff ) { 142 $('span.pending-count').each(function() { 143 var a = $(this), n = getCount(a) + diff; 144 if ( n < 1 ) 162 145 n = 0; 163 164 146 a.closest('.awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); 165 updateCount(a, n); 166 dashboardTotals(); 167 }); 147 updateCount( a, n ); 148 }); 149 150 dashboardTotals(); 168 151 }; 169 152 … … 194 177 spam = getUpdate('spam'); 195 178 196 pending = getCount( $('span.pending-count').eq(0) ); 197 198 if ( $(settings.target).parent().is('span.unapprove') || ( ( untrash || unspam ) && unapproved ) ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove" 199 pending = pending + 1; 200 } else if ( unapproved ) { // we deleted a formerly unapproved comment 201 pending = pending - 1; 179 if ( $(settings.target).parent().is('span.unapprove') || ( ( untrash || unspam ) && unapproved ) ) { 180 // a comment was 'deleted' from another list (e.g. approved, spam, trash) and moved to pending, 181 // or a trash/spam of a pending comment was undone 182 pending = 1; 183 } else if ( unapproved ) { 184 // a pending comment was trashed/spammed/approved 185 pending = -1; 202 186 } 203 187 … … 505 489 if ( r.supplemental.parent_approved ) { 506 490 pid = $('#comment-' + r.supplemental.parent_approved); 507 updatePending( getCount( $('span.pending-count').eq(0) ) -1 );491 updatePending( -1 ); 508 492 509 493 if ( this.comments_listing == 'moderated' ) {
Note: See TracChangeset
for help on using the changeset viewer.