2 * MediaWiki Widgets - MediaSearchQueue class.
4 * @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
10 * MediaWiki media resource queue.
13 * @extends mw.widgets.MediaResourceQueue
16 * @param {Object} [config] Configuration options
17 * @cfg {number} maxHeight The maximum height of the media, used in the
18 * search call to the API.
20 mw.widgets.MediaSearchQueue = function MwWidgetsMediaSearchQueue( config ) {
21 config = config || {};
24 mw.widgets.MediaSearchQueue.super.call( this, config );
26 this.searchQuery = '';
30 OO.inheritClass( mw.widgets.MediaSearchQueue, mw.widgets.MediaResourceQueue );
33 * Override parent method to set up the providers according to
36 * @return {jQuery.Promise} Promise that resolves when the resources are set up
38 mw.widgets.MediaSearchQueue.prototype.setup = function () {
42 return this.getFileRepos().then( function ( sources ) {
43 if ( queue.providers.length === 0 ) {
44 // Set up the providers
45 for ( i = 0, len = sources.length; i < len; i++ ) {
46 queue.providers.push( new mw.widgets.MediaSearchProvider(
49 name: sources[ i ].name,
50 local: sources[ i ].local,
51 scriptDirUrl: sources[ i ].scriptDirUrl,
53 gsrsearch: queue.getSearchQuery()
56 iiurlheight: queue.getMaxHeight()
66 * Set the search query
68 * @param {string} searchQuery API search query
70 mw.widgets.MediaSearchQueue.prototype.setSearchQuery = function ( searchQuery ) {
71 this.setParams( { gsrsearch: searchQuery } );
75 * Get the search query
77 * @return {string} API search query
79 mw.widgets.MediaSearchQueue.prototype.getSearchQuery = function () {
80 return this.getParams().gsrsearch;
82 }( jQuery, mediaWiki ) );