mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-24 22:25:27 +00:00
cbad0bd363
It's presumed that skin options will eventually become the default or be removed from the skin. While they are not the default, it would be helpful to package them in one single module - as ResourceLoader modules are costly bloating the dependency graph in the MediaWiki startup module. In T167713 we talked about grouping our entry points by page rather than feature, which this seems consistent with. A page with special options enabled is different from a page without. Change-Id: Id948f913d4743532ba3442d2059a03c122419ff2
53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
( function ( M, $ ) {
|
|
|
|
var View = M.require( 'mobile.startup/View' );
|
|
|
|
/**
|
|
* Displays a little arrow at the bottom right of the viewport.
|
|
* @class BackToTopOverlay
|
|
* @extends View
|
|
*/
|
|
function BackToTopOverlay() {
|
|
View.apply( this, arguments );
|
|
}
|
|
|
|
OO.mfExtend( BackToTopOverlay, View, {
|
|
className: 'backtotop',
|
|
template: mw.template.get( 'skins.minerva.options', 'BackToTopOverlay.hogan' ),
|
|
events: $.extend( {}, View.prototype.events, {
|
|
click: 'onBackToTopClick'
|
|
} ),
|
|
|
|
/**
|
|
* Show the back to top element, if it's not visible already.
|
|
* @memberof BackToTopOverlay
|
|
* @instance
|
|
*/
|
|
show: function () {
|
|
this.$el.css( 'visibility', 'visible' ).addClass( 'visible' );
|
|
},
|
|
|
|
/**
|
|
* Hide the back to top element, if it's visible.
|
|
* @memberof BackToTopOverlay
|
|
* @instance
|
|
*/
|
|
hide: function () {
|
|
this.$el.removeClass( 'visible' );
|
|
},
|
|
|
|
/**
|
|
* Handles the click on the "Back to top" element and scrolls back
|
|
* to the top smoothly.
|
|
* @memberof BackToTopOverlay
|
|
* @instance
|
|
*/
|
|
onBackToTopClick: function () {
|
|
$( 'html, body' ).animate( { scrollTop: 0 }, 400 );
|
|
}
|
|
} );
|
|
|
|
M.define( 'skins.minerva.options/BackToTopOverlay', BackToTopOverlay );
|
|
|
|
}( mw.mobileFrontend, jQuery ) );
|