MediaWiki:Common.js: Difference between revisions

From the Kingdom Hearts Wiki, the Kingdom Hearts encyclopedia
Jump to navigationJump to search
No edit summary
mNo edit summary
 
(25 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on desktop */


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


/* Hide page previews when portals are used */
/* Add user subpages toolbox link */
$(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() {
$(function() {
if (mw.config.get('wgTitle') === 'Main Page') {
if (mw.config.get('wgCanonicalNamespace') === 'User' && mw.config.get('skin') !== 'timeless') {
$('div[id^="mf-"]').each(function(i, obj) {
var subpagesLink = '/Special:PrefixIndex/User:' + mw.config.get('wgTitle').split('/')[0] + '/';
$(this).removeAttr('title');
mw.util.addPortletLink('p-tb', subpagesLink, 'User subpages', 't-subpages', 'Subpages for this user');
});
}
}
});
});


/* Add subpages toolbox link on user pages */
/* Hide page previews when portals are used */
$(function() {
$(function() {
var namespace = mw.config.get('wgCanonicalNamespace');
if (document.getElementsByClassName('nav')[0] && document.getElementsByClassName('dropdown')[0])
var title = mw.config.get('wgTitle');
$('head').append('<style type="text/css">.mwe-popups { display: none !important; }</style>');
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');
}
});
});


Line 63: Line 28:
}
}
$("table.talkbubble").each(function() {
$("table.talkbubble").each(function() {
$(this).find("td").first().width(90).css("text-align", "center").find("img").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);
if ($(this).width() > 90) $(this).css("height", "auto").width(90);
});
});

Latest revision as of 20:17, 3 April 2024

/* Any JavaScript here will be loaded for all users on desktop */

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

/* Add user subpages toolbox link */
$(function() {
	if (mw.config.get('wgCanonicalNamespace') === 'User' && mw.config.get('skin') !== 'timeless') {
		var subpagesLink = '/Special:PrefixIndex/User:' + mw.config.get('wgTitle').split('/')[0] + '/';
		mw.util.addPortletLink('p-tb', subpagesLink, 'User subpages', 't-subpages', 'Subpages for this user');
	}
});

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

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