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').length) { var topOffset = 10; var windowTop = $(window).scrollTop; var tocHeight = $('#toc').outerHeight; var tocTopPos = $('#toc').offset.top; var tocBotPos = tocTopPos + tocHeight; var tocRightPos = $('#toc').offset.left + $('#toc').outerWidth; if ( $('.desktopBox > div').outerWidth === 0 ) $('.desktopBox').width(336); else $('.desktopBox').width(''); var boxWidth = $('.desktopBox').outerWidth; var boxHeight = $('.desktopBox').outerHeight; var boxRightPos = $('.desktopBox').offset.left + boxWidth + parseInt($('.desktopBox').css('right')); var boxMarginLeft = parseInt($('.desktopBox').css('marginLeft')); var blankSpace = boxRightPos - tocRightPos; $('.desktopBox').css('right', (blankSpace - boxWidth - boxMarginLeft)/2); if (tocHeight > boxHeight) if (tocTopPos - topOffset > windowTop) $('.desktopBox').css('top', 0); else if (tocBotPos - boxHeight - topOffset > windowTop) $('.desktopBox').css('top', windowTop - tocTopPos + topOffset); else $('.desktopBox').css('top', tocHeight - boxHeight); } } $(tocAdPositioner); $(window).scroll(function {	$(tocAdPositioner); }); $(window).resize(function {	clearTimeout(window.resizeFinished);	window.resizeFinished = setTimeout(function { $(tocAdPositioner); }, 100); });