MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */

/* Fix desktop anchor ad close button */ $('body.newbie').on('click', '#ssrt-close-anchor-button', function {	$('body > .ad-sticky-wrapper').hide; });

/* Add subpages toolbox link on user pages */ $(function {	var title = mw.config.get('wgTitle');	if (mw.config.get('wgCanonicalNamespace') === 'User' && !title.includes('/') && mw.config.get('skin') !== 'timeless') {		var subpagesLink = '/Special:PrefixIndex/User:' + title + '/';		mediaWiki.util.addPortletLink('p-tb', subpagesLink, 'User subpages', 't-subpages', 'Subpages of this page');	} });

/* TOC ad unit */ function tocAdPositioner { if ($('.desktopBox').css('position') === 'relative') { var winTopPos = $(window).scrollTop; var tocHeight = $('#toc').outerHeight; var tocTopPos = $('#toc').offset.top; var tocBotPos = tocTopPos + tocHeight; if (tocBotPos > winTopPos) { var boxWidth = $('.desktopBox').outerWidth; var boxHeight = $('.desktopBox').outerHeight; var boxMarginLeft = parseFloat($('.desktopBox').css('marginLeft')); var boxRightPos = $('.desktopBox').offset.left + boxWidth + parseFloat($('.desktopBox').css('right')); var tocRightPos = $('#toc').offset.left + $('#toc').outerWidth; $('.desktopBox').css('right', (boxRightPos - tocRightPos - boxWidth - boxMarginLeft)/2); if (tocHeight > boxHeight) { var winBotPos = $(window).scrollTop + $(window).outerHeight; var curBotPos = winBotPos > tocBotPos ? tocBotPos : winBotPos; var topOffset = (curBotPos - winTopPos - boxHeight)/4; if (tocTopPos - topOffset > winTopPos) $('.desktopBox').css('top', 0); else if (tocBotPos - boxHeight - topOffset > winTopPos) $('.desktopBox').css('top', winTopPos - tocTopPos + topOffset); else $('.desktopBox').css('top', tocHeight - boxHeight); }		}	} } $(function {	if ($('.desktopBox').length) {		$(tocAdPositioner);		$(window).on('scroll resize', function { $(tocAdPositioner); });	} });