In $.textSelection, treat <input> elements differently from other elements (such...
[lhc/web/wiklou.git] / resources / jquery / jquery.color.js
1 /**
2 * jQuery Color Animations
3 * Copyright 2007 John Resig
4 * Released under the MIT and GPL licenses.
5 *
6 * - 2011-01-05: Modified by Krinkle to use the jQuery.colorUtil plugin (which has to be loaded first!)
7 */
8 (function( $ ) {
9
10 // We override the animation for all of these color styles
11 $.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'],
12 function( i, attr ) {
13 $.fx.step[attr] = function( fx ) {
14 if ( fx.state == 0 ) {
15 fx.start = getColor( fx.elem, attr );
16 fx.end = $.colorUtil.getRGB( fx.end );
17 }
18
19 fx.elem.style[attr] = 'rgb(' + [
20 Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
21 Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
22 Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
23 ].join( ',' ) + ')';
24 }
25 }
26 );
27
28 function getColor(elem, attr) {
29 var color;
30
31 do {
32 color = $.curCSS(elem, attr);
33
34 // Keep going until we find an element that has color, or we hit the body
35 if ( color != '' && color != 'transparent' || $.nodeName(elem, 'body') )
36 break;
37
38 attr = 'backgroundColor';
39 } while ( elem = elem.parentNode );
40
41 return $.colorUtil.getRGB(color);
42 };
43
44 } )( jQuery );