2014-12-16 01:06:05 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor MediaWiki Initialization ImageInfoCache class.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2015-04-30 16:03:30 +00:00
|
|
|
/**
|
|
|
|
* Get information about images.
|
|
|
|
* @class
|
|
|
|
* @extends ve.init.mw.ApiResponseCache
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
ve.init.mw.ImageInfoCache = function VeInitMwImageInfoCache() {
|
|
|
|
ve.init.mw.ImageInfoCache.super.call( this );
|
|
|
|
};
|
2015-04-29 16:58:34 +00:00
|
|
|
|
2015-04-30 16:03:30 +00:00
|
|
|
/* Inheritance */
|
2014-12-16 01:06:05 +00:00
|
|
|
|
2015-04-30 16:03:30 +00:00
|
|
|
OO.inheritClass( ve.init.mw.ImageInfoCache, ve.init.mw.ApiResponseCache );
|
2015-04-29 16:58:34 +00:00
|
|
|
|
2015-04-30 16:03:30 +00:00
|
|
|
/* Static methods */
|
2015-04-29 16:58:34 +00:00
|
|
|
|
2015-04-30 16:03:30 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.init.mw.ImageInfoCache.static.processPage = function ( page ) {
|
|
|
|
if ( page.imageinfo ) {
|
2015-08-19 17:33:02 +00:00
|
|
|
return page.imageinfo[ 0 ];
|
2015-04-30 16:03:30 +00:00
|
|
|
}
|
|
|
|
};
|
2015-04-29 16:58:34 +00:00
|
|
|
|
2015-04-30 16:03:30 +00:00
|
|
|
/* Methods */
|
2014-12-16 01:06:05 +00:00
|
|
|
|
2015-04-30 16:03:30 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.init.mw.ImageInfoCache.prototype.getRequestPromise = function ( subqueue ) {
|
|
|
|
return new mw.Api().get(
|
|
|
|
{
|
|
|
|
action: 'query',
|
|
|
|
prop: 'imageinfo',
|
|
|
|
indexpageids: '1',
|
|
|
|
iiprop: 'size|mediatype',
|
|
|
|
titles: subqueue.join( '|' )
|
|
|
|
},
|
|
|
|
{ type: 'POST' }
|
|
|
|
);
|
|
|
|
};
|