mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-13 14:48:28 +00:00
b9862d7d24
I want to remove the need for M.define in the Minerva repository. It's no longer necessary with packageFiles and will help tame a lot of the code we have here! Change-Id: If6a35a23e84a44adb965fd9c41265ba37eb8368e
26 lines
684 B
JavaScript
26 lines
684 B
JavaScript
module.exports = function () {
|
|
var BackToTopOverlay = require( './BackToTopOverlay.js' ),
|
|
backtotop = new BackToTopOverlay(),
|
|
features = mw.config.get( 'wgMinervaFeatures', {} ),
|
|
M = mw.mobileFrontend,
|
|
mobile = M.require( 'mobile.startup' ),
|
|
browser = mobile.Browser.getSingleton(),
|
|
eventBus = mobile.eventBusSingleton;
|
|
|
|
// check if browser user agent is iOS (T141598)
|
|
if ( browser.isIos() || !features.backToTop ) {
|
|
return;
|
|
}
|
|
|
|
// initialize the back to top element
|
|
backtotop.appendTo( 'body' );
|
|
|
|
eventBus.on( 'scroll', function () {
|
|
if ( $( window ).height() - $( window ).scrollTop() <= 0 ) {
|
|
backtotop.show();
|
|
} else {
|
|
backtotop.hide();
|
|
}
|
|
} );
|
|
};
|