[dismiss]
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:Gadget-GlobalScript.js: Difference between revisions
From the Kingdom Hearts Wiki, the Kingdom Hearts encyclopedia
Jump to navigationJump to search
No edit summary Tag: Manual revert |
No edit summary |
||
Line 11: | Line 11: | ||
} | } | ||
mw.hook('wikipage.collapsibleContent').add(mwCollapsibleSetup); | mw.hook('wikipage.collapsibleContent').add(mwCollapsibleSetup); | ||
/* Replace smart quotes */ | |||
function quoteFixer() { | |||
var textAreas = ['#wpTextbox1', '#wikitext-editor']; | |||
for (var i = 0; i < textAreas.length; i++) { | |||
if ($(textAreas[i]).length) | |||
$(textAreas[i]).val($(textAreas[i]).val().replace(/[‘’]/g, "'").replace(/[“”]/g, '"')); | |||
} | |||
} | |||
$(function() { | |||
if (['edit', 'submit'].includes(mw.config.get('wgAction')) && ![8, 10, 274, 828, 2300].includes(mw.config.get('wgNamespaceNumber'))) { | |||
$('.editButtons input').click(quoteFixer); | |||
if ($('body.skin-minerva').length) | |||
setTimeout(function() { $('.header-action button').click(quoteFixer) }, 3000); | |||
} | |||
}); | |||
/* Gallery videos */ | /* Gallery videos */ |
Revision as of 18:52, 4 March 2023
/* Any JavaScript here will be loaded for all skins on both desktop and mobile */
/* 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);
/* Replace smart quotes */
function quoteFixer() {
var textAreas = ['#wpTextbox1', '#wikitext-editor'];
for (var i = 0; i < textAreas.length; i++) {
if ($(textAreas[i]).length)
$(textAreas[i]).val($(textAreas[i]).val().replace(/[‘’]/g, "'").replace(/[“”]/g, '"'));
}
}
$(function() {
if (['edit', 'submit'].includes(mw.config.get('wgAction')) && ![8, 10, 274, 828, 2300].includes(mw.config.get('wgNamespaceNumber'))) {
$('.editButtons input').click(quoteFixer);
if ($('body.skin-minerva').length)
setTimeout(function() { $('.header-action button').click(quoteFixer) }, 3000);
}
});
/* Gallery videos */
$(function() {
$('.gallery').each(function(i, gallery) {
var videos = $(gallery).find('.gallerybox video');
if (!videos.length)
return;
var boxes = $(gallery).find('.gallerybox');
var onlyVideos = videos.length == boxes.length ? true : false;
videos.each(function(ii, video) {
if (onlyVideos)
$(video).css('height', 'auto');
$(video).parent().css({'max-width': 'calc(100% - 30px)', 'margin': '15px auto'});
});
var timeOut = onlyVideos ? 1000 : 0;
setTimeout(function() {
var height = 0;
$(gallery).find('.gallerybox .thumb').each(function(ii, thumb) {
if ($(thumb).innerHeight() > height)
height = $(thumb).innerHeight();
});
videos.each(function(ii, video) {
maxHeight = height - 30;
$(video).parent().parent().css({'height': height, 'display': 'flex'});
$(video).parent().css({'width': '100%', 'min-width': '125px', 'margin': 'auto'});
$(video).css({'height': 'auto', 'max-height': maxHeight});
});
}, timeOut);
});
});