From 82a26045e5e1c775bb0de6bb442d0a97163c2844 Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Fri, 19 Jun 2015 13:47:35 +0000 Subject: [PATCH] Check that current changes can be lost before editing another comment. When replying to or editing a comment, double-clicking another comment will open it in quick edit and changes to the current comment are lost. Props pareshradadiya, chriscct7. Fixes #21845. git-svn-id: https://develop.svn.wordpress.org/trunk@32857 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/edit-comments.js | 5 +++-- src/wp-includes/script-loader.php | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/js/edit-comments.js b/src/wp-admin/js/edit-comments.js index 7268e7bb54..bea253cec0 100644 --- a/src/wp-admin/js/edit-comments.js +++ b/src/wp-admin/js/edit-comments.js @@ -313,8 +313,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() { diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 0bf838d501..a58833e402 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -439,7 +439,8 @@ function wp_default_scripts( &$scripts ) { 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']), 'replyApprove' => __( 'Approve and Reply' ), - 'reply' => __( 'Reply' ) + 'reply' => __( 'Reply' ), + 'warnQuickEdit' => __( "Are you sure you want to edit this comment?\nThe changes you made will be lost." ), ) ); $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), false, 1 );