MediaWiki:Gadget-RainbowHeaders.js: Difference between revisions

From Elwiki
(Created page with "$('tr.rainbow').each(function(e){ if(!($(this).css('position') in ['relative', 'absolute'])){ $(this).css('position', 'relative'); } var trWidth = $(this)....")
 
mNo edit summary
Line 1: Line 1:
$('tr.rainbow').each(function(e){
$('tr.rainbow').each(function(e){
     if(!($(this).css('position') in ['relative', 'absolute'])){
    var tr = $(this);
         $(this).css('position', 'relative');
     if(!(tr.css('position') in ['relative', 'absolute'])){
         tr.css('position', 'relative');
     }
     }
     var trWidth = $(this).width();
     var trWidth = tr.width();
     $(this).children('th').each(function(e){
     $(this).children('th').each(function(e){
         var startH = Math.floor($(this).offset().left / trWidth * 360);
        var th = $(this);
         var endH = Math.floor(($(this).offset().left + $(this).width()) / trWidth * 360);
         var startH = Math.floor(th.offset().left / trWidth * 360);
         var endH = Math.floor((th.offset().left + th.width()) / trWidth * 360);
         startH = Math.max(0, startH);
         startH = Math.max(0, startH);
         endH = Math.min(359, endH);
         endH = Math.min(359, endH);
         $(this).css('background-image', 'linear-gradient(to right, hsl(' + startH + ', 50%, 50%), hsl(' + endH + ', 50%, 50%))');
         th.css('background-image', 'linear-gradient(to right, hsl(' + startH + ', 50%, 50%), hsl(' + endH + ', 50%, 50%))');
     });
     });
});
});

Revision as of 00:37, 31 May 2016

$('tr.rainbow').each(function(e){
    var tr = $(this);
    if(!(tr.css('position') in ['relative', 'absolute'])){
        tr.css('position', 'relative');
    }
    var trWidth = tr.width();
    $(this).children('th').each(function(e){
        var th = $(this);
        var startH = Math.floor(th.offset().left / trWidth * 360);
        var endH = Math.floor((th.offset().left + th.width()) / trWidth * 360);
        startH = Math.max(0, startH);
        endH = Math.min(359, endH);
        th.css('background-image', 'linear-gradient(to right, hsl(' + startH + ', 50%, 50%), hsl(' + endH + ', 50%, 50%))');
    });
});