MediaWiki:Common.js

From DREDGE Wiki
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */

mw.loader.getScript( 'https://commons.wiki.gg/index.php?title=MediaWiki:Common-base.js&action=raw&ctype=text/javascript' );
mw.loader.load("https://commons.wiki.gg/wiki/MediaWiki:DiscordIntegrator.js?action=raw\u0026ctype=text/javascript");
/*
==========================================
Scroll detector for the fadeInUp animation
==========================================
*/
$( document ).ready(function() { 

$(window).scroll(function() { 
	$('.fadeInUpObject').each(function(){ 
	var imagePos = $(this).offset().top; 
	
	var topOfWindow = $(window).scrollTop(); 
		if (imagePos < topOfWindow+600) { 
			$(this).addClass("fadeInUp"); 
		}
			
	});
		
});

});


/* 
==========================================
Scroll detector for the pullDown animation 
==========================================
*/ 

$( document ).ready(function() { //when the page has loaded,

$(window).scroll(function() { 
	$('.pullDownObject').each(function(){ //For each element with the class "pullDownObject",
	var imagePos = $(this).offset().top; 
	
	var topOfWindow = $(window).scrollTop(); //(Defining topOfWindow)
		if (imagePos < topOfWindow+600) { //If the element is 600px away from topOfWindow,
			$(this).addClass("pullDown"); //Add the "pullDown" class to it, giving it the animation
		}
			
	});
		
});

});

/* Note that the pullDown class is defined elsewhere, in the wiki's CSS page */
/* [[Template:SpoilerText]] */
$(function () {
	$('.spoiler-content')
	.off('click') // in case this code is loaded twice
	.on('click', function(e){
		$(this).toggleClass('show');
	}).find('a').on('click', function(e){
		e.stopPropagation();
	});

});
/* End Template:SpoilerText */