MediaWiki:Common.js: Difference between revisions

m
no edit summary
No edit summary
mNo edit summary
 
(38 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)] + ')');
});
});


/* Fix game icons when new user message */
/* Add user subpages toolbox link */
$(function() {
$(function() {
if (document.getElementsByClassName('usermessage')[0] && document.getElementById('title-linktabs'))
if (mw.config.get('wgCanonicalNamespace') === 'User' && mw.config.get('skin') !== 'timeless') {
$('#title-linktabs').css('top', '-48px');
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 */
/* Hide page previews when portals are used */
$(function() {
$(function() {
if (document.getElementsByClassName('nav')[0] && document.getElementsByClassName('dropdown')[0]) {
if (document.getElementsByClassName('nav')[0] && document.getElementsByClassName('dropdown')[0])
$('head').append('<style type="text/css">.mwe-popups { display: none !important; }</style>');
$('head').append('<style type="text/css">.mwe-popups { display: none !important; }</style>');
}
});
/* 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'));
});
});
/* Automatically add aboutfile template to file upload description */
$(function() {
if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !document.getElementById('wpForReUpload') && !document.getElementsByClassName('mw-destfile-warning')[0] && !document.getElementsByClassName('error')[0]) {
uploadDescription = document.getElementById('wpUploadDescription');
var doubleBracket = '{' + '{';
uploadDescription.value = doubleBracket + 'aboutfile\n|description=\n|purpose=\n|game=\n|source=\n}}';
}
});
/* Fix tabbers which incorrectly have their width set to their tabbertabs */
$('.tabber').each(function(i, obj) {
if (!$(this).prop('style').width) {
var tabbertabWidth = $(this).find('.tabbertab').prop('style').width;
if (tabbertabWidth)
$(this).css('width', tabbertabWidth);
}
});
});


Line 53: 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);
});
});