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 * @classdesc Media resource queue.
13 * @extends mw.widgets.MediaResourceQueue
16 * @description Create an instance of `mw.widgets.MediaSearchQueue`.
17 * @param {Object} [config] Configuration options
18 * @param {number} config.maxHeight The maximum height of the media, used in the
19 * search call to the API.
21 mw.widgets.MediaSearchQueue = function MwWidgetsMediaSearchQueue( config ) {
22 config = config || {};
25 mw.widgets.MediaSearchQueue.super.call( this, config );
29 OO.inheritClass( mw.widgets.MediaSearchQueue, mw.widgets.MediaResourceQueue );
32 * Override parent method to set up the providers according to
35 * @return {jQuery.Promise} Promise that resolves when the resources are set up
37 mw.widgets.MediaSearchQueue.prototype.setup = function () {
38 return this.getFileRepos().then( ( sources ) => {
39 if ( this.providers.length === 0 ) {
40 // Set up the providers
41 for ( let i = 0, len = sources.length; i < len; i++ ) {
42 this.addProvider( new mw.widgets.MediaSearchProvider(
45 name: sources[ i ].name,
46 local: sources[ i ].local,
47 scriptDirUrl: sources[ i ].scriptDirUrl,
49 gsrsearch: this.getSearchQuery()
52 iiurlheight: this.getMaxHeight()
62 * Set the search query.
64 * @param {string} searchQuery API search query
66 mw.widgets.MediaSearchQueue.prototype.setSearchQuery = function ( searchQuery ) {
67 this.setParams( { gsrsearch: searchQuery } );
71 * Get the search query.
73 * @return {string} API search query
75 mw.widgets.MediaSearchQueue.prototype.getSearchQuery = function () {
76 return this.getParams().gsrsearch;