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(!( | var tr = $(this); | ||
if(!(tr.css('position') in ['relative', 'absolute'])){ | |||
tr.css('position', 'relative'); | |||
} | } | ||
var trWidth = | var trWidth = tr.width(); | ||
$(this).children('th').each(function(e){ | $(this).children('th').each(function(e){ | ||
var startH = Math.floor( | var th = $(this); | ||
var endH = Math.floor(( | 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); | ||
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%))');
});
});