@@ -19,24 +19,24 @@ $.effects = {
19
19
} ;
20
20
21
21
/*!
22
- * jQuery Color Animations v2.0.0
23
- * http ://jquery .com/
22
+ * jQuery Color Animations v2.1.1
23
+ * https ://github .com/jquery/jquery-color
24
24
*
25
25
* Copyright 2012 jQuery Foundation and other contributors
26
26
* Released under the MIT license.
27
27
* http://jquery.org/license
28
28
*
29
- * Date: Mon Aug 13 13:41:02 2012 -0500
29
+ * Date: Sun Oct 28 15:08:06 2012 -0400
30
30
*/
31
31
( function ( jQuery , undefined ) {
32
32
33
- var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor" . split ( " " ) ,
33
+ var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor" ,
34
34
35
35
// plusequals test for += 100 -= 100
36
36
rplusequals = / ^ ( [ \- + ] ) = \s * ( \d + \. ? \d * ) / ,
37
37
// a set of RE's that can match strings and generate color tuples.
38
38
stringParsers = [ {
39
- re : / r g b a ? \( \s * ( \d { 1 , 3 } ) \s * , \s * ( \d { 1 , 3 } ) \s * , \s * ( \d { 1 , 3 } ) \s * (?: , \s * ( \d + (?: \. \d + ) ? ) \s * ) ? \) / ,
39
+ re : / r g b a ? \( \s * ( \d { 1 , 3 } ) \s * , \s * ( \d { 1 , 3 } ) \s * , \s * ( \d { 1 , 3 } ) \s * (?: , \s * ( \d ? (?: \. \d + ) ? ) \s * ) ? \) / ,
40
40
parse : function ( execResult ) {
41
41
return [
42
42
execResult [ 1 ] ,
@@ -46,7 +46,7 @@ $.effects = {
46
46
] ;
47
47
}
48
48
} , {
49
- re : / r g b a ? \( \s * ( \d + (?: \. \d + ) ? ) \% \s * , \s * ( \d + (?: \. \d + ) ? ) \% \s * , \s * ( \d + (?: \. \d + ) ? ) \% \s * (?: , \s * ( \d + (?: \. \d + ) ? ) \s * ) ? \) / ,
49
+ re : / r g b a ? \( \s * ( \d + (?: \. \d + ) ? ) \% \s * , \s * ( \d + (?: \. \d + ) ? ) \% \s * , \s * ( \d + (?: \. \d + ) ? ) \% \s * (?: , \s * ( \d ? (?: \. \d + ) ? ) \s * ) ? \) / ,
50
50
parse : function ( execResult ) {
51
51
return [
52
52
execResult [ 1 ] * 2.55 ,
@@ -76,7 +76,7 @@ $.effects = {
76
76
] ;
77
77
}
78
78
} , {
79
- re : / h s l a ? \( \s * ( \d + (?: \. \d + ) ? ) \s * , \s * ( \d + (?: \. \d + ) ? ) \% \s * , \s * ( \d + (?: \. \d + ) ? ) \% \s * (?: , \s * ( \d + (?: \. \d + ) ? ) \s * ) ? \) / ,
79
+ re : / h s l a ? \( \s * ( \d + (?: \. \d + ) ? ) \s * , \s * ( \d + (?: \. \d + ) ? ) \% \s * , \s * ( \d + (?: \. \d + ) ? ) \% \s * (?: , \s * ( \d ? (?: \. \d + ) ? ) \s * ) ? \) / ,
80
80
space : "hsla" ,
81
81
parse : function ( execResult ) {
82
82
return [
@@ -293,7 +293,7 @@ color.fn = jQuery.extend( color.prototype, {
293
293
} ) ;
294
294
295
295
// everything defined but alpha?
296
- if ( inst [ cache ] && $ . inArray ( null , inst [ cache ] . slice ( 0 , 3 ) ) < 0 ) {
296
+ if ( inst [ cache ] && jQuery . inArray ( null , inst [ cache ] . slice ( 0 , 3 ) ) < 0 ) {
297
297
// use the default of 1
298
298
inst [ cache ] [ 3 ] = 1 ;
299
299
if ( space . from ) {
@@ -481,8 +481,10 @@ spaces.hsla.to = function ( rgba ) {
481
481
h = ( 60 * ( r - g ) / diff ) + 240 ;
482
482
}
483
483
484
- if ( l === 0 || l === 1 ) {
485
- s = l ;
484
+ // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
485
+ // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
486
+ if ( diff === 0 ) {
487
+ s = 0 ;
486
488
} else if ( l <= 0.5 ) {
487
489
s = diff / add ;
488
490
} else {
@@ -586,51 +588,58 @@ each( spaces, function( spaceName, space ) {
586
588
} ) ;
587
589
} ) ;
588
590
589
- // add .fx.step functions
590
- each ( stepHooks , function ( i , hook ) {
591
- jQuery . cssHooks [ hook ] = {
592
- set : function ( elem , value ) {
593
- var parsed , curElem ,
594
- backgroundColor = "" ;
595
-
596
- if ( jQuery . type ( value ) !== "string" || ( parsed = stringParse ( value ) ) ) {
597
- value = color ( parsed || value ) ;
598
- if ( ! support . rgba && value . _rgba [ 3 ] !== 1 ) {
599
- curElem = hook === "backgroundColor" ? elem . parentNode : elem ;
600
- while (
601
- ( backgroundColor === "" || backgroundColor === "transparent" ) &&
602
- curElem && curElem . style
603
- ) {
604
- try {
605
- backgroundColor = jQuery . css ( curElem , "backgroundColor" ) ;
606
- curElem = curElem . parentNode ;
607
- } catch ( e ) {
591
+ // add cssHook and .fx.step function for each named hook.
592
+ // accept a space separated string of properties
593
+ color . hook = function ( hook ) {
594
+ var hooks = hook . split ( " " ) ;
595
+ each ( hooks , function ( i , hook ) {
596
+ jQuery . cssHooks [ hook ] = {
597
+ set : function ( elem , value ) {
598
+ var parsed , curElem ,
599
+ backgroundColor = "" ;
600
+
601
+ if ( jQuery . type ( value ) !== "string" || ( parsed = stringParse ( value ) ) ) {
602
+ value = color ( parsed || value ) ;
603
+ if ( ! support . rgba && value . _rgba [ 3 ] !== 1 ) {
604
+ curElem = hook === "backgroundColor" ? elem . parentNode : elem ;
605
+ while (
606
+ ( backgroundColor === "" || backgroundColor === "transparent" ) &&
607
+ curElem && curElem . style
608
+ ) {
609
+ try {
610
+ backgroundColor = jQuery . css ( curElem , "backgroundColor" ) ;
611
+ curElem = curElem . parentNode ;
612
+ } catch ( e ) {
613
+ }
608
614
}
615
+
616
+ value = value . blend ( backgroundColor && backgroundColor !== "transparent" ?
617
+ backgroundColor :
618
+ "_default" ) ;
609
619
}
610
620
611
- value = value . blend ( backgroundColor && backgroundColor !== "transparent" ?
612
- backgroundColor :
613
- "_default" ) ;
621
+ value = value . toRgbaString ( ) ;
622
+ }
623
+ try {
624
+ elem . style [ hook ] = value ;
625
+ } catch ( e ) {
626
+ // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
614
627
}
615
-
616
- value = value . toRgbaString ( ) ;
617
628
}
618
- try {
619
- elem . style [ hook ] = value ;
620
- } catch ( error ) {
621
- // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
629
+ } ;
630
+ jQuery . fx . step [ hook ] = function ( fx ) {
631
+ if ( ! fx . colorInit ) {
632
+ fx . start = color ( fx . elem , hook ) ;
633
+ fx . end = color ( fx . end ) ;
634
+ fx . colorInit = true ;
622
635
}
623
- }
624
- } ;
625
- jQuery . fx . step [ hook ] = function ( fx ) {
626
- if ( ! fx . colorInit ) {
627
- fx . start = color ( fx . elem , hook ) ;
628
- fx . end = color ( fx . end ) ;
629
- fx . colorInit = true ;
630
- }
631
- jQuery . cssHooks [ hook ] . set ( fx . elem , fx . start . transition ( fx . end , fx . pos ) ) ;
632
- } ;
633
- } ) ;
636
+ jQuery . cssHooks [ hook ] . set ( fx . elem , fx . start . transition ( fx . end , fx . pos ) ) ;
637
+ } ;
638
+ } ) ;
639
+
640
+ } ;
641
+
642
+ color . hook ( stepHooks ) ;
634
643
635
644
jQuery . cssHooks . borderColor = {
636
645
expand : function ( value ) {
@@ -674,7 +683,6 @@ colors = jQuery.Color.names = {
674
683
} ) ( jQuery ) ;
675
684
676
685
677
-
678
686
/******************************************************************************/
679
687
/****************************** CLASS ANIMATIONS ******************************/
680
688
/******************************************************************************/
0 commit comments