MediaWiki:Common.js

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

/* Remove mobile title tags on desktop main page */ $(function {	if (mw.config.get('wgTitle') === 'Main Page') {		$('div[id^="mf-"]').each(function(i, obj) { $(this).removeAttr('title'); });	} });

/* 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');	} });

/* Add autocollapse support to mw-collapsible */ function mwCollapsibleSetup($collapsibleContent) { var $element, autoCollapseThreshold = 2; $.each($collapsibleContent, function (index, element) {		$element = $(element);		if ($collapsibleContent.length >= autoCollapseThreshold && $element.hasClass('autocollapse'))			$element.data('mw-collapsible').collapse;	}); } mw.hook('wikipage.collapsibleContent').add(mwCollapsibleSetup);

/* Balance main page Shroom/MWE boxes and filler links */ $(function {	function mainPageMaintain {		var leftHeight = $('#featured').outerHeight(true) + $('#poll').outerHeight(true);		var rightHeight = $('#news').outerHeight(true) + $('#dyk').outerHeight(true);		var i, len; var divIds = ['shroom', 'mwe'];		for (i = 0, len = divIds.length; i < len; ++i) {			if (leftHeight < rightHeight) {				$('#' + divIds[i] + '-left').show;				$('#' + divIds[i] + '-right').hide;				leftHeight = leftHeight + $('#' + divIds[i] + '-left').outerHeight(true);			} else {				$('#' + divIds[i] + '-right').show;				$('#' + divIds[i] + '-left').hide;				rightHeight = rightHeight + $('#' + divIds[i] + '-right').outerHeight(true);			}		}		var heightDif; divIds = ['maintain', 'rc', 'random', 'faq', 'editing'];		for (i = 0, len = divIds.length; i < len; ++i) {			heightDif = Math.abs(leftHeight - rightHeight);			if (heightDif > 26) {				if ( leftHeight < rightHeight ) { $('#' + divIds[i] + '-left').show; $('#' + divIds[i] + '-right').hide; leftHeight = leftHeight + $('#' + divIds[i] + '-left').outerHeight(true); } else { $('#' + divIds[i] + '-right').show; $('#' + divIds[i] + '-left').hide; rightHeight = rightHeight + $('#' + divIds[i] + '-right').outerHeight(true); }			} else { $('#' + divIds[i] + '-left').hide; $('#' + divIds[i] + '-right').hide; }		}	}	if (mw.config.get('wgTitle') === 'Main Page') { $(mainPageMaintain); $(window).resize(function {			if (document.getElementsByClassName('pollspinner')[0]) {				setTimeout(function { $(mainPageMaintain); }, 500);			} else {				$(mainPageMaintain);			}		}); } });