1
1
/*!
2
- * jQuery Color Animations v2.2 .0
2
+ * jQuery Color Animations v3.0 .0
3
3
* https://github.com/jquery/jquery-color
4
4
*
5
5
* Copyright OpenJS Foundation and other contributors
6
6
* Released under the MIT license.
7
7
* https://jquery.org/license
8
8
*
9
- * Date: Sun May 10 09:02:36 2020 +0200
9
+ * Date: Wed May 15 16:49:44 2024 +0200
10
10
*/
11
11
12
12
( function ( root , factory ) {
13
+ "use strict" ;
14
+
13
15
if ( typeof define === "function" && define . amd ) {
14
16
15
17
// AMD. Register as an anonymous module.
20
22
factory ( root . jQuery ) ;
21
23
}
22
24
} ) ( this , function ( jQuery , undefined ) {
25
+ "use strict" ;
23
26
24
27
var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " +
25
28
"borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor" ,
145
148
floor : true
146
149
}
147
150
} ,
148
- support = color . support = { } ,
149
-
150
- // element for support tests
151
- supportElem = jQuery ( "<p>" ) [ 0 ] ,
152
151
153
152
// colors = jQuery.Color.names
154
153
colors ,
155
154
156
155
// local aliases of functions called often
157
156
each = jQuery . each ;
158
157
159
- // determine rgba support immediately
160
- supportElem . style . cssText = "background-color:rgba(1,1,1,.5)" ;
161
- support . rgba = supportElem . style . backgroundColor . indexOf ( "rgba" ) > - 1 ;
162
-
163
158
// define cache name and alpha properties
164
159
// for rgba and hsla spaces
165
160
each ( spaces , function ( spaceName , space ) {
@@ -197,12 +192,6 @@ function clamp( value, prop, allowEmpty ) {
197
192
// ~~ is an short way of doing floor for positive numbers
198
193
value = type . floor ? ~ ~ value : parseFloat ( value ) ;
199
194
200
- // IE will pass in empty strings as value for alpha,
201
- // which will hit this case
202
- if ( isNaN ( value ) ) {
203
- return prop . def ;
204
- }
205
-
206
195
if ( type . mod ) {
207
196
208
197
// we add mod before modding to make sure that negatives values
@@ -315,7 +304,10 @@ color.fn = jQuery.extend( color.prototype, {
315
304
} ) ;
316
305
317
306
// everything defined but alpha?
318
- if ( inst [ cache ] && jQuery . inArray ( null , inst [ cache ] . slice ( 0 , 3 ) ) < 0 ) {
307
+ if ( inst [ cache ] && jQuery . inArray (
308
+ null ,
309
+ inst [ cache ] . slice ( 0 , 3 )
310
+ ) < 0 ) {
319
311
320
312
// use the default of 1
321
313
if ( inst [ cache ] [ 3 ] == null ) {
@@ -427,7 +419,7 @@ color.fn = jQuery.extend( color.prototype, {
427
419
prefix = "rgb(" ;
428
420
}
429
421
430
- return prefix + rgba . join ( ) + ")" ;
422
+ return prefix + rgba . join ( ", " ) + ")" ;
431
423
} ,
432
424
toHslaString : function ( ) {
433
425
var prefix = "hsla(" ,
@@ -447,7 +439,7 @@ color.fn = jQuery.extend( color.prototype, {
447
439
hsla . pop ( ) ;
448
440
prefix = "hsl(" ;
449
441
}
450
- return prefix + hsla . join ( ) + ")" ;
442
+ return prefix + hsla . join ( ", " ) + ")" ;
451
443
} ,
452
444
toHexString : function ( includeAlpha ) {
453
445
var rgba = this . _rgba . slice ( ) ,
@@ -460,12 +452,11 @@ color.fn = jQuery.extend( color.prototype, {
460
452
return "#" + jQuery . map ( rgba , function ( v ) {
461
453
462
454
// default to 0 when nulls exist
463
- v = ( v || 0 ) . toString ( 16 ) ;
464
- return v . length === 1 ? "0" + v : v ;
455
+ return ( "0" + ( v || 0 ) . toString ( 16 ) ) . substr ( - 2 ) ;
465
456
} ) . join ( "" ) ;
466
457
} ,
467
458
toString : function ( ) {
468
- return this . _rgba [ 3 ] === 0 ? "transparent" : this . toRgbaString ( ) ;
459
+ return this . toRgbaString ( ) ;
469
460
}
470
461
} ) ;
471
462
color . fn . parse . prototype = color . fn ;
@@ -632,37 +623,15 @@ color.hook = function( hook ) {
632
623
each ( hooks , function ( _i , hook ) {
633
624
jQuery . cssHooks [ hook ] = {
634
625
set : function ( elem , value ) {
635
- var parsed , curElem ,
636
- backgroundColor = "" ;
626
+ var parsed ;
637
627
638
- if ( value !== "transparent" && ( getType ( value ) !== "string" || ( parsed = stringParse ( value ) ) ) ) {
628
+ if ( value !== "transparent" &&
629
+ ( getType ( value ) !== "string" ||
630
+ ( parsed = stringParse ( value ) ) ) ) {
639
631
value = color ( parsed || value ) ;
640
- if ( ! support . rgba && value . _rgba [ 3 ] !== 1 ) {
641
- curElem = hook === "backgroundColor" ? elem . parentNode : elem ;
642
- while (
643
- ( backgroundColor === "" || backgroundColor === "transparent" ) &&
644
- curElem && curElem . style
645
- ) {
646
- try {
647
- backgroundColor = jQuery . css ( curElem , "backgroundColor" ) ;
648
- curElem = curElem . parentNode ;
649
- } catch ( e ) {
650
- }
651
- }
652
-
653
- value = value . blend ( backgroundColor && backgroundColor !== "transparent" ?
654
- backgroundColor :
655
- "_default" ) ;
656
- }
657
-
658
632
value = value . toRgbaString ( ) ;
659
633
}
660
- try {
661
- elem . style [ hook ] = value ;
662
- } catch ( e ) {
663
-
664
- // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
665
- }
634
+ elem . style [ hook ] = value ;
666
635
}
667
636
} ;
668
637
jQuery . fx . step [ hook ] = function ( fx ) {
0 commit comments