MediaWiki:Common.js: Difference between revisions

Fancy Colored Tooltips
(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. */


// Fency hovers for recipes
// 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();
});
});
184

edits