mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-31 07:49:38 +01:00
d9a2e85bfe
* specify globals in more files * add missing `wp.media.*` namespace docs * add doc blocks to files that had none See #28510. Built from https://develop.svn.wordpress.org/trunk@31492 git-svn-id: http://core.svn.wordpress.org/trunk@31473 1a063a9b-81f0-0310-95a4-ce76da25c4cd
50 lines
852 B
JavaScript
50 lines
852 B
JavaScript
/*globals wp */
|
|
|
|
/**
|
|
* wp.media.view.Search
|
|
*
|
|
* @class
|
|
* @augments wp.media.View
|
|
* @augments wp.Backbone.View
|
|
* @augments Backbone.View
|
|
*/
|
|
var View = require( './view.js' ),
|
|
l10n = wp.media.view.l10n,
|
|
Search;
|
|
|
|
Search = View.extend({
|
|
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');
|
|
}
|
|
}
|
|
});
|
|
|
|
module.exports = Search;
|