MediaWiki:Common.js

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

/* Fix media negative margin bug for wide galleries */ $('.gallerybox audio').each(function(i, obj) {	if ($(this).parent.css('margin-top') < '15px')		$(this).parent.css('margin', '15px auto'); });

/* 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 namespace = mw.config.get('wgCanonicalNamespace');	var title = mw.config.get('wgTitle');	if (namespace === 'User' && title.indexOf('/') < 0) {		var subpagesLink = '/Special:PrefixIndex/User:' + title + '/';		mediaWiki.util.addPortletLink('p-tb', subpagesLink, 'User subpages', 't-subpages', 'Subpages of this page');	} });

/* Fix top-right links */ $(function {	if (document.getElementsByClassName('top-right')[0]) {		if (document.getElementsByClassName('mw-redirectedfrom')[0])			$('.top-right').css('top', '-32px');		if (document.getElementsByClassName('usermessage')[0])			$('.top-right').css('top', '-44px');	}	if (document.getElementsByClassName('top-right-text')[0]) {		if (document.getElementsByClassName('mw-redirectedfrom')[0])			$('.top-right-text').css('top', '-23px');		if (document.getElementsByClassName('usermessage')[0])			$('.top-right-text').css('top', '-35px');	} });

/* Add a drop-down menu for CheckUser reasons */ function checkUserOther(name) { if (name == 'Other') { var menu = document.getElementById('checkreason'); var field = ''; menu.outerHTML = field; } } $(function {	if (mw.config.get('wgCanonicalSpecialPageName') === 'CheckUser') {		var field = document.getElementById('checkreason');		var menu = 'Please select a reason... Routine new user check Suspected sockpuppet account Matching a vandal account Other ';		field.outerHTML = menu;	} });

/* Put main page MWE box and filler links on shorter side */ $(function {	function mainPageMaintain {		var leftHeight = $('#featured').outerHeight(true) + $('#poll').outerHeight(true) + $('#shroom').outerHeight(true);		var rightHeight = $('#news').outerHeight(true) + $('#dyk').outerHeight(true);		if (leftHeight < rightHeight) {			$('#mwe-left').show;			$('#mwe-right').hide;			leftHeight = leftHeight + $('#mwe-left').outerHeight(true);		} else {			$('#mwe-right').show;			$('#mwe-left').hide;			rightHeight = rightHeight + $('#mwe-right').outerHeight(true);		}		var i, len, heightDif;		var 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);			}		}); } });