User:Canadabonk/common.js: Difference between revisions

From TestWiki
Content added Content deleted
(Created page with "$(document).ready(function(){ if ($(window).width() > 850 && $('#toc') && $('body.skin-cosmos')) { mw.loader.load('https://dev.miraheze.org/wiki/User:Canadabonk/CosmosTweaks.css?action=raw&ctype=text/css'); $('#mw-content').prepend('<div class="ct-sidetools-wrapper"><div class="ct-sidetools"></div></div>'); const tocbuttonhtml = '<div class="ct-toc"><span class="ct-sidetools-button"></span></div>'; $('.ct-sidetools').append(tocbuttonhtml); const...")
 
No edit summary
Line 1: Line 1:
$(document).ready(function(){
$(document).ready(function(){
if ($(window).width() > 850 && $('#toc') && $('body.skin-cosmos')) {
if ($(window).width() > 850 && $('#toc').get(0) && $('body.skin-cosmos').get(0)) {
mw.loader.load('https://dev.miraheze.org/wiki/User:Canadabonk/CosmosTweaks.css?action=raw&ctype=text/css');
mw.loader.load('https://dev.miraheze.org/wiki/User:Canadabonk/CosmosTweaks.css?action=raw&ctype=text/css');

Revision as of 15:28, 5 June 2024

$(document).ready(function(){
	
	if ($(window).width() > 850 && $('#toc').get(0) && $('body.skin-cosmos').get(0)) {
		
		mw.loader.load('https://dev.miraheze.org/wiki/User:Canadabonk/CosmosTweaks.css?action=raw&ctype=text/css');
		
		$('#mw-content').prepend('<div class="ct-sidetools-wrapper"><div class="ct-sidetools"></div></div>');
		
		const tocbuttonhtml = '<div class="ct-toc"><span class="ct-sidetools-button"></span></div>';
		$('.ct-sidetools').append(tocbuttonhtml);
		
		const tocbutton = $('.ct-toc').find('.ct-sidetools-button');
		const faListUl = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M64 144a48 48 0 1 0 0-96 48 48 0 1 0 0 96zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H192zM64 464a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm48-208a48 48 0 1 0 -96 0 48 48 0 1 0 96 0z"/></svg>';
		tocbutton.append(faListUl);
		
		$('#toc').find('ul').clone().appendTo('.ct-toc');
		$('.ct-toc').find('ul').wrap('<div class="ct-stickytoc"></div>');
		
		const stickytoc = $('.ct-stickytoc');
		stickytoc.prepend('<div>Contents</div>');
		stickytoc.hide();
		
		tocbutton.click(function() {
			stickytoc.fadeToggle(200);
		});
	}
	
});