MediaWiki:Gadget-MobileScript.js: Difference between revisions
From the Super Mario Wiki, the Mario encyclopedia
Jump to navigationJump to search
(Created page with "→Any JavaScript here will be loaded for users of the mobile site: ") |
No edit summary |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for users of the mobile site */ | /* Any JavaScript here will be loaded for users of the mobile site */ | ||
/* Collapse boxes on smaller devices */ | |||
function mwMobileCollapse($collapsibleContent) { | |||
if ($(window).width() < 720) | |||
$.each($collapsibleContent, function (index, element) { | |||
$(element).data('mw-collapsible').collapse(); | |||
}); | |||
} | |||
mw.hook('wikipage.collapsibleContent').add(mwMobileCollapse); | |||
/* MarioWiki: Move navboxes to dedicated section */ | |||
$(function() { | |||
if ($('.navbox-section').length) { | |||
$('section > .navbox').detach().appendTo('.navbox-section'); | |||
$('.nav-right').clone().appendTo('.navbox-section'); | |||
if ($.trim($('.navbox-section').text()) == '') { | |||
$('.navbox-heading').attr('style', 'display:none !important'); | |||
$('.navbox-section').attr('style', 'display:none !important'); | |||
} | |||
} | |||
}); | |||
/* 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('<style type="text/css">.toc-mobile { max-width: ' + maxWidth + 'px; }</style>'); | |||
} | |||
}); | |||
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); | |||
}); |
Revision as of 07:11, June 2, 2021
/* Any JavaScript here will be loaded for users of the mobile site */
/* Collapse boxes on smaller devices */
function mwMobileCollapse($collapsibleContent) {
if ($(window).width() < 720)
$.each($collapsibleContent, function (index, element) {
$(element).data('mw-collapsible').collapse();
});
}
mw.hook('wikipage.collapsibleContent').add(mwMobileCollapse);
/* MarioWiki: Move navboxes to dedicated section */
$(function() {
if ($('.navbox-section').length) {
$('section > .navbox').detach().appendTo('.navbox-section');
$('.nav-right').clone().appendTo('.navbox-section');
if ($.trim($('.navbox-section').text()) == '') {
$('.navbox-heading').attr('style', 'display:none !important');
$('.navbox-section').attr('style', 'display:none !important');
}
}
});
/* 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('<style type="text/css">.toc-mobile { max-width: ' + maxWidth + 'px; }</style>');
}
});
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);
});