/* global adminCommentsL10n, thousandsSeparator, list_args, QTags, ajaxurl, wpAjax */
-var setCommentsList, theList, theExtraList, commentReply,
- toggleWithKeyboard = false;
+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,
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);
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) )
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');
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++;
};
toggle_all = function() {
- toggleWithKeyboard = true;
- $('input:checkbox', '#cb').click().prop('checked', false);
- toggleWithKeyboard = false;
+ $('#cb-select-all-1').data( 'wp-toggle', 1 ).trigger( 'click' ).removeData( 'wp-toggle' );
};
make_bulk = function(value) {
$.table_hotkeys(
$('table.widefat'),
- ['a', 'u', 's', 'd', 'r', 'q', 'z', ['e', edit_comment], ['shift+x', toggle_all],
- ['shift+a', make_bulk('approve')], ['shift+s', make_bulk('spam')],
- ['shift+d', make_bulk('delete')], ['shift+t', make_bulk('trash')],
- ['shift+z', make_bulk('untrash')], ['shift+u', make_bulk('unapprove')]],
- { highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last,
- prev_page_link_cb: make_hotkeys_redirect('prev'), next_page_link_cb: make_hotkeys_redirect('next') }
+ [
+ 'a', 'u', 's', 'd', 'r', 'q', 'z',
+ ['e', edit_comment],
+ ['shift+x', toggle_all],
+ ['shift+a', make_bulk('approve')],
+ ['shift+s', make_bulk('spam')],
+ ['shift+d', make_bulk('delete')],
+ ['shift+t', make_bulk('trash')],
+ ['shift+z', make_bulk('untrash')],
+ ['shift+u', make_bulk('unapprove')]
+ ],
+ {
+ highlight_first: adminCommentsL10n.hotkeys_highlight_first,
+ highlight_last: adminCommentsL10n.hotkeys_highlight_last,
+ prev_page_link_cb: make_hotkeys_redirect('prev'),
+ next_page_link_cb: make_hotkeys_redirect('next'),
+ hotkeys_opts: {
+ disableInInput: true,
+ type: 'keypress',
+ noDisable: '.check-column input[type="checkbox"]'
+ }
+ }
);
}
});