MediaWiki:Common.js
Jump to navigation
Jump 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. */
// load various utilities from the commons wiki, including l10nFactory and isEditorActive
mw.loader.getScript( 'https://commons.wiki.gg/index.php?title=MediaWiki:Common-base.js&action=raw&ctype=text/javascript' ).then(function(){
/**
* from terraria wiki.gg sidebar nav menu toggle for mobile view
*/
$(function(){
$('<div class="menu-toggle"/>').insertBefore($('#p-logo')).on("click", function(event){
event.stopPropagation();
$(this).toggleClass('expanded');
});
});
/*end of mw.loader.getScript().then callback*/ });
// Tooltips (http://dev.wikia.com/wiki/Tooltips#Configuration)
window.tooltips_list = [
{
classname: 'spell-tooltip',
parse: '{' + '{DisplaySpellTooltip|<#name#>}}'
},
{
classname: 'item-tooltip',
parse: '{' + '{DisplayItemTooltip|<#name#>}}'
},
{
classname: 'pet-tooltip',
parse: '{' + '{DisplayPetTooltip|<#name#>}}'
},
{
classname: 'class-tooltip',
parse: '{' + '{DisplayClassTooltip|<#name#>}}'
},
{
classname: 'stance-tooltip',
parse: '{' + '{DisplayStanceTooltip|<#name#>}}'
},
{
classname: 'Elixir-tooltip',
parse: '{' + '{DisplayElixirTooltip|<#name#>}}'
},
{
classname: 'generic-tooltip',
parse: '<#tooltip#>'
}
];
/* Resize item-icon-img to apply the ratio applied on item-icon-bg */
$(window).load(function() {
$(".item-icon").each(function() {
$cont = $(this);
$resize = $cont.find(".item-icon-bg").first().width() / 76;
$cont.find(".item-icon-img > p > a > img").each(function() {
$img = $(this);
$w = $img[0].naturalWidth;
$h = $img[0].naturalHeight;
$img.width($w * $resize);
$img.height($h * $resize);
// Lazyload?
$img.load(function() {
$lzy = $(this);
$resize = $lzy.parent().parent().parent().parent().find(".item-icon-bg").first().width() / 76;
$w = $lzy[0].naturalWidth;
$h = $lzy[0].naturalHeight;
$lzy.width($w * $resize);
$lzy.height($h * $resize);
});
});
});
$(window).resize(function() {
// Perform the resize of item-presets:
$(".item-icon").each(function() {
$cont = $(this);
$resize = $cont.find(".item-icon-bg").first().width() / 76;
$cont.find(".item-icon-img > p > a > img").each(function() {
$img = $(this);
$w = $img[0].naturalWidth;
$h = $img[0].naturalHeight;
$img.width($w * $resize);
$img.height($h * $resize);
});
});
});
})