wp/wp-admin/js/widgets.js
changeset 18 be944660c56a
parent 16 a86126ab1dd4
--- a/wp/wp-admin/js/widgets.js	Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-admin/js/widgets.js	Wed Sep 21 18:19:35 2022 +0200
@@ -36,7 +36,7 @@
 			 * Toggle the widgets containers when clicked and update the toggle
 			 * button `aria-expanded` attribute value.
 			 */
-			.click( function() {
+			.on( 'click', function() {
 				var $this = $( this ),
 					$wrap = $this.closest( '.widgets-holder-wrap '),
 					$toggle = $this.find( '.handlediv' );
@@ -81,7 +81,7 @@
 				});
 				unsavedWidgetsElements.each( function() {
 					if ( ! $( this ).hasClass( 'open' ) ) {
-						$( this ).find( '.widget-title-action:first' ).click();
+						$( this ).find( '.widget-title-action:first' ).trigger( 'click' );
 					}
 				});
 
@@ -92,7 +92,7 @@
 					} else {
 						this.scrollIntoView();
 					}
-					$( this ).find( '.widget-inside :tabbable:first' ).focus();
+					$( this ).find( '.widget-inside :tabbable:first' ).trigger( 'focus' );
 				} );
 
 				event.returnValue = wp.i18n.__( 'The changes you made will be lost if you navigate away from this page.' );
@@ -101,7 +101,7 @@
 		});
 
 		// Handle the widgets containers in the left column.
-		$( '#widgets-left .sidebar-name' ).click( function() {
+		$( '#widgets-left .sidebar-name' ).on( 'click', function() {
 			var $wrap = $( this ).closest( '.widgets-holder-wrap' );
 
 			$wrap
@@ -112,7 +112,7 @@
 			$document.triggerHandler( 'wp-pin-menu' );
 		});
 
-		$(document.body).bind('click.widgets-toggle', function(e) {
+		$(document.body).on('click.widgets-toggle', function(e) {
 			var target = $(e.target), css = {},
 				widget, inside, targetWidth, widgetWidth, margin, saveButton, widgetId,
 				toggleBtn = target.closest( '.widget' ).find( '.widget-top button.widget-action' );
@@ -419,7 +419,7 @@
 		// Area Chooser.
 		$( '#widgets-right .widgets-holder-wrap' ).each( function( index, element ) {
 			var $element = $( element ),
-				name = $element.find( '.sidebar-name h2' ).text(),
+				name = $element.find( '.sidebar-name h2' ).text() || '',
 				ariaLabel = $element.find( '.sidebar-name' ).data( 'add-to' ),
 				id = $element.find( '.widgets-sortables' ).attr( 'id' ),
 				li = $( '<li>' ),
@@ -428,7 +428,7 @@
 					'aria-pressed': 'false',
 					'class': 'widgets-chooser-button',
 					'aria-label': ariaLabel
-				} ).text( $.trim( name ) );
+				} ).text( name.toString().trim() );
 
 			li.append( button );
 
@@ -741,7 +741,7 @@
 	}
 };
 
-$document.ready( function(){ wpWidgets.init(); } );
+$( function(){ wpWidgets.init(); } );
 
 })(jQuery);
 
@@ -760,4 +760,4 @@
 	widgetAdded: ''
 };
 
-wpWidgets.l10n = window.wp.deprecateL10nObject( 'wpWidgets.l10n', wpWidgets.l10n );
+wpWidgets.l10n = window.wp.deprecateL10nObject( 'wpWidgets.l10n', wpWidgets.l10n, '5.5.0' );