]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/js/edit-comments.js
WordPress 3.9
[autoinstalls/wordpress.git] / wp-admin / js / edit-comments.js
index 97415012eb8410c597a3ae4b97d806859928e4c7..ff149e19dcca6e58c885a423216b245a94f82e52 100644 (file)
@@ -1,9 +1,8 @@
 /* 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,
@@ -80,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);
@@ -106,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) )
@@ -154,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');
@@ -206,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++;
@@ -594,9 +570,7 @@ $(document).ready(function(){
                };
 
                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) {
@@ -609,12 +583,28 @@ $(document).ready(function(){
 
                $.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"]'
+                               }
+                       }
                );
        }
 });