MediaWiki:Gadget-ScrollUpButton.js

/* scrollUpButton /* global $:false */ $(function { 'use strict';
 * Add a button to scroll up to the top of the current page.
 * @rev 3 (2019-28-07)
 * @author Kwj2772
 * @contributor Perhelion
 * No internationalisation required

var $icon = 'https://static.jojowiki.com/images/customizations/Font_Awesome_5_regular_arrow-circle-up_blue.svg';

if (!document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#Image', '1.1')) $icon = 'https://static.jojowiki.com/images/customizations/32px-Font_Awesome_5_regular_arrow-circle-up_blue.svg.png';

$icon = $(' ', {	src: $icon,	id: 'scrollUpButton' }).css({		position: 'fixed',		bottom: '24px',		right: '18px',		opacity: 0.7,		cursor: 'pointer',		display: 'none'	}).on('click', function {		// Move to the top of the page		$('html, body').animate({ scrollTop: 0 }, 160);	}).on('mouseenter mouseleave', function (e) {		this.style.opacity = e.type === 'mouseenter' ? 1 : 0.7;	}).appendTo('body');

$(window).on('scroll', function {	// Fade out if you reach the top of the page	if ($(this).scrollTop > 60) $icon.fadeIn('slow');	else $icon.fadeOut('slow'); });

}); //