mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-24 07:34:11 +00:00
Hygiene: Remove unnecessary IIFE in gateway/mediawiki.js
Change-Id: If6d76c2915b13f9871dea3b7f33cb74ec5906566
This commit is contained in:
parent
0260325bb9
commit
f1e6e2bfa1
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.map
vendored
BIN
resources/dist/index.js.map
vendored
Binary file not shown.
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue