MediaWiki:Gadget-RainbowHeaders.js: Difference between revisions
From Elwiki
mNo edit summary |
mNo edit summary |
||
Line 7: | Line 7: | ||
$(this).children('th').each(function(e){ | $(this).children('th').each(function(e){ | ||
var th = $(this); | var th = $(this); | ||
var startH = Math.floor(th. | var startH = Math.floor(th.position().left / trWidth * 360); | ||
var endH = Math.floor((th. | var endH = Math.floor((th.position().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); |
Revision as of 03:50, 4 June 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.position().left / trWidth * 360);
var endH = Math.floor((th.position().left + th.width()) / trWidth * 360);
startH = Math.max(0, startH);
endH = Math.min(359, endH);
console.log(startH, endH);
th.css('background-image', 'linear-gradient(to right, hsl(' + startH + ', 50%, 50%), hsl(' + endH + ', 50%, 50%))');
});
});