]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/js/edit-comments.js
Wordpress 4.6
[autoinstalls/wordpress.git] / wp-admin / js / edit-comments.js
index 97415012eb8410c597a3ae4b97d806859928e4c7..3de031022cb37766c87e766de66e71de18660d2f 100644 (file)
@@ -1,9 +1,188 @@
 /* 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, updateCountText, updatePending, updateApproved,
+       updateHtmlTitle, updateDashboardText, adminTitle = document.title,
+       isDashboard = $('#dashboard_right_now').length,
+       titleDiv, titleRegEx;
+
+       getCount = function(el) {
+               var n = parseInt( el.html().replace(/[^0-9]+/g, ''), 10 );
+               if ( isNaN(n) ) {
+                       return 0;
+               }
+               return n;
+       };
+
+       updateCount = function(el, n) {
+               var n1 = '';
+               if ( isNaN(n) ) {
+                       return;
+               }
+               n = n < 1 ? '0' : n.toString();
+               if ( n.length > 3 ) {
+                       while ( n.length > 3 ) {
+                               n1 = thousandsSeparator + n.substr(n.length - 3) + n1;
+                               n = n.substr(0, n.length - 3);
+                       }
+                       n = n + n1;
+               }
+               el.html(n);
+       };
+
+       updateApproved = function( diff, commentPostId ) {
+               var postSelector = '.post-com-count-' + commentPostId,
+                       noClass = 'comment-count-no-comments',
+                       approvedClass = 'comment-count-approved',
+                       approved,
+                       noComments;
+
+               updateCountText( 'span.approved-count', diff );
+
+               if ( ! commentPostId ) {
+                       return;
+               }
+
+               // cache selectors to not get dupes
+               approved = $( 'span.' + approvedClass, postSelector );
+               noComments = $( 'span.' + noClass, postSelector );
+
+               approved.each(function() {
+                       var a = $(this), n = getCount(a) + diff;
+                       if ( n < 1 )
+                               n = 0;
+
+                       if ( 0 === n ) {
+                               a.removeClass( approvedClass ).addClass( noClass );
+                       } else {
+                               a.addClass( approvedClass ).removeClass( noClass );
+                       }
+                       updateCount( a, n );
+               });
+
+               noComments.each(function() {
+                       var a = $(this);
+                       if ( diff > 0 ) {
+                               a.removeClass( noClass ).addClass( approvedClass );
+                       } else {
+                               a.addClass( noClass ).removeClass( approvedClass );
+                       }
+                       updateCount( a, diff );
+               });
+       };
+
+       updateCountText = function( selector, diff ) {
+               $( selector ).each(function() {
+                       var a = $(this), n = getCount(a) + diff;
+                       if ( n < 1 ) {
+                               n = 0;
+                       }
+                       updateCount( a, n );
+               });
+       };
+
+       updateDashboardText = function ( response ) {
+               if ( ! isDashboard || ! response || ! response.i18n_comments_text ) {
+                       return;
+               }
+
+               var rightNow = $( '#dashboard_right_now' );
+
+               $( '.comment-count a', rightNow ).text( response.i18n_comments_text );
+               $( '.comment-mod-count a', rightNow ).text( response.i18n_moderation_text )
+                       .parent()
+                       [ response.in_moderation > 0 ? 'removeClass' : 'addClass' ]( 'hidden' );
+       };
+
+       updateHtmlTitle = function ( diff ) {
+               var newTitle, regExMatch, titleCount, commentFrag;
+
+               titleRegEx = titleRegEx || new RegExp( adminCommentsL10n.docTitleCommentsCount.replace( '%s', '\\([0-9' + thousandsSeparator + ']+\\)' ) + '?' );
+               // count funcs operate on a $'d element
+               titleDiv = titleDiv || $( '<div />' );
+               newTitle = adminTitle;
+
+               commentFrag = titleRegEx.exec( document.title );
+               if ( commentFrag ) {
+                       commentFrag = commentFrag[0];
+                       titleDiv.html( commentFrag );
+                       titleCount = getCount( titleDiv ) + diff;
+               } else {
+                       titleDiv.html( 0 );
+                       titleCount = diff;
+               }
+
+               if ( titleCount >= 1 ) {
+                       updateCount( titleDiv, titleCount );
+                       regExMatch = titleRegEx.exec( document.title );
+                       if ( regExMatch ) {
+                               newTitle = document.title.replace( regExMatch[0], adminCommentsL10n.docTitleCommentsCount.replace( '%s', titleDiv.text() ) + ' ' );
+                       }
+               } else {
+                       regExMatch = titleRegEx.exec( newTitle );
+                       if ( regExMatch ) {
+                               newTitle = newTitle.replace( regExMatch[0], adminCommentsL10n.docTitleComments );
+                       }
+               }
+               document.title = newTitle;
+       };
+
+       updatePending = function( diff, commentPostId ) {
+               var postSelector = '.post-com-count-' + commentPostId,
+                       noClass = 'comment-count-no-pending',
+                       noParentClass = 'post-com-count-no-pending',
+                       pendingClass = 'comment-count-pending',
+                       pending,
+                       noPending;
+
+               if ( ! isDashboard ) {
+                       updateHtmlTitle( diff );
+               }
+
+               $( 'span.pending-count' ).each(function() {
+                       var a = $(this), n = getCount(a) + diff;
+                       if ( n < 1 )
+                               n = 0;
+                       a.closest('.awaiting-mod')[ 0 === n ? 'addClass' : 'removeClass' ]('count-0');
+                       updateCount( a, n );
+               });
+
+               if ( ! commentPostId ) {
+                       return;
+               }
+
+               // cache selectors to not get dupes
+               pending = $( 'span.' + pendingClass, postSelector );
+               noPending = $( 'span.' + noClass, postSelector );
+
+               pending.each(function() {
+                       var a = $(this), n = getCount(a) + diff;
+                       if ( n < 1 )
+                               n = 0;
+
+                       if ( 0 === n ) {
+                               a.parent().addClass( noParentClass );
+                               a.removeClass( pendingClass ).addClass( noClass );
+                       } else {
+                               a.parent().removeClass( noParentClass );
+                               a.addClass( pendingClass ).removeClass( noClass );
+                       }
+                       updateCount( a, n );
+               });
+
+               noPending.each(function() {
+                       var a = $(this);
+                       if ( diff > 0 ) {
+                               a.parent().removeClass( noParentClass );
+                               a.removeClass( noClass ).addClass( pendingClass );
+                       } else {
+                               a.parent().addClass( noParentClass );
+                               a.addClass( noClass ).removeClass( pendingClass );
+                       }
+                       updateCount( a, diff );
+               });
+       };
 
 setCommentsList = function() {
        var totalInput, perPageInput, pageInput, dimAfter, delBefore, updateTotalCount, delAfter, refillTheExtraList, diff,
@@ -13,10 +192,26 @@ setCommentsList = function() {
        perPageInput = $('input[name="_per_page"]', '#comments-form');
        pageInput = $('input[name="_page"]', '#comments-form');
 
+       // Updates the current total (stored in the _total input)
+       updateTotalCount = function( total, time, setConfidentTime ) {
+               if ( time < lastConfidentTime )
+                       return;
+
+               if ( setConfidentTime )
+                       lastConfidentTime = time;
+
+               totalInput.val( total.toString() );
+       };
+
+       // this fires when viewing "All"
        dimAfter = function( r, settings ) {
-               var editRow, replyID, replyButton,
+               var editRow, replyID, replyButton, response,
                        c = $( '#' + settings.element );
 
+               if ( true !== settings.parsed ) {
+                       response = settings.parsed.responses[0];
+               }
+
                editRow = $('#replyrow');
                replyID = $('#comment_ID', editRow).val();
                replyButton = $('#replybtn', editRow);
@@ -25,16 +220,26 @@ setCommentsList = function() {
                        if ( settings.data.id == replyID )
                                replyButton.text(adminCommentsL10n.replyApprove);
 
-                       c.find('div.comment_status').html('0');
+                       c.find( '.row-actions span.view' ).addClass( 'hidden' ).end()
+                               .find( 'div.comment_status' ).html( '0' );
+
                } else {
                        if ( settings.data.id == replyID )
                                replyButton.text(adminCommentsL10n.reply);
 
-                       c.find('div.comment_status').html('1');
+                       c.find( '.row-actions span.view' ).removeClass( 'hidden' ).end()
+                               .find( 'div.comment_status' ).html( '1' );
                }
 
                diff = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1;
-               updatePending( diff );
+               if ( response ) {
+                       updateDashboardText( response.supplemental );
+                       updatePending( diff, response.supplemental.postId );
+                       updateApproved( -1 * diff, response.supplemental.postId );
+               } else {
+                       updatePending( diff );
+                       updateApproved( -1 * diff  );
+               }
        };
 
        // Send current total, page, per_page and url
@@ -80,136 +285,183 @@ 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(){
+                       a.click(function( e ){
+                               e.preventDefault();
+                               e.stopPropagation(); // ticket #35904
                                list.wpList.del(this);
                                $('#undo-' + id).css( {backgroundColor:'#ceb'} ).fadeOut(350, function(){
                                        $(this).remove();
                                        $('#comment-' + id).css('backgroundColor', '').fadeIn(300, function(){ $(this).show(); });
                                });
-                               return false;
                        });
                }
 
                return settings;
        };
 
-       // Updates the current total (stored in the _total input)
-       updateTotalCount = function( total, time, setConfidentTime ) {
-               if ( time < lastConfidentTime )
-                       return;
-
-               if ( setConfidentTime )
-                       lastConfidentTime = time;
-
-               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;
+       // 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, animated, animatedCallback,
+                       response = true === settings.parsed ? {} : settings.parsed.responses[0],
+                       commentStatus = true === settings.parsed ? '' : response.supplemental.status,
+                       commentPostId = true === settings.parsed ? '' : response.supplemental.postId,
+                       newTotal = true === settings.parsed ? '' : response.supplemental,
+
+                       targetParent = $( settings.target ).parent(),
+                       commentRow = $('#' + settings.element),
+
+                       spamDiff, trashDiff, pendingDiff, approvedDiff,
+
+                       approved = commentRow.hasClass( 'approved' ),
+                       unapproved = commentRow.hasClass( 'unapproved' ),
+                       spammed = commentRow.hasClass( 'spam' ),
+                       trashed = commentRow.hasClass( 'trash' ),
+                       undoing = false; // ticket #35904
+
+               updateDashboardText( newTotal );
+
+               // the order of these checks is important
+               // .unspam can also have .approve or .unapprove
+               // .untrash can also have .approve or .unapprove
+
+               if ( targetParent.is( 'span.undo' ) ) {
+                       // the comment was spammed
+                       if ( targetParent.hasClass( 'unspam' ) ) {
+                               spamDiff = -1;
+
+                               if ( 'trash' === commentStatus ) {
+                                       trashDiff = 1;
+                               } else if ( '1' === commentStatus ) {
+                                       approvedDiff = 1;
+                               } else if ( '0' === commentStatus ) {
+                                       pendingDiff = 1;
+                               }
 
-               total = $('span.total-count', dash);
-               appr = $('span.approved-count', dash);
-               totalN = getCount(total);
+                       // the comment was trashed
+                       } else if ( targetParent.hasClass( 'untrash' ) ) {
+                               trashDiff = -1;
 
-               totalN = totalN + n;
-               apprN = totalN - getCount( $('span.pending-count', dash) ) - getCount( $('span.spam-count', dash) );
-               updateCount(total, totalN);
-               updateCount(appr, apprN);
-       };
+                               if ( 'spam' === commentStatus ) {
+                                       spamDiff = 1;
+                               } else if ( '1' === commentStatus ) {
+                                       approvedDiff = 1;
+                               } else if ( '0' === commentStatus ) {
+                                       pendingDiff = 1;
+                               }
+                       }
 
-       getCount = function(el) {
-               var n = parseInt( el.html().replace(/[^0-9]+/g, ''), 10 );
-               if ( isNaN(n) )
-                       return 0;
-               return n;
-       };
+                       undoing = true;
+
+               // user clicked "Spam"
+               } else if ( targetParent.is( 'span.spam' ) ) {
+                       // the comment is currently approved
+                       if ( approved ) {
+                               approvedDiff = -1;
+                       // the comment is currently pending
+                       } else if ( unapproved ) {
+                               pendingDiff = -1;
+                       // the comment was in the trash
+                       } else if ( trashed ) {
+                               trashDiff = -1;
+                       }
+                       // you can't spam an item on the spam screen
+                       spamDiff = 1;
+
+               // user clicked "Unspam"
+               } else if ( targetParent.is( 'span.unspam' ) ) {
+                       if ( approved ) {
+                               pendingDiff = 1;
+                       } else if ( unapproved ) {
+                               approvedDiff = 1;
+                       } else if ( trashed ) {
+                               // the comment was previously approved
+                               if ( targetParent.hasClass( 'approve' ) ) {
+                                       approvedDiff = 1;
+                               // the comment was previously pending
+                               } else if ( targetParent.hasClass( 'unapprove' ) ) {
+                                       pendingDiff = 1;
+                               }
+                       } else if ( spammed ) {
+                               if ( targetParent.hasClass( 'approve' ) ) {
+                                       approvedDiff = 1;
 
-       updateCount = function(el, n) {
-               var n1 = '';
-               if ( isNaN(n) )
-                       return;
-               n = n < 1 ? '0' : n.toString();
-               if ( n.length > 3 ) {
-                       while ( n.length > 3 ) {
-                               n1 = thousandsSeparator + n.substr(n.length - 3) + n1;
-                               n = n.substr(0, n.length - 3);
+                               } else if ( targetParent.hasClass( 'unapprove' ) ) {
+                                       pendingDiff = 1;
+                               }
+                       }
+                       // you can Unspam an item on the spam screen
+                       spamDiff = -1;
+
+               // user clicked "Trash"
+               } else if ( targetParent.is( 'span.trash' ) ) {
+                       if ( approved ) {
+                               approvedDiff = -1;
+                       } else if ( unapproved ) {
+                               pendingDiff = -1;
+                       // the comment was in the spam queue
+                       } else if ( spammed ) {
+                               spamDiff = -1;
+                       }
+                       // you can't trash an item on the trash screen
+                       trashDiff = 1;
+
+               // user clicked "Restore"
+               } else if ( targetParent.is( 'span.untrash' ) ) {
+                       if ( approved ) {
+                               pendingDiff = 1;
+                       } else if ( unapproved ) {
+                               approvedDiff = 1;
+                       } else if ( trashed ) {
+                               if ( targetParent.hasClass( 'approve' ) ) {
+                                       approvedDiff = 1;
+                               } else if ( targetParent.hasClass( 'unapprove' ) ) {
+                                       pendingDiff = 1;
+                               }
+                       }
+                       // you can't go from trash to spam
+                       // you can untrash on the trash screen
+                       trashDiff = -1;
+
+               // User clicked "Approve"
+               } else if ( targetParent.is( 'span.approve:not(.unspam):not(.untrash)' ) ) {
+                       approvedDiff = 1;
+                       pendingDiff = -1;
+
+               // User clicked "Unapprove"
+               } else if ( targetParent.is( 'span.unapprove:not(.unspam):not(.untrash)' ) ) {
+                       approvedDiff = -1;
+                       pendingDiff = 1;
+
+               // User clicked "Delete Permanently"
+               } else if ( targetParent.is( 'span.delete' ) ) {
+                       if ( spammed ) {
+                               spamDiff = -1;
+                       } else if ( trashed ) {
+                               trashDiff = -1;
                        }
-                       n = n + n1;
                }
-               el.html(n);
-       };
 
-       updatePending = function( diff ) {
-               $('span.pending-count').each(function() {
-                       var a = $(this), n = getCount(a) + diff;
-                       if ( n < 1 )
-                               n = 0;
-                       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,
-                       untrash = $(settings.target).parent().is('span.untrash'),
-                       unspam = $(settings.target).parent().is('span.unspam'),
-                       unapproved = $('#' + settings.element).is('.unapproved');
-
-               function getUpdate(s) {
-                       if ( $(settings.target).parent().is('span.' + s) )
-                               return 1;
-                       else if ( $('#' + settings.element).is('.' + s) )
-                               return -1;
-
-                       return 0;
+               if ( pendingDiff ) {
+                       updatePending( pendingDiff, commentPostId );
+                       updateCountText( 'span.all-count', pendingDiff );
                }
 
-               if ( untrash )
-                       trash = -1;
-               else
-                       trash = getUpdate('trash');
-
-               if ( unspam )
-                       spam = -1;
-               else
-                       spam = getUpdate('spam');
-
-               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,
-                       // or a trash/spam of a pending comment was undone
-                       pending = 1;
-               } else if ( unapproved ) {
-                       // a pending comment was trashed/spammed/approved
-                       pending = -1;
+               if ( approvedDiff ) {
+                       updateApproved( approvedDiff, commentPostId );
+                       updateCountText( 'span.all-count', approvedDiff );
                }
 
-               if ( pending )
-                       updatePending(pending);
-
-               $('span.spam-count').each( function() {
-                       var a = $(this), n = getCount(a) + spam;
-                       updateCount(a, n);
-               });
+               if ( spamDiff ) {
+                       updateCountText( 'span.spam-count', spamDiff );
+               }
 
-               $('span.trash-count').each( function() {
-                       var a = $(this), n = getCount(a) + trash;
-                       updateCount(a, n);
-               });
+               if ( trashDiff ) {
+                       updateCountText( 'span.trash-count', trashDiff );
+               }
 
-               if ( $('#dashboard_right_now').length ) {
-                       N = trash ? -1 * trash : 0;
-                       dashboardTotals(N);
-               } else {
+               if ( ! isDashboard ) {
                        total = totalInput.val() ? parseInt( totalInput.val(), 10 ) : 0;
                        if ( $(settings.target).parent().is('span.undo') )
                                total++;
@@ -219,26 +471,43 @@ setCommentsList = function() {
                        if ( total < 0 )
                                total = 0;
 
-                       if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) {
-                               total_items_i18n = settings.parsed.responses[0].supplemental.total_items_i18n || '';
-                               if ( total_items_i18n ) {
-                                       $('.displaying-num').text( total_items_i18n );
-                                       $('.total-pages').text( settings.parsed.responses[0].supplemental.total_pages_i18n );
-                                       $('.tablenav-pages').find('.next-page, .last-page').toggleClass('disabled', settings.parsed.responses[0].supplemental.total_pages == $('.current-page').val());
+                       if ( 'object' === typeof r ) {
+                               if ( response.supplemental.total_items_i18n && lastConfidentTime < response.supplemental.time ) {
+                                       total_items_i18n = response.supplemental.total_items_i18n || '';
+                                       if ( total_items_i18n ) {
+                                               $('.displaying-num').text( total_items_i18n );
+                                               $('.total-pages').text( response.supplemental.total_pages_i18n );
+                                               $('.tablenav-pages').find('.next-page, .last-page').toggleClass('disabled', response.supplemental.total_pages == $('.current-page').val());
+                                       }
+                                       updateTotalCount( total, response.supplemental.time, true );
+                               } else if ( response.supplemental.time ) {
+                                       updateTotalCount( total, response.supplemental.time, false );
                                }
-                               updateTotalCount( total, settings.parsed.responses[0].supplemental.time, true );
                        } else {
                                updateTotalCount( total, r, false );
                        }
                }
 
-               if ( ! theExtraList || theExtraList.size() === 0 || theExtraList.children().size() === 0 || untrash || unspam ) {
+               if ( ! theExtraList || theExtraList.length === 0 || theExtraList.children().length === 0 || undoing ) {
                        return;
                }
 
-               theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() );
+               theList.get(0).wpList.add( theExtraList.children( ':eq(0):not(.no-items)' ).remove().clone() );
 
                refillTheExtraList();
+
+               animated = $( ':animated', '#the-comment-list' );
+               animatedCallback = function () {
+                       if ( ! $( '#the-comment-list tr:visible' ).length ) {
+                               theList.get(0).wpList.add( theExtraList.find( '.no-items' ).clone() );
+                       }
+               };
+
+               if ( animated.length ) {
+                       animated.promise().done( animatedCallback );
+               } else {
+                       animatedCallback();
+               }
        };
 
        refillTheExtraList = function(ev) {
@@ -297,13 +566,14 @@ setCommentsList = function() {
 commentReply = {
        cid : '',
        act : '',
+       originalContent : '',
 
        init : function() {
                var row = $('#replyrow');
 
                $('a.cancel', row).click(function() { return commentReply.revert(); });
                $('a.save', row).click(function() { return commentReply.send(); });
-               $('input#author, input#author-email, input#author-url', row).keypress(function(e){
+               $( 'input#author-name, input#author-email, input#author-url', row ).keypress( function( e ) {
                        if ( e.which == 13 ) {
                                commentReply.send();
                                e.preventDefault();
@@ -337,8 +607,9 @@ commentReply = {
        },
 
        toggle : function(el) {
-               if ( $(el).css('display') != 'none' )
-                       $(el).find('a.vim-q').click();
+               if ( 'none' !== $( el ).css( 'display' ) && ( $( '#replyrow' ).parent().is('#com-reply') || window.confirm( adminCommentsL10n.warnQuickEdit ) ) ) {
+                       $( el ).find( 'a.vim-q' ).click();
+               }
        },
 
        revert : function() {
@@ -375,17 +646,23 @@ commentReply = {
                $('#com-reply').append( replyrow );
                $('#replycontent').css('height', '').val('');
                $('#edithead input').val('');
-               $('.error', replyrow).html('').hide();
-               $('.spinner', replyrow).hide();
+               $('.error', replyrow).empty().hide();
+               $( '.spinner', replyrow ).removeClass( 'is-active' );
 
                this.cid = '';
+               this.originalContent = '';
        },
 
        open : function(comment_id, post_id, action) {
                var editRow, rowData, act, replyButton, editHeight,
                        t = this,
                        c = $('#comment-' + comment_id),
-                       h = c.height();
+                       h = c.height(),
+                       colspanVal = 0;
+
+               if ( ! this.discardCommentChanges() ) {
+                       return false;
+               }
 
                t.close();
                t.cid = comment_id;
@@ -395,18 +672,25 @@ commentReply = {
                action = action || 'replyto';
                act = 'edit' == action ? 'edit' : 'replyto';
                act = t.act = act + '-comment';
+               t.originalContent = $('textarea.comment', rowData).val();
+               colspanVal = $( '> th:visible, > td:visible', c ).length;
+
+               // Make sure it's actually a table and there's a `colspan` value to apply.
+               if ( editRow.hasClass( 'inline-edit-row' ) && 0 !== colspanVal ) {
+                       $( 'td', editRow ).attr( 'colspan', colspanVal );
+               }
 
                $('#action', editRow).val(act);
                $('#comment_post_ID', editRow).val(post_id);
                $('#comment_ID', editRow).val(comment_id);
 
                if ( action == 'edit' ) {
-                       $('#author', editRow).val( $('div.author', rowData).text() );
+                       $( '#author-name', editRow ).val( $( 'div.author', rowData ).text() );
                        $('#author-email', editRow).val( $('div.author-email', rowData).text() );
                        $('#author-url', editRow).val( $('div.author-url', rowData).text() );
                        $('#status', editRow).val( $('div.comment_status', rowData).text() );
                        $('#replycontent', editRow).val( $('textarea.comment', rowData).val() );
-                       $('#edithead, #savebtn', editRow).show();
+                       $( '#edithead, #editlegend, #savebtn', editRow ).show();
                        $('#replyhead, #replybtn, #addhead, #addbtn', editRow).hide();
 
                        if ( h > 120 ) {
@@ -421,12 +705,12 @@ commentReply = {
                        });
                } else if ( action == 'add' ) {
                        $('#addhead, #addbtn', editRow).show();
-                       $('#replyhead, #replybtn, #edithead, #editbtn', editRow).hide();
+                       $( '#replyhead, #replybtn, #edithead, #editlegend, #savebtn', editRow ) .hide();
                        $('#the-comment-list').prepend(editRow);
                        $('#replyrow').fadeIn(300);
                } else {
                        replyButton = $('#replybtn', editRow);
-                       $('#edithead, #savebtn, #addhead, #addbtn', editRow).hide();
+                       $( '#edithead, #editlegend, #savebtn, #addhead, #addbtn', editRow ).hide();
                        $('#replyhead, #replybtn', editRow).show();
                        c.after(editRow);
 
@@ -466,7 +750,7 @@ commentReply = {
                var post = {};
 
                $('#replysubmit .error').hide();
-               $('#replysubmit .spinner').show();
+               $( '#replysubmit .spinner' ).addClass( 'is-active' );
 
                $('#replyrow input').not(':button').each(function() {
                        var t = $(this);
@@ -516,7 +800,7 @@ commentReply = {
 
                if ( r.supplemental.parent_approved ) {
                        pid = $('#comment-' + r.supplemental.parent_approved);
-                       updatePending( -1 );
+                       updatePending( -1, r.supplemental.parent_post_id );
 
                        if ( this.comments_listing == 'moderated' ) {
                                pid.animate( { 'backgroundColor':'#CCEEBB' }, 400, function(){
@@ -526,6 +810,15 @@ commentReply = {
                        }
                }
 
+               if ( r.supplemental.i18n_comments_text ) {
+                       if ( isDashboard ) {
+                               updateDashboardText( r.supplemental );
+                       } else {
+                               updateApproved( 1, r.supplemental.parent_post_id );
+                               updateCountText( 'span.all-count', 1 );
+                       }
+               }
+
                c = $.trim(r.data); // Trim leading whitespaces
                $(c).hide();
                $('#replyrow').after(c);
@@ -549,7 +842,7 @@ commentReply = {
        error : function(r) {
                var er = r.statusText;
 
-               $('#replysubmit .spinner').hide();
+               $( '#replysubmit .spinner' ).removeClass( 'is-active' );
 
                if ( r.responseText )
                        er = r.responseText.replace( /<.[^<>]*?>/g, '' );
@@ -567,6 +860,22 @@ commentReply = {
                        $('table.comments-box').css('display', '');
                        $('#no-comments').remove();
                });
+       },
+
+       /**
+        * Alert the user if they have unsaved changes on a comment that will be
+        * lost if they proceed.
+        *
+        * @returns {boolean}
+        */
+       discardCommentChanges: function() {
+               var editRow = $( '#replyrow' );
+
+               if  ( this.originalContent === $( '#replycontent', editRow ).val() ) {
+                       return true;
+               }
+
+               return window.confirm( adminCommentsL10n.warnCommentChanges );
        }
 };
 
@@ -575,7 +884,10 @@ $(document).ready(function(){
 
        setCommentsList();
        commentReply.init();
-       $(document).delegate('span.delete a.delete', 'click', function(){return false;});
+
+       $(document).on( 'click', 'span.delete a.delete', function( e ) {
+               e.preventDefault();
+       });
 
        if ( typeof $.table_hotkeys != 'undefined' ) {
                make_hotkeys_redirect = function(which) {
@@ -594,9 +906,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,14 +919,45 @@ $(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"]'
+                               },
+                               cycle_expr: '#the-comment-list tr',
+                               start_row_index: 0
+                       }
                );
        }
+
+       // Quick Edit and Reply have an inline comment editor.
+       $( '#the-comment-list' ).on( 'click', '.comment-inline', function (e) {
+               e.preventDefault();
+               var $el = $( this ),
+                       action = 'replyto';
+
+               if ( 'undefined' !== typeof $el.data( 'action' ) ) {
+                       action = $el.data( 'action' );
+               }
+
+               commentReply.open( $el.data( 'commentId' ), $el.data( 'postId' ), action );
+       } );
 });
 
 })(jQuery);