2017-10-23 16:37:32 +00:00
|
|
|
( 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',
|
2018-09-26 23:03:20 +00:00
|
|
|
template: mw.template.get( 'skins.minerva.options', 'BackToTopOverlay.hogan' ),
|
2017-10-23 16:37:32 +00:00
|
|
|
events: $.extend( {}, View.prototype.events, {
|
|
|
|
click: 'onBackToTopClick'
|
|
|
|
} ),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the back to top element, if it's not visible already.
|
2018-08-20 23:40:40 +00:00
|
|
|
* @memberof BackToTopOverlay
|
|
|
|
* @instance
|
2017-10-23 16:37:32 +00:00
|
|
|
*/
|
|
|
|
show: function () {
|
|
|
|
this.$el.css( 'visibility', 'visible' ).addClass( 'visible' );
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hide the back to top element, if it's visible.
|
2018-08-20 23:40:40 +00:00
|
|
|
* @memberof BackToTopOverlay
|
|
|
|
* @instance
|
2017-10-23 16:37:32 +00:00
|
|
|
*/
|
|
|
|
hide: function () {
|
|
|
|
this.$el.removeClass( 'visible' );
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles the click on the "Back to top" element and scrolls back
|
|
|
|
* to the top smoothly.
|
2018-08-20 23:40:40 +00:00
|
|
|
* @memberof BackToTopOverlay
|
|
|
|
* @instance
|
2017-10-23 16:37:32 +00:00
|
|
|
*/
|
|
|
|
onBackToTopClick: function () {
|
|
|
|
$( 'html, body' ).animate( { scrollTop: 0 }, 400 );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2018-09-26 23:03:20 +00:00
|
|
|
M.define( 'skins.minerva.options/BackToTopOverlay', BackToTopOverlay );
|
2017-10-23 16:37:32 +00:00
|
|
|
|
|
|
|
}( mw.mobileFrontend, jQuery ) );
|