Merge "Changing a message's lang must reset cached text."
[lhc/web/wiklou.git] / resources / src / jquery / jquery.color.js
1 /**
2 * jQuery Color Animations
3 *
4 * @author John Resig, 2007
5 * @author Krinkle, 2011
6 * Released under the MIT and GPL licenses.
7 *
8 * - 2011-01-05: Forked for MediaWiki. See also jQuery.colorUtil plugin
9 */
10 ( function ( $ ) {
11
12 function getColor( elem, attr ) {
13 /*jshint boss:true */
14 var color;
15
16 do {
17 color = $.css( elem, attr );
18
19 // Keep going until we find an element that has color, or we hit the body
20 if ( color !== '' && color !== 'transparent' || $.nodeName( elem, 'body' ) ) {
21 break;
22 }
23
24 attr = 'backgroundColor';
25 } while ( elem = elem.parentNode );
26
27 return $.colorUtil.getRGB( color );
28 }
29
30 // We override the animation for all of these color styles
31 $.each([
32 'backgroundColor',
33 'borderBottomColor',
34 'borderLeftColor',
35 'borderRightColor',
36 'borderTopColor',
37 'color',
38 'outlineColor'
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 );
44 fx.colorInit = true;
45 }
46
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 )
51 ].join( ',' ) + ')';
52 };
53 } );
54
55 }( jQuery ) );