MediaWiki:Common.js
From the Kingdom Hearts Wiki, the Kingdom Hearts encyclopedia
Jump to navigationJump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* 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/d/d7/Wiki_2.png', '/images/9/97/Wiki_3.png', '/images/6/6a/Wiki_4.png', '/images/7/79/Wiki_5.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');
});
/* Default Special:ReplaceText to not announce edits */
$(function() {
if (mw.config.get('wgCanonicalSpecialPageName') === 'ReplaceText')
$('input[id="doAnnounce"]').prop('checked', false);
});
/* Default Special:UserMerge to user deletion */
$(function() {
if (mw.config.get('wgCanonicalSpecialPageName') === 'UserMerge') {
$('input[name="wpnewuser"]').val('Anonymous');
$('input[name="wpdelete"]').prop('checked', true);
}
});
/* 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'));
});
});
/* 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('/')) {
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);
/* 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();
});
});
});