mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-01 17:36:35 +00:00
36befda61c
It's new, it's fresh, it's amazing, it's here. Change-Id: I5dc784411f704685ed5cc763a2b2b1c5d3e5a610
67 lines
1.5 KiB
JavaScript
67 lines
1.5 KiB
JavaScript
/*!
|
|
* VisualEditor DataModel MWMediaResourceQueue class.
|
|
*
|
|
* @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* MediaWiki media resource queue.
|
|
*
|
|
* @class
|
|
* @extends ve.dm.APIResultsQueue
|
|
*
|
|
* @constructor
|
|
* @param {Object} [config] Configuration options
|
|
* @cfg {number} maxHeight The maximum height of the media, used in the
|
|
* search call to the API.
|
|
*/
|
|
ve.dm.MWMediaResourceQueue = function VeDmMWMediaResourceQueue( config ) {
|
|
config = config || {};
|
|
|
|
// Parent constructor
|
|
ve.dm.MWMediaResourceQueue.super.call( this, config );
|
|
|
|
this.maxHeight = config.maxHeight || 200;
|
|
};
|
|
|
|
/* Inheritance */
|
|
OO.inheritClass( ve.dm.MWMediaResourceQueue, ve.dm.APIResultsQueue );
|
|
|
|
/**
|
|
* Fetch the file repos.
|
|
*
|
|
* @return {jQuery.Promise} Promise that resolves when the resources are set up
|
|
*/
|
|
ve.dm.MWMediaResourceQueue.prototype.getFileRepos = function () {
|
|
var defaultSource = [ {
|
|
url: mw.util.wikiScript( 'api' ),
|
|
local: ''
|
|
} ];
|
|
|
|
if ( !this.fileRepoPromise ) {
|
|
this.fileRepoPromise = new mw.Api().get( {
|
|
action: 'query',
|
|
meta: 'filerepoinfo'
|
|
} ).then(
|
|
function ( resp ) {
|
|
return resp.query && resp.query.repos || defaultSource;
|
|
},
|
|
function () {
|
|
return $.Deferred().resolve( defaultSource );
|
|
}
|
|
);
|
|
}
|
|
|
|
return this.fileRepoPromise;
|
|
};
|
|
|
|
/**
|
|
* Get image maximum height
|
|
*
|
|
* @return {string} Image max height
|
|
*/
|
|
ve.dm.MWMediaResourceQueue.prototype.getMaxHeight = function () {
|
|
return this.maxHeight;
|
|
};
|