wp/wp-admin/js/edit-comments.js
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
--- a/wp/wp-admin/js/edit-comments.js	Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-admin/js/edit-comments.js	Wed Sep 21 18:19:35 2022 +0200
@@ -445,7 +445,7 @@
 			a.attr('class', 'vim-z vim-destructive aria-button-if-js');
 			$('.avatar', el).first().clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside');
 
-			a.click(function( e ){
+			a.on( 'click', function( e ){
 				e.preventDefault();
 				e.stopPropagation(); // Ticket #35904.
 				list.wpList.del(this);
@@ -762,7 +762,7 @@
 	 * @global
 	 */
 	window.theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } )
-		.bind('wpListDelEnd', function(e, s){
+		.on('wpListDelEnd', function(e, s){
 			var wpListsData = $(s.target).attr('data-wp-lists'), id = s.element.replace(/[^0-9]+/g, '');
 
 			if ( wpListsData.indexOf(':trash=1') != -1 || wpListsData.indexOf(':spam=1') != -1 )
@@ -793,9 +793,9 @@
 	init : function() {
 		var row = $('#replyrow');
 
-		$( '.cancel', row ).click( function() { return commentReply.revert(); } );
-		$( '.save', row ).click( function() { return commentReply.send(); } );
-		$( 'input#author-name, input#author-email, input#author-url', row ).keypress( function( e ) {
+		$( '.cancel', row ).on( 'click', function() { return commentReply.revert(); } );
+		$( '.save', row ).on( 'click', function() { return commentReply.send(); } );
+		$( 'input#author-name, input#author-email, input#author-url', row ).on( 'keypress', function( e ) {
 			if ( e.which == 13 ) {
 				commentReply.send();
 				e.preventDefault();
@@ -804,11 +804,11 @@
 		});
 
 		// Add events.
-		$('#the-comment-list .column-comment > p').dblclick(function(){
+		$('#the-comment-list .column-comment > p').on( 'dblclick', function(){
 			commentReply.toggle($(this).parent());
 		});
 
-		$('#doaction, #doaction2, #post-query-submit').click(function(){
+		$('#doaction, #post-query-submit').on( 'click', function(){
 			if ( $('#the-comment-list #replyrow').length > 0 )
 				commentReply.close();
 		});
@@ -831,7 +831,7 @@
 	 */
 	addEvents : function(r) {
 		r.each(function() {
-			$(this).find('.column-comment > p').dblclick(function(){
+			$(this).find('.column-comment > p').on( 'dblclick', function(){
 				commentReply.toggle($(this).parent());
 			});
 		});
@@ -850,7 +850,7 @@
 	 */
 	toggle : function(el) {
 		if ( 'none' !== $( el ).css( 'display' ) && ( $( '#replyrow' ).parent().is('#com-reply') || window.confirm( __( 'Are you sure you want to edit this comment?\nThe changes you made will be lost.' ) ) ) ) {
-			$( el ).find( 'button.vim-q' ).click();
+			$( el ).find( 'button.vim-q' ).trigger( 'click' );
 		}
 	},
 
@@ -905,7 +905,7 @@
 					.show()
 					.find( '.vim-q' )
 						.attr( 'aria-expanded', 'false' )
-						.focus();
+						.trigger( 'focus' );
 			} ).css( 'backgroundColor', '' );
 		}
 
@@ -913,7 +913,7 @@
 		if ( 'replyto-comment' === this.act ) {
 			commentRow.find( '.vim-r' )
 				.attr( 'aria-expanded', 'false' )
-				.focus();
+				.trigger( 'focus' );
 		}
 
 		// Reset the Quicktags buttons.
@@ -1032,7 +1032,7 @@
 			else if ( rtop - 20 < scrollTop )
 				window.scroll(0, rtop - 35);
 
-			$('#replycontent').focus().keyup(function(e){
+			$('#replycontent').trigger( 'focus' ).on( 'keyup', function(e){
 				if ( e.which == 27 )
 					commentReply.revert(); // Close on Escape.
 			});
@@ -1135,7 +1135,8 @@
 			updateCountText( 'span.all-count', 1 );
 		}
 
-		c = $.trim(r.data); // Trim leading whitespaces.
+		r.data = r.data || '';
+		c = r.data.toString().trim(); // Trim leading whitespaces.
 		$(c).hide();
 		$('#replyrow').after(c);
 
@@ -1224,7 +1225,7 @@
 	}
 };
 
-$(document).ready(function(){
+$( function(){
 	var make_hotkeys_redirect, edit_comment, toggle_all, make_bulk;
 
 	setCommentsList();
@@ -1297,7 +1298,7 @@
 			return function() {
 				var scope = $('select[name="action"]');
 				$('option[value="' + value + '"]', scope).prop('selected', true);
-				$('#doaction').click();
+				$('#doaction').trigger( 'click' );
 			};
 		};