2015-02-22 08:25:27 +01:00
|
|
|
/*globals wp */
|
|
|
|
|
2015-02-09 01:43:50 +01:00
|
|
|
/**
|
|
|
|
* wp.media.view.Search
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @augments wp.media.View
|
|
|
|
* @augments wp.Backbone.View
|
|
|
|
* @augments Backbone.View
|
|
|
|
*/
|
2015-03-31 04:03:29 +02:00
|
|
|
var l10n = wp.media.view.l10n,
|
2015-02-09 01:43:50 +01:00
|
|
|
Search;
|
|
|
|
|
2015-03-31 04:03:29 +02:00
|
|
|
Search = wp.media.View.extend({
|
2015-02-09 01:43:50 +01:00
|
|
|
tagName: 'input',
|
|
|
|
className: 'search',
|
|
|
|
id: 'media-search-input',
|
|
|
|
|
|
|
|
attributes: {
|
|
|
|
type: 'search',
|
|
|
|
placeholder: l10n.search
|
|
|
|
},
|
|
|
|
|
|
|
|
events: {
|
|
|
|
'input': 'search',
|
|
|
|
'keyup': 'search',
|
|
|
|
'change': 'search',
|
|
|
|
'search': 'search'
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {wp.media.view.Search} Returns itself to allow chaining
|
|
|
|
*/
|
|
|
|
render: function() {
|
|
|
|
this.el.value = this.model.escape('search');
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
search: function( event ) {
|
|
|
|
if ( event.target.value ) {
|
|
|
|
this.model.set( 'search', event.target.value );
|
|
|
|
} else {
|
|
|
|
this.model.unset('search');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-09 17:01:29 +01:00
|
|
|
module.exports = Search;
|