From 2f71d7d8e49c1e783fedfb6cf91479af5d123fd8 Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Tue, 2 Sep 2014 03:56:05 +0000 Subject: [PATCH] Comments: Simplify JS for inline edit and reply. fixes #27533. git-svn-id: https://develop.svn.wordpress.org/trunk@29662 602fd350-edb4-49c9-b593-d223f7449a82 --- .../includes/class-wp-comments-list-table.php | 6 ++--- src/wp-admin/js/edit-comments.js | 26 +++++++------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index 3beafb821d..4238d8f327 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -474,11 +474,11 @@ class WP_Comments_List_Table extends WP_List_Table { if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) { $actions['edit'] = "". __( 'Edit' ) . ''; - $format = '%s'; + $format = '%s'; - $actions['quickedit'] = sprintf( $format, $comment->comment_ID, $post->ID, 'vim-q edit-comment-inline', esc_attr__( 'Quick Edit' ), __( 'Quick Edit' ) ); + $actions['quickedit'] = sprintf( $format, $comment->comment_ID, $post->ID, 'edit', 'vim-q comment-inline', esc_attr__( 'Quick Edit' ), __( 'Quick Edit' ) ); - $actions['reply'] = sprintf( $format, $comment->comment_ID, $post->ID, 'vim-r reply-comment-inline', esc_attr__( 'Reply to this comment' ), __( 'Reply' ) ); + $actions['reply'] = sprintf( $format, $comment->comment_ID, $post->ID, 'replyto', 'vim-r comment-inline', esc_attr__( 'Reply to this comment' ), __( 'Reply' ) ); } /** This filter is documented in wp-admin/includes/dashboard.php */ diff --git a/src/wp-admin/js/edit-comments.js b/src/wp-admin/js/edit-comments.js index d8a402ecd6..78c46174ea 100644 --- a/src/wp-admin/js/edit-comments.js +++ b/src/wp-admin/js/edit-comments.js @@ -608,24 +608,18 @@ $(document).ready(function(){ ); } - if ( typeof commentReply != 'undefined' ) { + // 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'; - // Each "Quick Edit" link, open the comment editor - $( 'body' ).on( 'click', '.comment .row-actions .quickedit .edit-comment-inline', function (e) { - e.preventDefault(); + if ( 'undefined' !== typeof $el.data( 'action' ) ) { + action = $el.data( 'action' ); + } - var $el = $( e.currentTarget ); - commentReply.open( $el.data( 'comment-id' ), $el.data( 'post-id' ), 'edit' ); - } ); - - // Each "Reply" link, open the comment reply - $( 'body' ).on( 'click', '.comment .row-actions .reply .reply-comment-inline', function (e) { - e.preventDefault(); - - var $el = $( e.currentTarget ); - commentReply.open( $el.data('comment-id'), $el.data('post-id') ); - } ); - } + commentReply.open( $el.data( 'commentId' ), $el.data( 'postId' ), action ); + } ); }); })(jQuery);