mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-28 16:10:55 +00:00
eaa2692da0
Given the level of documentation in this repo is extremely low now seems a good as time as any. The resulting documentation is a vast improvement on before grouping functions to an owner and introducing module names. We can iterate on the documentation over time. Bug: T138401 Change-Id: I9e787d40931d3d72a7037ce07d3ab0db8e72d825
48 lines
1.1 KiB
JavaScript
48 lines
1.1 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
|
|
* @module skins.minerva.backtotop/BackToTopOverlay
|
|
*/
|
|
function BackToTopOverlay() {
|
|
View.apply( this, arguments );
|
|
}
|
|
|
|
OO.mfExtend( BackToTopOverlay, View, {
|
|
className: 'backtotop',
|
|
template: mw.template.get( 'skins.minerva.backtotop', 'BackToTopOverlay.hogan' ),
|
|
events: $.extend( {}, View.prototype.events, {
|
|
click: 'onBackToTopClick'
|
|
} ),
|
|
|
|
/**
|
|
* Show the back to top element, if it's not visible already.
|
|
*/
|
|
show: function () {
|
|
this.$el.css( 'visibility', 'visible' ).addClass( 'visible' );
|
|
},
|
|
|
|
/**
|
|
* Hide the back to top element, if it's visible.
|
|
*/
|
|
hide: function () {
|
|
this.$el.removeClass( 'visible' );
|
|
},
|
|
|
|
/**
|
|
* Handles the click on the "Back to top" element and scrolls back
|
|
* to the top smoothly.
|
|
*/
|
|
onBackToTopClick: function () {
|
|
$( 'html, body' ).animate( { scrollTop: 0 }, 400 );
|
|
}
|
|
} );
|
|
|
|
M.define( 'skins.minerva.backtotop/BackToTopOverlay', BackToTopOverlay );
|
|
|
|
}( mw.mobileFrontend, jQuery ) );
|