Themes: After [36546] restore theme search functionality.
* Correct several incorrect uses of `_.union`. Since Underscore 1.7.0 `_.union` supports only arrays and not variadic args. * Use a namespaced event `themes:update`. Backbone 1.2 added a built in `update` event that triggers after any amount of models are added or removed from a collection. Props adamsilverstein. See #34350. git-svn-id: https://develop.svn.wordpress.org/trunk@36580 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e636f79308
commit
57ebfc9b94
@ -158,8 +158,8 @@ themes.Collection = Backbone.Collection.extend({
|
|||||||
$( 'body' ).removeClass( 'no-results' );
|
$( 'body' ).removeClass( 'no-results' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger an 'update' event
|
// Trigger a 'themes:update' event
|
||||||
this.trigger( 'update' );
|
this.trigger( 'themes:update' );
|
||||||
},
|
},
|
||||||
|
|
||||||
// Performs a search within the collection
|
// Performs a search within the collection
|
||||||
@ -185,7 +185,7 @@ themes.Collection = Backbone.Collection.extend({
|
|||||||
description = data.get( 'description' ).replace( /(<([^>]+)>)/ig, '' );
|
description = data.get( 'description' ).replace( /(<([^>]+)>)/ig, '' );
|
||||||
author = data.get( 'author' ).replace( /(<([^>]+)>)/ig, '' );
|
author = data.get( 'author' ).replace( /(<([^>]+)>)/ig, '' );
|
||||||
|
|
||||||
haystack = _.union( name, data.get( 'id' ), description, author, data.get( 'tags' ) );
|
haystack = _.union( [ name, data.get( 'id' ), description, author, data.get( 'tags' ) ] );
|
||||||
|
|
||||||
if ( match.test( data.get( 'author' ) ) && term.length > 2 ) {
|
if ( match.test( data.get( 'author' ) ) && term.length > 2 ) {
|
||||||
data.set( 'displayAuthor', true );
|
data.set( 'displayAuthor', true );
|
||||||
@ -264,7 +264,7 @@ themes.Collection = Backbone.Collection.extend({
|
|||||||
|
|
||||||
// Trigger a collection refresh event
|
// Trigger a collection refresh event
|
||||||
// and a `query:success` event with a `count` argument.
|
// and a `query:success` event with a `count` argument.
|
||||||
self.trigger( 'update' );
|
self.trigger( 'themes:update' );
|
||||||
self.trigger( 'query:success', count );
|
self.trigger( 'query:success', count );
|
||||||
|
|
||||||
if ( data.themes && data.themes.length === 0 ) {
|
if ( data.themes && data.themes.length === 0 ) {
|
||||||
@ -308,7 +308,7 @@ themes.Collection = Backbone.Collection.extend({
|
|||||||
this.count = this.length;
|
this.count = this.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.trigger( 'update' );
|
this.trigger( 'themes:update' );
|
||||||
this.trigger( 'query:success', this.count );
|
this.trigger( 'query:success', this.count );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -863,11 +863,11 @@ themes.view.Themes = wp.Backbone.View.extend({
|
|||||||
self.currentTheme();
|
self.currentTheme();
|
||||||
|
|
||||||
// When the collection is updated by user input...
|
// When the collection is updated by user input...
|
||||||
this.listenTo( self.collection, 'update', function() {
|
this.listenTo( self.collection, 'themes:update', function() {
|
||||||
self.parent.page = 0;
|
self.parent.page = 0;
|
||||||
self.currentTheme();
|
self.currentTheme();
|
||||||
self.render( this );
|
self.render( this );
|
||||||
});
|
} );
|
||||||
|
|
||||||
// Update theme count to full result set when available.
|
// Update theme count to full result set when available.
|
||||||
this.listenTo( self.collection, 'query:success', function( count ) {
|
this.listenTo( self.collection, 'query:success', function( count ) {
|
||||||
@ -1478,7 +1478,7 @@ themes.view.Installer = themes.view.Appearance.extend({
|
|||||||
|
|
||||||
// Construct the filter request
|
// Construct the filter request
|
||||||
// using the default values
|
// using the default values
|
||||||
filter = _.union( filter, this.filtersChecked() );
|
filter = _.union( [ filter, this.filtersChecked() ] );
|
||||||
request = { tag: [ filter ] };
|
request = { tag: [ filter ] };
|
||||||
|
|
||||||
// Get the themes by sending Ajax POST request to api.wordpress.org/themes
|
// Get the themes by sending Ajax POST request to api.wordpress.org/themes
|
||||||
|
Loading…
Reference in New Issue
Block a user