Site Notice

Remember to pay a visit to our Discord server and chat with our community! See here for more info.

Be sure to check out the KHUX Wiki for the latest on Kingdom Hearts Union χ and Kingdom Hearts Dark Road! Go and pitch in!

The KHWiki contains spoilers for all Kingdom Hearts games. Read at your own risk.

Please remember not to add information about unreleased games from trailers.

MediaWiki:Common.js: Difference between revisions

From the Kingdom Hearts Wiki, the Kingdom Hearts encyclopedia
Jump to navigationJump to search
No edit summary
No edit summary
Line 51: Line 51:
if (document.getElementsByClassName('mw-redirectedfrom')[0])
if (document.getElementsByClassName('mw-redirectedfrom')[0])
$('#title-linktabs').css('top', '-36px');
$('#title-linktabs').css('top', '-36px');
if (document.getElementsByClassName('usermessage')[0])
else if (document.getElementsByClassName('usermessage')[0])
$('#title-linktabs').css('top', '-48px');
$('#title-linktabs').css('top', '-48px');
}
}

Revision as of 14:20, 20 March 2020

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

/* Alternating wiki logo */
$(function() {
	var logos = ['/images/b/bc/Wiki.png', '/images/9/97/Wiki_3.png', '/images/d/d7/Wiki_2.png'];
	$('#p-logo a').css('background-image', 'url(' + logos[Math.floor(Math.random() * logos.length)] + ')');
});

/* Hide page previews when portals are used */
$(function() {
	if (document.getElementsByClassName('nav')[0] && document.getElementsByClassName('dropdown')[0])
		$('head').append('<style type="text/css">.mwe-popups { display: none !important; }</style>');
});

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

/* Username inserts for the USERNAME template */
$(function() {
	if (typeof(disableUsernameReplace) != 'undefined' && disableUsernameReplace || mw.config.get('wgUserName') == null) return;
	$('span.insertusername').each(function() {
		$(this).text(mw.config.get('wgUserName'));
	});
});

/* Fix game icons */
$(function() {
	if (document.getElementById('title-linktabs')) {
		if (document.getElementsByClassName('mw-redirectedfrom')[0])
			$('#title-linktabs').css('top', '-36px');
		else if (document.getElementsByClassName('usermessage')[0])
			$('#title-linktabs').css('top', '-48px');
	}
});

/* Shrinking talk bubble sprites */
$(function() {
	if (document.readyState != "complete") {
		setTimeout(arguments.callee, 100);
		return;
	}
	$("table.talkbubble").each(function() {
		$(this).find("td").first().width(90).css("text-align", "center").find("img").each(function () {
			if ($(this).width() > 90) $(this).css("height", "auto").width(90);
		});
	});
});

/* Code for Template:Suite3 - Author: Soxra */
$(function() {
	$(".morphMaster").each(function() {
		var $master = $(this);
		var $tabs = $master.find(".morphTabBox");
		var $container = $master.find(".morphTabContainer");

		$tabs.find(".morphLink").click(function() {
			var id = $(this).attr("id");
			id = id.substr(0, id.length - 4);
			$container.find(".morphContent").hide();
			$container.find("#" + id + "Content").show();
		});
	});
});