]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/js/edit-comments.js
Wordpress 4.6-scripts
[autoinstalls/wordpress.git] / wp-admin / js / edit-comments.js
index f201362bf0040a898362b2f89e4736fcdcd021d7..3de031022cb37766c87e766de66e71de18660d2f 100644 (file)
@@ -220,12 +220,15 @@ 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;
@@ -563,6 +566,7 @@ setCommentsList = function() {
 commentReply = {
        cid : '',
        act : '',
+       originalContent : '',
 
        init : function() {
                var row = $('#replyrow');
@@ -646,6 +650,7 @@ commentReply = {
                $( '.spinner', replyrow ).removeClass( 'is-active' );
 
                this.cid = '';
+               this.originalContent = '';
        },
 
        open : function(comment_id, post_id, action) {
@@ -655,6 +660,10 @@ commentReply = {
                        h = c.height(),
                        colspanVal = 0;
 
+               if ( ! this.discardCommentChanges() ) {
+                       return false;
+               }
+
                t.close();
                t.cid = comment_id;
 
@@ -663,6 +672,7 @@ 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.
@@ -850,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 );
        }
 };