X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/b925718b4bf2dd47a8429f844d0a255ca6e35bd1..b22765f41bf0b2021b9beb9120ee0ac91fa89292:/wp-admin/js/edit-comments.js diff --git a/wp-admin/js/edit-comments.js b/wp-admin/js/edit-comments.js index f201362b..3de03102 100644 --- a/wp-admin/js/edit-comments.js +++ b/wp-admin/js/edit-comments.js @@ -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 ); } };