2 * MediaWiki Widgets - MediaResourceQueue 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.APIResultsQueue
16 * @description Create an instance of `mw.widgets.MediaResourceQueue`.
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.MediaResourceQueue = function MwWidgetsMediaResourceQueue( config ) {
22 config = config || {};
25 mw.widgets.MediaResourceQueue.super.call( this, config );
27 this.maxHeight = config.maxHeight || 200;
31 OO.inheritClass( mw.widgets.MediaResourceQueue, mw.widgets.APIResultsQueue );
34 * Fetch the file repos.
36 * @return {jQuery.Promise} Promise that resolves when the resources are set up
38 mw.widgets.MediaResourceQueue.prototype.getFileRepos = function () {
39 const defaultSource = [ {
40 url: mw.util.wikiScript( 'api' ),
44 if ( !this.fileRepoPromise ) {
45 this.fileRepoPromise = new mw.Api().get( {
49 ( resp ) => resp.query && resp.query.repos || defaultSource,
50 () => $.Deferred().resolve( defaultSource )
54 return this.fileRepoPromise;
58 * Get image maximum height.
60 * @return {string} Image max height
62 mw.widgets.MediaResourceQueue.prototype.getMaxHeight = function () {
63 return this.maxHeight;