2 * jQuery Color Animations
4 * @author John Resig, 2007
5 * @author Krinkle, 2011
6 * Released under the MIT and GPL licenses.
8 * - 2011-01-05: Forked for MediaWiki. See also jQuery.colorUtil plugin
12 function getColor( elem, attr ) {
17 color = $.css( elem, attr );
19 // Keep going until we find an element that has color, or we hit the body
20 if ( color !== '' && color !== 'transparent' || $.nodeName( elem, 'body' ) ) {
24 attr = 'backgroundColor';
25 } while ( elem = elem.parentNode );
27 return $.colorUtil.getRGB( color );
30 // We override the animation for all of these color styles
39 ], function ( i, attr ) {
40 $.fx.step[attr] = function ( fx ) {
41 if ( !fx.colorInit ) {
42 fx.start = getColor( fx.elem, attr );
43 fx.end = $.colorUtil.getRGB( fx.end );
47 fx.elem.style[attr] = 'rgb(' + [
48 Math.max( Math.min( parseInt( (fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10 ), 255 ), 0 ),
49 Math.max( Math.min( parseInt( (fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10 ), 255 ), 0 ),
50 Math.max( Math.min( parseInt( (fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10 ), 255 ), 0 )