2018-11-16 15:16:25 +00:00
|
|
|
( function ( M ) {
|
2017-10-23 16:37:32 +00:00
|
|
|
|
2018-11-22 19:10:40 +00:00
|
|
|
var View = M.require( 'mobile.startup/View' ),
|
|
|
|
util = M.require( 'mobile.startup/util' );
|
2017-10-23 16:37:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a little arrow at the bottom right of the viewport.
|
|
|
|
* @class BackToTopOverlay
|
|
|
|
* @extends View
|
2018-11-22 19:10:40 +00:00
|
|
|
* @param {Object} props
|
2017-10-23 16:37:32 +00:00
|
|
|
*/
|
2018-11-22 19:10:40 +00:00
|
|
|
function BackToTopOverlay( props ) {
|
|
|
|
View.call( this,
|
|
|
|
util.extend( {}, props, {
|
|
|
|
className: 'backtotop'
|
|
|
|
} )
|
|
|
|
);
|
2017-10-23 16:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OO.mfExtend( BackToTopOverlay, View, {
|
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
|
|
|
|
2018-11-16 15:16:25 +00:00
|
|
|
}( mw.mobileFrontend ) );
|