Hygiene: Remove unnecessary IIFE in gateway/mediawiki.js

Change-Id: If6d76c2915b13f9871dea3b7f33cb74ec5906566
This commit is contained in:
joakin 2017-02-14 21:16:55 +01:00
parent 0260325bb9
commit f1e6e2bfa1
3 changed files with 89 additions and 92 deletions

Binary file not shown.

Binary file not shown.

View file

@ -1,17 +1,16 @@
( function ( mw ) {
var EXTRACT_LENGTH = 525,
var EXTRACT_LENGTH = 525,
// Public and private cache lifetime (5 minutes)
CACHE_LIFETIME = 300;
CACHE_LIFETIME = 300,
createModel = require( '../preview/model' ).createModel;
/**
/**
* MediaWiki API gateway factory
*
* @param {mw.Api} api
* @param {mw.ext.constants } config
* @param {mw.ext.constants} config
* @returns {ext.popups.Gateway}
*/
function createMediaWikiApiGateway( api, config ) {
function createMediaWikiApiGateway( api, config ) {
/**
* Fetch page data from the API
@ -65,9 +64,9 @@
convertPageToModel: convertPageToModel,
getPageSummary: getPageSummary
};
}
}
/**
/**
* Extract page data from the MediaWiki API response
*
* @param {Object} data API response data
@ -75,7 +74,7 @@
* i.e. if the response is empty,
* @returns {Object}
*/
function extractPageFromResponse( data ) {
function extractPageFromResponse( data ) {
if (
data.query &&
data.query.pages &&
@ -85,16 +84,16 @@
}
throw new Error( 'API response `query.pages` is empty.' );
}
}
/**
/**
* Transform the MediaWiki API response to a preview model
*
* @param {Object} page
* @returns {ext.popups.PreviewModel}
*/
function convertPageToModel( page ) {
return mw.popups.preview.createModel(
function convertPageToModel( page ) {
return createModel(
page.title,
page.canonicalurl,
page.pagelanguagehtmlcode,
@ -102,8 +101,6 @@
page.extract,
page.thumbnail
);
}
}
module.exports = createMediaWikiApiGateway;
}( mediaWiki ) );
module.exports = createMediaWikiApiGateway;