Changeset 58957
- Timestamp:
- 08/30/2024 10:15:59 PM (6 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/wp/updates.js
r58455 r58957 143 143 144 144 /** 145 * Minimum number of characters before an ajax search is fired. 146 * 147 * @since 6.7.0 148 * 149 * @type {number} 150 */ 151 wp.updates.searchMinCharacters = 2; 152 153 /** 145 154 * Whether filesystem credentials need to be requested from the user. 146 155 * … … 2978 2987 } 2979 2988 2989 // Track the previous search string length. 2990 var previousSearchStringLength = 0; 2991 wp.updates.shouldSearch = function( searchStringLength ) { 2992 var shouldSearch = searchStringLength >= wp.updates.searchMinCharacters || 2993 previousSearchStringLength > wp.updates.searchMinCharacters; 2994 previousSearchStringLength = searchStringLength; 2995 return shouldSearch; 2996 }; 2997 2980 2998 /** 2981 2999 * Handles changes to the plugin search box on the new-plugin page, … … 2985 3003 */ 2986 3004 $pluginInstallSearch.on( 'keyup input', _.debounce( function( event, eventtype ) { 2987 var $searchTab = $( '.plugin-install-search' ), data, searchLocation; 3005 var $searchTab = $( '.plugin-install-search' ), data, searchLocation, 3006 searchStringLength = $pluginInstallSearch.val().length; 2988 3007 2989 3008 data = { … … 2995 3014 }; 2996 3015 searchLocation = location.href.split( '?' )[ 0 ] + '?' + $.param( _.omit( data, [ '_ajax_nonce', 'pagenow' ] ) ); 3016 3017 // Set the autocomplete attribute, turning off autocomplete 1 character before ajax search kicks in. 3018 if ( wp.updates.shouldSearch( searchStringLength ) ) { 3019 $pluginInstallSearch.attr( 'autocomplete', 'off' ); 3020 } else { 3021 $pluginInstallSearch.attr( 'autocomplete', 'on' ); 3022 return; 3023 } 2997 3024 2998 3025 // Clear on escape. … … 3055 3082 if ( $pluginSearch.length ) { 3056 3083 $pluginSearch.attr( 'aria-describedby', 'live-search-desc' ); 3084 3057 3085 } 3058 3086 … … 3070 3098 plugin_status: 'all' 3071 3099 }, 3072 queryArgs; 3100 queryArgs, 3101 searchStringLength = $pluginSearch.val().length; 3102 3103 // Set the autocomplete attribute, turning off autocomplete 1 character before ajax search kicks in. 3104 if ( wp.updates.shouldSearch( searchStringLength ) ) { 3105 $pluginSearch.attr( 'autocomplete', 'off' ); 3106 } else { 3107 $pluginSearch.attr( 'autocomplete', 'on' ); 3108 return; 3109 } 3073 3110 3074 3111 // Clear on escape.
Note: See TracChangeset
for help on using the changeset viewer.