mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-28 08:00:32 +00:00
c8693b6789
These will soon throw warnings and soon be removed! Bug: T209007 Change-Id: Idca4c892366dc5b5e8490f1326188b97abc876f7
58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
( function ( M ) {
|
|
|
|
var View = M.require( 'mobile.startup/View' ),
|
|
util = M.require( 'mobile.startup/util' );
|
|
|
|
/**
|
|
* Displays a little arrow at the bottom right of the viewport.
|
|
* @class BackToTopOverlay
|
|
* @extends View
|
|
* @param {Object} props
|
|
*/
|
|
function BackToTopOverlay( props ) {
|
|
View.call( this,
|
|
util.extend( {}, props, {
|
|
className: 'backtotop'
|
|
} )
|
|
);
|
|
}
|
|
|
|
OO.mfExtend( BackToTopOverlay, View, {
|
|
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 ) );
|