2014-12-16 01:06:05 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor MediaWiki Initialization ImageInfoCache class.
|
|
|
|
*
|
2018-01-03 00:54:47 +00:00
|
|
|
* @copyright 2011-2018 VisualEditor Team and others; see AUTHORS.txt
|
2014-12-16 01:06:05 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2015-04-30 16:03:30 +00:00
|
|
|
/**
|
|
|
|
* Get information about images.
|
2015-08-19 18:21:01 +00:00
|
|
|
*
|
2015-04-30 16:03:30 +00:00
|
|
|
* @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 ];
|
2017-06-30 12:51:24 +00:00
|
|
|
} else if ( 'missing' in page ) {
|
|
|
|
return { missing: true };
|
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 ) {
|
2016-02-29 16:16:34 +00:00
|
|
|
// If you change what `iiprop`s are being fetched, update
|
|
|
|
// ve.ui.MWMediaDialog to add the same ones to the cache.
|
2015-04-30 16:03:30 +00:00
|
|
|
return new mw.Api().get(
|
|
|
|
{
|
|
|
|
action: 'query',
|
|
|
|
prop: 'imageinfo',
|
|
|
|
indexpageids: '1',
|
|
|
|
iiprop: 'size|mediatype',
|
2016-09-30 16:07:10 +00:00
|
|
|
titles: subqueue
|
2015-04-30 16:03:30 +00:00
|
|
|
},
|
|
|
|
{ type: 'POST' }
|
|
|
|
);
|
|
|
|
};
|