wp/wp-admin/js/link.js
changeset 18 be944660c56a
parent 16 a86126ab1dd4
--- a/wp/wp-admin/js/link.js	Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-admin/js/link.js	Wed Sep 21 18:19:35 2022 +0200
@@ -4,11 +4,11 @@
 
 /* global postboxes, deleteUserSetting, setUserSetting, getUserSetting */
 
-jQuery(document).ready( function($) {
+jQuery( function($) {
 
 	var newCat, noSyncChecks = false, syncChecks, catAddAfter;
 
-	$('#link_name').focus();
+	$('#link_name').trigger( 'focus' );
 	// Postboxes.
 	postboxes.add_postbox_toggles('link');
 
@@ -19,7 +19,7 @@
 	 *
 	 * @return {boolean} Always returns false to prevent the default behavior.
 	 */
-	$('#category-tabs a').click(function(){
+	$('#category-tabs a').on( 'click', function(){
 		var t = $(this).attr('href');
 		$(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
 		$('.tabs-panel').hide();
@@ -31,7 +31,7 @@
 		return false;
 	});
 	if ( getUserSetting('cats') )
-		$('#category-tabs a[href="#categories-pop"]').click();
+		$('#category-tabs a[href="#categories-pop"]').trigger( 'click' );
 
 	// Ajax Cat.
 	newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ); } );
@@ -41,7 +41,7 @@
 	 *
 	 * @return {void}
 	 */
-	$('#link-category-add-submit').click( function() { newCat.focus(); } );
+	$('#link-category-add-submit').on( 'click', function() { newCat.focus(); } );
 
 	/**
 	 * Synchronize category checkboxes.
@@ -81,8 +81,12 @@
 		$(s.what + ' response_data', r).each( function() {
 			var t = $($(this).text());
 			t.find( 'label' ).each( function() {
-				var th = $(this), val = th.find('input').val(), id = th.find('input')[0].id, name = $.trim( th.text() ), o;
-				$('#' + id).change( syncChecks );
+				var th = $(this),
+					val = th.find('input').val(),
+					id = th.find('input')[0].id,
+					name = th.text().trim(),
+					o;
+				$('#' + id).on( 'change', syncChecks );
 				o = $( '<option value="' +  parseInt( val, 10 ) + '"></option>' ).text( name );
 			} );
 		} );
@@ -108,13 +112,13 @@
 	} );
 
 	// All categories is the default tab, so we delete the user setting.
-	$('a[href="#categories-all"]').click(function(){deleteUserSetting('cats');});
+	$('a[href="#categories-all"]').on( 'click', function(){deleteUserSetting('cats');});
 
 	// Set a preference for the popular categories to cookies.
-	$('a[href="#categories-pop"]').click(function(){setUserSetting('cats','pop');});
+	$('a[href="#categories-pop"]').on( 'click', function(){setUserSetting('cats','pop');});
 
 	if ( 'pop' == getUserSetting('cats') )
-		$('a[href="#categories-pop"]').click();
+		$('a[href="#categories-pop"]').trigger( 'click' );
 
 	/**
 	 * Adds event handler that shows the interface controls to add a new category.
@@ -125,12 +129,12 @@
 	 * @return {boolean} Always returns false to prevent regular link
 	 *                   functionality.
 	 */
-	$('#category-add-toggle').click( function() {
+	$('#category-add-toggle').on( 'click', function() {
 		$(this).parents('div:first').toggleClass( 'wp-hidden-children' );
-		$('#category-tabs a[href="#categories-all"]').click();
-		$('#newcategory').focus();
+		$('#category-tabs a[href="#categories-all"]').trigger( 'click' );
+		$('#newcategory').trigger( 'focus' );
 		return false;
 	} );
 
-	$('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change();
+	$('.categorychecklist :checkbox').on( 'change', syncChecks ).filter( ':checked' ).trigger( 'change' );
 });