MediaWiki:Gadget-snapToTop.js

From Tardis Wiki, the free Doctor Who reference
Revision as of 15:03, 31 July 2024 by Bongolium500 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Clear your cache often around here

After changes are made to this site's CSS or Javascript, you have to bypass your browser's cache to see the changes. You can always do this by going to your browser's preferences panel. But many browsers also offer keyboard shortcuts to save you that trouble. The following shortcuts work in the versions of the browsers that Tardis currently supports. They may not work in earlier versions.

  • Firefox: hold down Shift while performing a page reload.
  • Opera offers no default keyboard shortcut, but you can create a custom keyboard shortcut with the value Clear disk cache
  • Safari users should simultaneously hold down + Option + E. You may need to enable the Develop menu first
  • Chrome: press Ctrl + F5 or Shift + F5 while performing a page reload.
/* From https://fallout.wiki/wiki/MediaWiki:Common.js under CC B-SA 3.0 (https://creativecommons.org/licenses/by-sa/3.0/)
* @rev 4 (2021-05-08)
* @author Kwj2772
* @contributor Perhelion */
$(function () {
'use strict';

var $icon = 'https://tardis.wiki/w/images/Tardis_Images/3/3e/Back_to_top_button_image.png';

$icon = $('<img>', {
	src: $icon,
	id: 'scrollUpButton',
	class: 'noprint'
}).css({
	}).on('click', function () {
		// Move to the top of the page
		$('html, body').animate({ scrollTop: 0 }, 660);
	}).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() > 80) $icon.fadeIn('fast');
	else $icon.fadeOut('slow');
});

}());