2019-07-05 22:21:34 +00:00
|
|
|
module.exports = function () {
|
|
|
|
var BackToTopOverlay = require( './BackToTopOverlay.js' ),
|
2017-07-12 15:12:40 +00:00
|
|
|
backtotop = new BackToTopOverlay(),
|
2018-09-26 23:03:20 +00:00
|
|
|
features = mw.config.get( 'wgMinervaFeatures', {} ),
|
2019-07-05 22:21:34 +00:00
|
|
|
M = mw.mobileFrontend,
|
2019-02-07 16:34:18 +00:00
|
|
|
mobile = M.require( 'mobile.startup' ),
|
|
|
|
browser = mobile.Browser.getSingleton(),
|
|
|
|
eventBus = mobile.eventBusSingleton;
|
2017-07-12 15:12:40 +00:00
|
|
|
|
|
|
|
// check if browser user agent is iOS (T141598)
|
2018-09-26 23:03:20 +00:00
|
|
|
if ( browser.isIos() || !features.backToTop ) {
|
2017-07-12 15:12:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// initialize the back to top element
|
|
|
|
backtotop.appendTo( 'body' );
|
|
|
|
|
2018-12-04 22:13:38 +00:00
|
|
|
eventBus.on( 'scroll', function () {
|
2017-07-12 15:12:40 +00:00
|
|
|
if ( $( window ).height() - $( window ).scrollTop() <= 0 ) {
|
|
|
|
backtotop.show();
|
|
|
|
} else {
|
|
|
|
backtotop.hide();
|
|
|
|
}
|
|
|
|
} );
|
2019-07-05 22:21:34 +00:00
|
|
|
};
|