MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
(Fancy Colored Tooltips) |
(fix non-styled tooltips) |
||
Line 10: | Line 10: | ||
// Add formating with & | // Add formating with & | ||
var codes = title.match(/&[0-9a-fl-o]/g) | var codes = title.match(/&[0-9a-fl-o]/g) | ||
if (!codes) codes = [] | |||
var classes = codes.map(function(x){return 'format-' + x[1]}).join(' ') | var classes = codes.map(function(x){return 'format-' + x[1]}).join(' ') | ||
$('<p class="tooltip ' + classes + '">' + title.slice(codes.length * 2) + '</p>') | $('<p class="tooltip ' + classes + '">' + title.slice(codes.length * 2) + '</p>') |
Revision as of 20:58, 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)
if (!codes) codes = []
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();
});