mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-01 01:06:31 +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
27 lines
739 B
JavaScript
27 lines
739 B
JavaScript
module.exports = function () {
|
|
var BackToTopOverlay = require( './BackToTopOverlay.js' ),
|
|
backtotop = new BackToTopOverlay(),
|
|
features = mw.config.get( 'wgMinervaFeatures', {} ),
|
|
// eslint-disable-next-line no-restricted-properties
|
|
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();
|
|
}
|
|
} );
|
|
};
|