17
17
c.find('div.comment_status').html('1')
19
19
$('span.pending-count').each( function() {
21
n = a.html().replace(/[ ,.]+/g, '');
20
var a = $(this), n, dif;
21
n = a.html().replace(/[^0-9]+/g, '');
22
22
n = parseInt(n,10);
23
23
if ( isNaN(n) ) return;
24
n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 );
24
dif = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1;
25
26
if ( n < 0 ) { n = 0; }
26
a.parents('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
29
n = n.substr(0, n.length-3)+' '+n.substr(-3);
27
a.closest('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
34
33
// Send current total, page, per_page and url
35
delBefore = function( settings ) {
36
settings.data._total = totalInput.val();
37
settings.data._per_page = perPageInput.val();
38
settings.data._page = pageInput.val();
34
delBefore = function( settings, list ) {
35
var cl = $(settings.target).attr('className'), id, el, n, h, a, author, action = false;
37
settings.data._total = totalInput.val() || 0;
38
settings.data._per_page = perPageInput.val() || 0;
39
settings.data._page = pageInput.val() || 0;
39
40
settings.data._url = document.location.href;
41
if ( 'undefined' != showNotice && settings.data.action && settings.data.action == 'delete-comment' && !settings.data.spam )
42
return showNotice.warn() ? settings : false;
42
if ( cl.indexOf(':trash=1') != -1 )
44
else if ( cl.indexOf(':spam=1') != -1 )
48
id = cl.replace(/.*?comment-([0-9]+).*/, '$1');
49
el = $('#comment-' + id);
50
note = $('#' + action + '-undo-holder').html();
52
if ( el.siblings('#replyrow').length && commentReply.cid == id )
56
n = el.children(':visible').length;
57
author = $('.author strong', el).text();
58
h = $('<tr id="undo-' + id + '" class="undo un' + action + '" style="display:none;"><td colspan="' + n + '">' + note + '</td></tr>');
60
author = $('.comment-author', el).text();
61
h = $('<div id="undo-' + id + '" style="display:none;" class="undo un' + action + '">' + note + '</div>');
66
$('strong', '#undo-' + id).text(author + ' ');
67
a = $('.undo a', '#undo-' + id);
68
a.attr('href', 'comment.php?action=un' + action + 'comment&c=' + id + '&_wpnonce=' + settings.data._ajax_nonce);
69
a.attr('className', 'delete:the-comment-list:comment-' + id + '::un' + action + '=1 vim-z vim-destructive');
70
$('.avatar', el).clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside');
73
list.wpList.del(this);
74
$('#undo-' + id).css( {backgroundColor:'#ceb'} ).fadeOut(350, function(){
76
$('#comment-' + id).css('backgroundColor', '').fadeIn(300, function(){ $(this).show() });
47
/* Updates the current total (as displayed visibly)
85
// Updates the current total (as displayed visibly)
49
86
updateTotalCount = function( total, time, setConfidentTime ) {
50
if ( time < lastConfidentTime ) {
87
if ( time < lastConfidentTime )
90
if ( setConfidentTime )
91
lastConfidentTime = time;
53
93
totalInput.val( total.toString() );
54
if ( setConfidentTime ) {
55
lastConfidentTime = time;
57
94
$('span.total-type-count').each( function() {
59
n = totalInput.val().toString();
61
n = n.substr(0, n.length-3)+' '+n.substr(-3);
95
updateCount( $(this), total );
99
function dashboardTotals(n) {
100
var dash = $('#dashboard_right_now'), total, appr, totalN, apprN;
103
if ( isNaN(n) || !dash.length )
106
total = $('span.total-count', dash);
107
appr = $('span.approved-count', dash);
108
totalN = getCount(total);
111
apprN = totalN - getCount( $('span.pending-count', dash) ) - getCount( $('span.spam-count', dash) );
112
updateCount(total, totalN);
113
updateCount(appr, apprN);
117
function getCount(el) {
118
var n = parseInt( el.html().replace(/[^0-9]+/g, ''), 10 );
124
function updateCount(el, n) {
128
n = n < 1 ? '0' : n.toString();
129
if ( n.length > 3 ) {
130
while ( n.length > 3 ) {
131
n1 = thousandsSeparator + n.substr(n.length - 3) + n1;
132
n = n.substr(0, n.length - 3);
67
139
// In admin-ajax.php, we send back the unix time stamp instead of 1 on success
68
140
delAfter = function( r, settings ) {
141
var total, pageLinks, N, untrash = $(settings.target).parent().is('span.untrash'), unspam = $(settings.target).parent().is('span.unspam'), spam, trash;
143
function getUpdate(s) {
144
if ( $(settings.target).parent().is('span.' + s) )
146
else if ( $('#' + settings.element).is('.' + s) )
151
spam = getUpdate('spam');
152
trash = getUpdate('trash');
69
159
$('span.pending-count').each( function() {
71
n = a.html().replace(/[ ,.]+/g, '');
73
if ( isNaN(n) ) return;
74
if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment
160
var a = $(this), n = getCount(a), unapproved = $('#' + settings.element).is('.unapproved');
162
if ( $(settings.target).parent().is('span.unapprove') || ( ( untrash || unspam ) && unapproved ) ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
164
} else if ( unapproved ) { // we deleted a formerly unapproved comment
76
} else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
79
167
if ( n < 0 ) { n = 0; }
80
a.parents('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
83
n = n.substr(0, n.length-3)+' '+n.substr(-3);
168
a.closest('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
87
173
$('span.spam-count').each( function() {
89
n = a.html().replace(/[ ,.]+/g, '');
91
if ( isNaN(n) ) return;
92
if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam
94
} else if ( $('#' + settings.element).is('.spam') ) { // we approved or deleted a comment marked as spam
97
if ( n < 0 ) { n = 0; }
100
n = n.substr(0, n.length-3)+' '+n.substr(-3);
106
if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) {
107
// Set the total to the known good value (even if this value is a little old, newer values should only be a few less, and so shouldn't mess up the page links)
108
updateTotalCount( settings.parsed.responses[0].supplemental.total, settings.parsed.responses[0].supplemental.time, true );
109
if ( $.trim( settings.parsed.responses[0].supplemental.pageLinks ) ) {
110
$('.tablenav-pages').find( '.page-numbers' ).remove().end().append( $( settings.parsed.responses[0].supplemental.pageLinks ) );
111
} else if ( 'undefined' != typeof settings.parsed.responses[0].supplemental.pageLinks ) {
112
$('.tablenav-pages').find( '.page-numbers' ).remove();
174
var a = $(this), n = getCount(a) + spam;
178
$('span.trash-count').each( function() {
179
var a = $(this), n = getCount(a) + trash;
183
if ( $('#dashboard_right_now').length ) {
184
N = trash ? -1 * trash : 0;
115
// Decrement the total
116
var total = parseInt( totalInput.val(), 10 );
187
total = totalInput.val() ? parseInt( totalInput.val(), 10 ) : 0;
188
total = total - spam - trash;
119
updateTotalCount( total, r, false );
192
if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) {
193
pageLinks = settings.parsed.responses[0].supplemental.pageLinks || '';
194
if ( $.trim( pageLinks ) )
195
$('.tablenav-pages').find( '.page-numbers' ).remove().end().append( $( pageLinks ) );
197
$('.tablenav-pages').find( '.page-numbers' ).remove();
199
updateTotalCount( total, settings.parsed.responses[0].supplemental.time, true );
201
updateTotalCount( total, r, false );
122
if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) {
205
if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 || untrash ) {
189
279
close : function() {
190
$(this.o).fadeIn('fast').css('backgroundColor', '');
191
$('#com-reply').append( $('#replyrow') );
192
$('#replycontent').val('');
193
$('#edithead input').val('');
194
$('#replysubmit .error').html('').hide();
195
$('#replysubmit .waiting').hide();
196
if ( $.browser.msie )
197
$('#replycontainer, #replycontent').css('height', '120px');
199
$('#replycontainer').resizable('destroy').css('height', '120px');
283
c = $('#comment-' + this.cid);
285
if ( this.act == 'edit-comment' )
286
c.fadeIn(300, function(){ c.show() }).css('backgroundColor', '');
288
$('#replyrow').hide();
289
$('#com-reply').append( $('#replyrow') );
290
$('#replycontent').val('');
291
$('input', '#edithead').val('');
292
$('.error', '#replysubmit').html('').hide();
293
$('.waiting', '#replysubmit').hide();
295
if ( $.browser.msie )
296
$('#replycontainer, #replycontent').css('height', '120px');
298
$('#replycontainer').resizable('destroy').css('height', '120px');
202
304
open : function(id, p, a) {
203
var t = this, editRow, act, h;
305
var t = this, editRow, rowData, act, h, c = $('#comment-' + id);
205
t.o = '#comment-'+id;
207
$('#replyrow td').attr('colspan', $('.widefat thead th:visible').length);
208
editRow = $('#replyrow'), rowData = $('#inline-'+id);
309
$('td', '#replyrow').attr('colspan', $('table.widefat thead th:visible').length);
310
editRow = $('#replyrow');
311
rowData = $('#inline-'+id);
209
312
act = t.act = (a == 'edit') ? 'edit-comment' : 'replyto-comment';
211
314
$('#action', editRow).val(act);
364
467
window.location = l[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g, '')+'&hotkeys_highlight_'+first_last+'=1';
367
471
edit_comment = function(event, current_row) {
368
472
window.location = $('span.edit a', current_row).attr('href');
370
475
toggle_all = function() {
371
476
toggleWithKeyboard = true;
372
$('#comments-form thead #cb input:checkbox').click().attr('checked', '');
477
$('input:checkbox', '#cb').click().attr('checked', '');
373
478
toggleWithKeyboard = false;
375
481
make_bulk = function(value) {
376
return function(event, _) {
377
$('option[value='+value+']').attr('selected', 'selected');
378
$('form#comments-form')[0].submit();
483
var scope = $('select[name="action"]');
484
$('option[value='+value+']', scope).attr('selected', 'selected');
485
$('#comments-form').submit();
381
$.table_hotkeys($('table.widefat'),['a', 'u', 's', 'd', 'r', 'q', ['e', edit_comment],
382
['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')],
383
['shift+d', make_bulk('delete')], ['shift+x', toggle_all],
384
['shift+u', make_bulk('unapprove')]],
385
{highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last,
386
prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next')}
491
['a', 'u', 's', 'd', 'r', 'q', 'z', ['e', edit_comment], ['shift+x', toggle_all],
492
['shift+a', make_bulk('approve')], ['shift+s', make_bulk('markspam')],
493
['shift+d', make_bulk('delete')], ['shift+t', make_bulk('trash')],
494
['shift+z', make_bulk('untrash')], ['shift+u', make_bulk('unapprove')]],
495
{ highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last,
496
prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next') }