MediaWiki:Mobile.js

/* Any JavaScript here will be loaded for users using the mobile site */

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

/* Add subpages link on user pages */ $(function {	var namespace = mw.config.get('wgCanonicalNamespace');	var title = mw.config.get('wgTitle');	if (namespace === 'User' && title.indexOf('/') < 0)		$('.user-links').append(' Subpages'); });

/* Adjust margin of thumbs with no caption */ function thumbFixer { $('.thumb').each(function(i, obj) {		if (!$(this).find('.thumbcaption').text) {			if (window.matchMedia('all and (max-width: 719px)').matches)				$(this).css('margin-bottom', '0.75em');			else				$(this).css('margin-bottom', '');		}	}); } $(thumbFixer); $(window).resize(function {	$(thumbFixer); });

/* Adjust table of contents to fit with infobox */ $(function {	var body = $('#bodyContent');	var infobox = $('.infobox');

if (infobox) { var maxWidth = Math.round(body.width - infobox.outerWidth(true) - 10); $('head').append('.toc-mobile { max-width: ' + maxWidth + 'px; } '); } }); function tocResizer {	var body = $('#bodyContent');	var infobox = $('.infobox');	var toc = $('.toc-mobile');

if (infobox && toc) { var maxWidth = Math.round(body.width - infobox.outerWidth(true) - 10); toc.css('max-width', maxWidth); } } $(window).resize(function {	$(tocResizer); });

/* MarioWiki: Position top-right icons on wide screens */ function wideGameIcons { if (window.matchMedia('screen and (min-width: 1000px)').matches) { var goRight = Math.round(($(window).width - 1000)/2); $('.top-right').css('right', goRight); } else { $('.top-right').css('right', ''); } } $(wideGameIcons); $(window).resize(function {	$(wideGameIcons); });