MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
(Shift weird crafting problem from Common.css to Common.js) |
(Fancy Colored Tooltips) |
||
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 every page load. */ | ||
// | // Even More fancy hovers for recipes | ||
$(function() { | $(function() { | ||
// Tooltip only Text | // Tooltip only Text | ||
$('.masterTooltip').hover(function(){ | $('.masterTooltip').hover(function(){ | ||
// Hover over code | // Hover over code | ||
var title = $(this).attr('title'); | var title = $(this).attr('title'); | ||
$(this).data('tipText', title).removeAttr('title'); | $(this).data('tipText', title).removeAttr('title'); | ||
$('<p class="tooltip">' + title + '</p>') | // Add formating with & | ||
var codes = title.match(/&[0-9a-fl-o]/g) | |||
var classes = codes.map(function(x){return 'format-' + x[1]}).join(' ') | |||
$('<p class="tooltip ' + classes + '">' + title.slice(codes.length * 2) + '</p>') | |||
//.text(title + "\n1") | //.text(title + "\n1") | ||
.appendTo('body') | .appendTo('body') | ||
Line 21: | Line 24: | ||
$('.tooltip').css({ top: mousey, left: mousex }); | $('.tooltip').css({ top: mousey, left: mousex }); | ||
}); | }); | ||
// Hide the stupid empty newlines after crafting grids | |||
$('.crafting + p br:only-child').parent().hide(); | $('.crafting + p br:only-child').parent().hide(); | ||
}); | }); |
Revision as of 20:50, 10 August 2020
/* Any JavaScript here will be loaded for all users on every page load. */
// Even More fancy hovers for recipes
$(function() {
// Tooltip only Text
$('.masterTooltip').hover(function(){
// Hover over code
var title = $(this).attr('title');
$(this).data('tipText', title).removeAttr('title');
// Add formating with &
var codes = title.match(/&[0-9a-fl-o]/g)
var classes = codes.map(function(x){return 'format-' + x[1]}).join(' ')
$('<p class="tooltip ' + classes + '">' + title.slice(codes.length * 2) + '</p>')
//.text(title + "\n1")
.appendTo('body')
.show();
}, function() {
// Hover out code
$(this).attr('title', $(this).data('tipText'));
$('.tooltip').remove();
}).mousemove(function(e) {
var mousex = e.pageX + 20; //Get X coordinates
var mousey = e.pageY - 40; //Get Y coordinates
$('.tooltip').css({ top: mousey, left: mousex });
});
// Hide the stupid empty newlines after crafting grids
$('.crafting + p br:only-child').parent().hide();
});