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;
commentReply = {
cid : '',
act : '',
+ originalContent : '',
init : function() {
var row = $('#replyrow');
$( '.spinner', replyrow ).removeClass( 'is-active' );
this.cid = '';
+ this.originalContent = '';
},
open : function(comment_id, post_id, action) {
h = c.height(),
colspanVal = 0;
+ if ( ! this.discardCommentChanges() ) {
+ return false;
+ }
+
t.close();
t.cid = comment_id;
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.
$('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 );
}
};