mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-15 02:13:49 +00:00
59fe37cde1
Bug: T217295 Depends-On: I2ef762dbc1458411dd8ed746b7e829a2924740e3 Change-Id: Ia90ba47f152315fd39da368edac986b55f8bd5a0
50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
module.exports = function () {
|
|
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();
|
|
};
|