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. git-svn-id: https://develop.svn.wordpress.org/trunk@39099 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9bb355dccd
commit
21dc2530eb
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue