Fix issues pointed out by aarcos

See https://gerrit.wikimedia.org/r/#/c/95282/10/resources/ext.multimediaViewer/ext.multimediaViewer.js

A few issues with code being in two places; should probably refactor but
would prefer to get out a fix and refactor a little later.

Change-Id: Id74a01e177aeb09fe34416e7fd14759df58fda32
This commit is contained in:
Mark Holmquist 2014-01-06 11:43:18 -08:00
parent d883ffa3c9
commit 85d08e1d27

View file

@ -238,7 +238,9 @@
/**
* Gets the API arguments for various calls to the API to find sized thumbnails.
* @param {mw.LightboxInterface} ui
* @returns {number}
* @returns {Object}
* @returns {number} return.requested The width that should be requested from the API
* @returns {number} return.target The ideal width we would like to have - should be the width of the image element later.
*/
MMVP.getImageSizeApiArgs = function ( ui ) {
var requestedWidth, calculatedMaxWidth,
@ -304,7 +306,7 @@
*/
MMVP.resize = function ( ui ) {
var viewer = this,
filename = ui.currentImageFilename,
filename = this.currentImageFilename,
apiArgs = {
action: 'query',
format: 'json',
@ -313,7 +315,11 @@
iiprop: 'url'
},
targetWidth = this.getImageSizeApiArgs( ui, apiArgs );
widths = this.getImageSizeApiArgs( ui ),
targetWidth = widths.target,
requestedWidth = widths.requested;
apiArgs.iiurlwidth = requestedWidth;
this.api.get( apiArgs ).done( function ( data ) {
viewer.loadResizedImage( ui, data, targetWidth );