Plugins: Improve Ajax search of installed plugins.

Removes the highlight from the current filter when performing an Ajax search and adds it back when clearing the search input.

Fixes #37657.
Built from https://develop.svn.wordpress.org/trunk@39099


git-svn-id: http://core.svn.wordpress.org/trunk@39041 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler 2016-11-02 22:47:30 +00:00
parent 6485e5e3cf
commit ceeb8ddb46
3 changed files with 17 additions and 7 deletions

View File

@ -2247,8 +2247,10 @@
var data = { var data = {
_ajax_nonce: wp.updates.ajaxNonce, _ajax_nonce: wp.updates.ajaxNonce,
s: event.target.value, s: event.target.value,
pagenow: pagenow pagenow: pagenow,
}; plugin_status: 'all'
},
queryArgs;
// Clear on escape. // Clear on escape.
if ( 'keyup' === event.type && 27 === event.which ) { if ( 'keyup' === event.type && 27 === event.which ) {
@ -2261,8 +2263,14 @@
wp.updates.searchTerm = data.s; wp.updates.searchTerm = data.s;
} }
queryArgs = _.object( _.compact( _.map( location.search.slice( 1 ).split( '&' ), function( item ) {
if ( item ) return item.split( '=' );
} ) ) );
data.plugin_status = queryArgs.plugin_status || 'all';
if ( window.history && window.history.replaceState ) { if ( window.history && window.history.replaceState ) {
window.history.replaceState( null, '', location.href.split( '?' )[ 0 ] + '?s=' + data.s ); window.history.replaceState( null, '', location.href.split( '?' )[ 0 ] + '?s=' + data.s + '&plugin_status=' + data.plugin_status );
} }
if ( 'undefined' !== typeof wp.updates.searchRequest ) { if ( 'undefined' !== typeof wp.updates.searchRequest ) {
@ -2271,6 +2279,7 @@
$bulkActionForm.empty(); $bulkActionForm.empty();
$( 'body' ).addClass( 'loading-content' ); $( 'body' ).addClass( 'loading-content' );
$( '.subsubsub .current' ).removeClass( 'current' );
wp.updates.searchRequest = wp.ajax.post( 'search-plugins', data ).done( function( response ) { wp.updates.searchRequest = wp.ajax.post( 'search-plugins', data ).done( function( response ) {
@ -2280,6 +2289,7 @@
if ( ! data.s.length ) { if ( ! data.s.length ) {
$oldSubTitle.remove(); $oldSubTitle.remove();
$( '.subsubsub .' + data.plugin_status + ' a' ).addClass( 'current' );
} else if ( $oldSubTitle.length ) { } else if ( $oldSubTitle.length ) {
$oldSubTitle.replaceWith( $subTitle ); $oldSubTitle.replaceWith( $subTitle );
} else { } else {

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.7-beta1-39098'; $wp_version = '4.7-beta1-39099';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.