mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-17 03:08:12 +00:00
ef5003f310
The MobileFrontend dependency in Minerva is problematic. Code that Minerva needs should live in core. MobileFrontend should load code on all skins when they operate on a mobile domain. This eslint check reminds developers of this in a hope it encourages more upstreaming to core when possible. Of course disabling is also an option, but this check will at least make us aware of when we are moving further away from the goal. Change-Id: I62183c9aefc81053e4ad81fb746decef2dd24b44
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
module.exports = function () {
|
|
// eslint-disable-next-line no-restricted-properties
|
|
var M = mw.mobileFrontend,
|
|
mobile = M.require( 'mobile.startup' ),
|
|
references = mobile.references,
|
|
currentPage = mobile.currentPage(),
|
|
currentPageHTMLParser = mobile.currentPageHTMLParser(),
|
|
ReferencesHtmlScraperGateway = mobile.ReferencesHtmlScraperGateway,
|
|
gateway = new ReferencesHtmlScraperGateway( new mw.Api() );
|
|
|
|
/**
|
|
* Event handler to show reference when a reference link is clicked
|
|
* @ignore
|
|
* @param {JQuery.Event} ev Click event of the reference element
|
|
*/
|
|
function showReference( ev ) {
|
|
var urlComponents,
|
|
$dest = $( ev.currentTarget ),
|
|
href = $dest.attr( 'href' );
|
|
|
|
ev.preventDefault();
|
|
|
|
// If necessary strip the URL portion of the href so we are left with the
|
|
// fragment
|
|
urlComponents = href.split( '#' );
|
|
if ( urlComponents.length > 1 ) {
|
|
href = '#' + urlComponents[ 1 ];
|
|
}
|
|
references.showReference( href, currentPage, $dest.text(),
|
|
currentPageHTMLParser, gateway );
|
|
}
|
|
|
|
/**
|
|
* Event handler to show reference when a reference link is clicked.
|
|
* Delegates to `showReference` once the references drawer is ready.
|
|
*
|
|
* @ignore
|
|
* @param {JQuery.Event} ev Click event of the reference element
|
|
*/
|
|
function onClickReference( ev ) {
|
|
showReference( ev );
|
|
}
|
|
|
|
function init() {
|
|
// Make references clickable and show a drawer when clicked on.
|
|
mobile.util.getDocument().on( 'click', 'sup.reference a', onClickReference );
|
|
}
|
|
|
|
init();
|
|
};
|