MediaWiki:Common.js: Difference between revisions

m
no edit summary
mNo edit summary
mNo edit summary
Line 272: Line 272:


/****************************** Common Gradient ******************************/
/****************************** Common Gradient ******************************/
$(function() {
$(function(){
     var rainbowList = $('table > tbody > tr[style*=rainbow]');
     /* Deal with non-transparent headers */
     var headerList = $('table > tbody > tr').has('> th').filter(function() {
     var grad_transparent = $(document.createElement('span')).css('background-color'); /* Transparent Calculated Color*/
        return $(this).children('td').length == 0;
     $('tr:not(:has(td))').not('.rainbow').css('background-image', function(){
     }).filter(function() {
         var grad_color = $(this).css('background-color');
        return $.inArray(this, rainbowList) == -1;
         if(grad_transparent != grad_color){ /* If bgcolor is not transparent */
    }).children('th');
             $(this).css('background-image', ['linear-gradient(to bottom', '#eee', grad_color + ')'].join(','));
    headerList.each(function() {
         var bgc = $(this).css('background-color');
         if (bgc != 'rgba(0, 0, 0, 0)' && bgc != 'transparent') { /* Chrome & FF transparent hack */
             $(this).css('background-image', 'linear-gradient(to bottom, #eee, ' + bgc + ')');
         }
         }
     });
     });
     rainbowList.css({
     /* Deal with rainbow rows */
        'backgroundColor': 'orange'
    $('tr.rainbow').each(function(){
        var rb_totalWidth = parseInt($(this).outerWidth(true));
        var rb_cStart, rb_cEnd, rb_sumWidth = 0;
        $(this).children('td, th').each(function(){
            rb_cStart = ['hsl(' + parseFloat(rb_sumWidth / rb_totalWidth * 360).toString(), '100%', '75%)'].join(',');
            rb_sumWidth += $(this).outerWidth(true);
            rb_cEnd = ['hsl(' + parseFloat(rb_sumWidth / rb_totalWidth * 360).toString(), '100%', '75%)'].join(',');
            $(this).css({
                'background-image': ['linear-gradient(to right', rb_cStart, rb_cEnd + ')'].join(',')
            });
        });
     });
     });
     /*
     /*