Commit 93248a79 authored by nextime's avatar nextime

Removing jquery-color...

parent 20274b69
<? @include_once("../includes/common.php");?>
<? if($GUIDEBUG) { ?>
<!-- JavaScript plugins (requires jQuery) -->
<script src="/resources/js/jquery-1.9.0.min.js"></script>
<script src="/resources/js/jquery-1.10.2.min.js"></script>
<script src="/resources/jquery-color/jquery.color.min.js"></script>
<script src="/resources/hammer.js/dist/hammer.min.js"></script>
<script src="/resources/hammer.js/plugins/hammer.fakemultitouch.js"></script>
......
build/.sizecache.json
dist/
.DS_Store
node_modules
[submodule "test/qunit"]
path = test/qunit
url = git://github.com/jquery/qunit.git
{
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"expr": true,
"immed": true,
"noarg": true,
"onevar": true,
"quotmark": "double",
"smarttabs": true,
"trailing": true,
"undef": true,
"unused": true,
"browser": true,
"jquery": true
}
Authors ordered by first contribution
John Resig <jeresig@gmail.com>
Scott González <scott.gonzalez@gmail.com>
Corey Frang <gnarf@gnarf.net>
eddiemonge <eddie@eddiemonge.com>
Krinkle <krinklemail@gmail.com>
Richard D. Worth <rdworth@gmail.com>
Jörn Zaefferer <joern.zaefferer@gmail.com>
Mike Sherov <mike.sherov@gmail.com>
Brendan Byrd <GitHub@ResonatorSoft.org>
Christoffer Sawicki <christoffer.sawicki@gmail.com>
Dmitry <df.creative@gmail.com>
Ben Olson <bseth99@yahoo.com>
Welcome! Thanks for your interest in contributing to the jQuery Color plugin. You're **almost** in the right place. More information on how to contribute to this and all other jQuery Foundation projects is over at [contribute.jquery.org](http://contribute.jquery.org). You'll definitely want to take a look at the articles on contributing [code](http://contribute.jquery.org/code).
You may also want to take a look at our [commit & pull request guide](http://contribute.jquery.org/commits-and-pull-requests/) and [style guides](http://contribute.jquery.org/style-guide/) for instructions on how to maintain your fork and submit your code. Before we can merge any pull request, we'll also need you to sign our [contributor license agreement](http://contribute.jquery.org/cla).
You can find us on [IRC](http://irc.jquery.org), specifically in [#jquery-dev](irc://irc.freenode.net/#jquery-dev) should you have any questions. If you've never contributed to open source before, we've put together [a short guide with tips, tricks, and ideas on getting started](http://contribute.jquery.org/open-source/).
Copyright 2013 jQuery Foundation and other contributors,
http://jquery.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[![Build Status](http://swarm.jquery.org:8080/job/jQuery%20Color/badge/icon)](http://swarm.jquery.org:8080/job/jQuery%20Color/)
# jQuery Color
## Using jQuery Color in Production
We release jQuery Color by itself, or in a bundle. The extended names can be inclided as a jQuery Color plugin, or you can download the version of jQuery Color that includes the names. Choose your build from the following list:
**Current version: 2.1.2**
* jQuery Color [Compressed](http://code.jquery.com/color/jquery.color-2.1.2.min.js) [Uncompressed](http://code.jquery.com/color/jquery.color-2.1.2.js)
* jQuery Color Extended Names [Compressed](http://code.jquery.com/color/jquery.color.svg-names-2.1.2.min.js) [Uncompressed](http://code.jquery.com/color/jquery.color.svg-names-2.1.2.js)
* jQuery Color & Extended Names(previous two combined) [Compressed](http://code.jquery.com/color/jquery.color.plus-names-2.1.2.min.js) [Uncompressed](http://code.jquery.com/color/jquery.color.plus-names-2.1.2.js)
## How to build and test jQuery Color
First, get a copy of the git repo by running:
```shell
git clone git://github.com/jquery/jquery-color.git
```
Enter the directory and install the node dependencies:
```shell
cd jquery-color && npm install
```
Make sure you have `grunt` installed by testing:
```shell
grunt -version
```
If not, run:
```shell
npm install -g grunt
```
To run tests locally, run `grunt`, and this will run the tests in PhantomJS.
You can also run the tests in a browser by navigating to the `test/` directory, but first run `grunt` to install submodules.
## Animated colors
This plugins installs a [`cssHook`](http://api.jquery.com/jQuery.cssHooks/) which allows jQuery's [`.animate()`](http://api.jquery.com/animate) to animate between two colors.
## Supported properties
`backgroundColor`, `borderBottomColor`, `borderLeftColor`, `borderRightColor`, `borderTopColor`, `color`, `columnRuleColor`, `outlineColor`, `textDecorationColor`, `textEmphasisColor`
## Example use
```html
<!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: #bada55;
width: 100px;
border: 1px solid green;
}
</style>
<script src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
<script src="jquery.color.min.js"></script>
</head>
<body>
<button id="go">Simple</button>
<button id="sat">Desaturate</button>
<div id="block">Hello!</div>
<script>
jQuery("#go").click(function(){
jQuery("#block").animate({
backgroundColor: "#abcdef"
}, 1500 );
});
jQuery("#sat").click(function(){
jQuery("#block").animate({
backgroundColor: jQuery.Color({ saturation: 0 })
}, 1500 );
});
</script>
</body>
</html>
```
## Supporting other properties
The `jQuery.Color.hook()` function can be called to support additional css properties as colors, and allow them to be animated.
## Example use
```javascript
// we want to animate SVG fill and stroke properties
jQuery.Color.hook( "fill stroke" );
```
## The jQuery.Color Factory
The `jQuery.Color()` function allows you to create and manipulate color objects that are accepted by jQuery's `.animate()` and `.css()` functions.
* Returns a new Color object, similar to `jQuery()` or `jQuery.Event`
* Accepts many formats to create a new Color object with a `jQuery.Color.fn` prototype
### Example uses:
```javascript
// Parsing String Colors:
jQuery.Color( "#abcdef" );
jQuery.Color( "rgb(100,200,255)" );
jQuery.Color( "rgba(100,200,255,0.5)" );
jQuery.Color( "aqua" );
// Creating Color Objects in Code:
// use null or undefined for values you wish to leave out
jQuery.Color( red, green, blue, alpha );
jQuery.Color([ red, green, blue, alpha ]);
jQuery.Color({ red: red, green: green, blue: blue, alpha: alpha });
jQuery.Color({ hue: hue, saturation: saturation, lightness: lightness, alpha: alpha });
// Helper to get value from CSS
jQuery.Color( element, cssProperty );
```
## jQuery.Color.fn / prototype / the Color Object methods
### Getters / Setters:
```javascript
red() // returns the "red" component of the color ( Integer from 0 - 255 )
red( val ) // returns a copy of the color object with the red set to val
green() // returns the "green" component of the color from ( Integer from 0 - 255 )
green( val ) // returns a copy of the color object with the green set to val
blue() // returns the "blue" component of the color from ( Integer from 0 - 255 )
blue( val ) // returns a copy of the color object with the blue set to val
alpha() // returns the "alpha" component of the color from ( Float from 0.0 - 1.0 )
alpha( val ) // returns a copy of the color object with the alpha set to val
hue() // returns the "hue" component of the color ( Integer from 0 - 359 )
hue( val ) // returns a copy of the color object with the hue set to val
saturation() // returns the "saturation" component of the color ( Float from 0.0 - 1.0 )
saturation( val ) // returns a copy of the color object with the saturation set to val
lightness() // returns the "lightness" component of the color ( Float from 0.0 - 1.0 )
lightness( val ) // returns a copy of the color object with the lightness set to val
// all of the above values can also take strings in the format of "+=100" or "-=100"
rgba() // returns a rgba "tuple" [ red, green, blue, alpha ]
// rgba() setters: returns a copy of the color with any defined values set to the new value
rgba( red, green, blue, alpha )
rgba({ red: red, green: green, blue: blue, alpha: alpha })
rgba([ red, green, blue, alpha ])
hsla() // returns a HSL tuple [ hue, saturation, lightness, alpha ]
// much like the rgb setter - returns a copy with any defined values set
hsla( hue, saturation, lightness, alpha )
hsla({ hue: hue, saturation: saturation, lightness: lightness, alpha: alpha )
hsla([ hue, saturation, lightness, alpha ])
```
### String methods
```javascript
toRgbaString() // returns a css string "rgba(255, 255, 255, 0.4)"
toHslaString() // returns a css string "hsla(330, 75%, 25%, 0.4)"
toHexString( includeAlpha ) // returns a css string "#abcdef", with "includeAlpha" uses "#rrggbbaa" (alpha *= 255)
```
The `toRgbaString` and `toHslaString` methods will only include the alpha channel if it is not `1`. They will return `rgb(...)` and `hsl(...)` strings if the alpha is set to `1`.
### Working with other colors:
```javascript
transition( othercolor, distance ) // the color distance ( 0.0 - 1.0 ) of the way between this color and othercolor
blend( othercolor ) // Will apply this color on top of the other color using alpha blending
is( othercolor ) // Will determine if this color is equal to all defined properties of othercolor
```
## jQuery.Color properties
## Internals on The Color Object
* Internally, RGBA values are stored as `color._rgba[0] = red, color._rgba[1] = green, color._rgba[2] = blue, color._rgba[3] = alpha`. However, please remember there are nice convenient setters and getters for each of these properties.
* `undefined`/`null` values for colors indicate non-existence. This signals the `transition()` function to keep whatever value was set in the other end of the transition. For example, animating to `jQuery.Color([ 255, null, null, 1 ])` would only animate the red and alpha values of the color.
### `jQuery.Color.names`
A list of named colors is stored on the `jQuery.Color.names` object. The value they contain should be parseable by `jQuery.Color()`. All names on this object should be lowercased. I.E. `jQuery.Color("Red")` is the same as doing `jQuery.Color( jQuery.Color.names["red"] );`
There is also a named color `"_default"` which by default is white, this is used for situations where a color is unparseable.
### `"transparent"`
A special note about the color `"transparent"` - It returns `null` for red green and blue unless you specify colors for these values.
```javascript
jQuery.Color("#abcdef").transition("transparent", 0.5)
```
Animating to or from the value `"transparent"` will still use "#abcdef" for red green and blue.
## HSLA Support
If a color is created using any of the HSLA functions or parsers, it will keep the `_rgba` array up to date as well as having a `_hsla` array. Once an RGBA operation is performed on HSLA, however, the `_hsla` cache is removed and all operations will continue based off of rgb (unless you go back into HSLA). The `._hsla` array follows the same format as `._rbga`, `[hue, saturation, lightness, alpha ]`. If you need to build an HSLA color from an HSLA array, `jQuery.Color().hsla( array )` works for that purpose.
**Colors with 0 saturation, or 100%/0% lightness will be stored with a hue of 0**
## Extensibility
It is possible for you to add your own functions to the color object. For instance, this function will tell you if its better to use black or white on a given background color.
```javascript
// method taken from https://gist.github.com/960189
jQuery.Color.fn.contrastColor = function() {
var r = this._rgba[0], g = this._rgba[1], b = this._rgba[2];
return (((r*299)+(g*587)+(b*144))/1000) >= 131.5 ? "black" : "white";
};
// usage examples:
jQuery.Color("#bada55").contrastColor(); // "black"
element.css( "color", jQuery.Color( element, "backgroundColor" ).contrastColor() );
```
/*jshint node: true */
module.exports = function( grunt ) {
"use strict";
var max = [ "dist/jquery.color.js", "dist/jquery.color.svg-names.js" ],
min = [ "dist/jquery.color.min.js", "dist/jquery.color.svg-names.min.js", "dist/jquery.color.plus-names.min.js"],
combined = "dist/jquery.color.plus-names.js",
minify = {},
concat = {};
minify[ min[0] ] = [ "<banner>", max[0] ];
minify[ min[1] ] = [ "<banner:meta.bannerSvg>", max[1] ];
minify[ min[2] ] = [ "<banner:meta.bannerCombined>", combined ];
concat[ combined ] = [ max[0], max[1] ];
grunt.loadNpmTasks( "grunt-compare-size" );
grunt.loadNpmTasks( "grunt-git-authors" );
grunt.initConfig({
pkg: "<json:package.json>",
meta: {
banner: "/*! jQuery Color v@<%= pkg.version %> http://github.com/jquery/jquery-color | jquery.org/license */",
bannerSvg: "/*! jQuery Color v@<%= pkg.version %> SVG Color Names http://github.com/jquery/jquery-color | jquery.org/license */",
bannerCombined: "/*! jQuery Color v@<%= pkg.version %> with SVG Color Names http://github.com/jquery/jquery-color | jquery.org/license */"
},
lint: {
src: [ "jquery.color.js", "jquery.color.svg-names.js" ],
grunt: "grunt.js",
test: "test/unit/**"
},
jshint: (function() {
function parserc( path ) {
var rc = grunt.file.readJSON( (path || "") + ".jshintrc" ),
settings = {
options: rc,
globals: rc.globals || {}
};
(rc.predef || []).forEach(function( prop ) {
settings.globals[ prop ] = true;
});
delete rc.predef;
return settings;
}
return {
src: parserc(),
grunt: parserc(),
test: parserc( "test/unit/" )
};
}()),
qunit: {
files: "test/index.html"
},
concat: concat,
min: minify,
watch: {
files: [ "<config:lint.src>", "<config:lint.test>", "<config:lint.grunt>" ],
tasks: "default"
},
compare_size: {
"color": [ max[0], min[0] ],
"svg-names": [ max[1], min[1] ],
"combined": [ combined, min[2] ]
}
});
grunt.registerHelper( "git-date", function( fn ) {
grunt.utils.spawn({
cmd: "git",
args: [ "log", "-1", "--pretty=format:%ad" ]
}, function( error, result ) {
if ( error ) {
grunt.log.error( error );
return fn( error );
}
fn( null, result );
});
});
grunt.registerTask( "submodules", function() {
var done = this.async();
grunt.verbose.write( "Updating submodules..." );
grunt.utils.spawn({
cmd: "git",
args: [ "submodule", "update", "--init" ]
}, function( err, result ) {
if ( err ) {
grunt.verbose.error();
done( err );
return;
}
grunt.log.writeln( result );
done();
});
});
grunt.registerTask( "max", function() {
var done = this.async(),
version = grunt.config( "pkg.version" );
if ( process.env.COMMIT ) {
version += " " + process.env.COMMIT;
}
grunt.helper( "git-date", function( error, date ) {
if ( error ) {
return done( false );
}
max.forEach( function( dist ) {
grunt.file.copy( dist.replace( "dist/", "" ), dist, {
process: function( source ) {
return source
.replace( /@VERSION/g, version )
.replace( /@DATE/g, date );
}
});
});
done();
});
});
grunt.registerTask( "testswarm", function( commit, configFile ) {
var testswarm = require( "testswarm" ),
config = grunt.file.readJSON( configFile ).jquerycolor,
done = this.async();
testswarm.createClient( {
url: config.swarmUrl,
pollInterval: 10000,
timeout: 1000 * 60 * 30
} )
.addReporter( testswarm.reporters.cli )
.auth( {
id: config.authUsername,
token: config.authToken
})
.addjob(
{
name: "jQuery Color commit #<a href='https://github.com/jquery/jquery-color/commit/" + commit + "'>" + commit.substr( 0, 10 ) + "</a>",
runs: {
"jQuery color": config.testUrl + commit + "/test/index.html"
},
runMax: config.runMax,
browserSets: ["popular"]
}, function( err, passed ) {
if ( err ) {
grunt.log.error( err );
}
done( passed );
}
);
});
grunt.registerTask( "manifest", function() {
var pkg = grunt.config( "pkg" );
grunt.file.write( "color.jquery.json", JSON.stringify({
name: "color",
title: pkg.title,
description: pkg.description,
keywords: pkg.keywords,
version: pkg.version,
author: {
name: pkg.author.name,
url: pkg.author.url.replace( "master", pkg.version )
},
maintainers: pkg.maintainers,
licenses: pkg.licenses.map(function( license ) {
license.url = license.url.replace( "master", pkg.version );
return license;
}),
bugs: pkg.bugs,
homepage: pkg.homepage,
docs: pkg.homepage,
download: "http://code.jquery.com/#color",
dependencies: {
jquery: ">=1.5"
}
}, null, "\t" ) );
});
grunt.registerTask( "default", "lint submodules qunit build compare_size" );
grunt.registerTask( "build", "max concat min" );
};
/*!
* jQuery Color Animations v@VERSION
* https://github.com/jquery/jquery-color
*
* Copyright 2013 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* Date: @DATE
*/
(function( jQuery, undefined ) {
var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
// plusequals test for += 100 -= 100
rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
// a set of RE's that can match strings and generate color tuples.
stringParsers = [{
re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
parse: function( execResult ) {
return [
execResult[ 1 ],
execResult[ 2 ],
execResult[ 3 ],
execResult[ 4 ]
];
}
}, {
re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
parse: function( execResult ) {
return [
execResult[ 1 ] * 2.55,
execResult[ 2 ] * 2.55,
execResult[ 3 ] * 2.55,
execResult[ 4 ]
];
}
}, {
// this regex ignores A-F because it's compared against an already lowercased string
re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
parse: function( execResult ) {
return [
parseInt( execResult[ 1 ], 16 ),
parseInt( execResult[ 2 ], 16 ),
parseInt( execResult[ 3 ], 16 )
];
}
}, {
// this regex ignores A-F because it's compared against an already lowercased string
re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
parse: function( execResult ) {
return [
parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
];
}
}, {
re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
space: "hsla",
parse: function( execResult ) {
return [
execResult[ 1 ],
execResult[ 2 ] / 100,
execResult[ 3 ] / 100,
execResult[ 4 ]
];
}
}],
// jQuery.Color( )
color = jQuery.Color = function( color, green, blue, alpha ) {
return new jQuery.Color.fn.parse( color, green, blue, alpha );
},
spaces = {
rgba: {
props: {
red: {
idx: 0,
type: "byte"
},
green: {
idx: 1,
type: "byte"
},
blue: {
idx: 2,
type: "byte"
}
}
},
hsla: {
props: {
hue: {
idx: 0,
type: "degrees"
},
saturation: {
idx: 1,
type: "percent"
},
lightness: {
idx: 2,
type: "percent"
}
}
}
},
propTypes = {
"byte": {
floor: true,
max: 255
},
"percent": {
max: 1
},
"degrees": {
mod: 360,
floor: true
}
},
support = color.support = {},
// element for support tests
supportElem = jQuery( "<p>" )[ 0 ],
// colors = jQuery.Color.names
colors,
// local aliases of functions called often
each = jQuery.each;
// determine rgba support immediately
supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
// define cache name and alpha properties
// for rgba and hsla spaces
each( spaces, function( spaceName, space ) {
space.cache = "_" + spaceName;
space.props.alpha = {
idx: 3,
type: "percent",
def: 1
};
});
function clamp( value, prop, allowEmpty ) {
var type = propTypes[ prop.type ] || {};
if ( value == null ) {
return (allowEmpty || !prop.def) ? null : prop.def;
}
// ~~ is an short way of doing floor for positive numbers
value = type.floor ? ~~value : parseFloat( value );
// IE will pass in empty strings as value for alpha,
// which will hit this case
if ( isNaN( value ) ) {
return prop.def;
}
if ( type.mod ) {
// we add mod before modding to make sure that negatives values
// get converted properly: -10 -> 350
return (value + type.mod) % type.mod;
}
// for now all property types without mod have min and max
return 0 > value ? 0 : type.max < value ? type.max : value;
}
function stringParse( string ) {
var inst = color(),
rgba = inst._rgba = [];
string = string.toLowerCase();
each( stringParsers, function( i, parser ) {
var parsed,
match = parser.re.exec( string ),
values = match && parser.parse( match ),
spaceName = parser.space || "rgba";
if ( values ) {
parsed = inst[ spaceName ]( values );
// if this was an rgba parse the assignment might happen twice
// oh well....
inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
rgba = inst._rgba = parsed._rgba;
// exit each( stringParsers ) here because we matched
return false;
}
});
// Found a stringParser that handled it
if ( rgba.length ) {
// if this came from a parsed string, force "transparent" when alpha is 0
// chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
if ( rgba.join() === "0,0,0,0" ) {
jQuery.extend( rgba, colors.transparent );
}
return inst;
}
// named colors
return colors[ string ];
}
color.fn = jQuery.extend( color.prototype, {
parse: function( red, green, blue, alpha ) {
if ( red === undefined ) {
this._rgba = [ null, null, null, null ];
return this;
}
if ( red.jquery || red.nodeType ) {
red = jQuery( red ).css( green );
green = undefined;
}
var inst = this,
type = jQuery.type( red ),
rgba = this._rgba = [];
// more than 1 argument specified - assume ( red, green, blue, alpha )
if ( green !== undefined ) {
red = [ red, green, blue, alpha ];
type = "array";
}
if ( type === "string" ) {
return this.parse( stringParse( red ) || colors._default );
}
if ( type === "array" ) {
each( spaces.rgba.props, function( key, prop ) {
rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
});
return this;
}
if ( type === "object" ) {
if ( red instanceof color ) {
each( spaces, function( spaceName, space ) {
if ( red[ space.cache ] ) {
inst[ space.cache ] = red[ space.cache ].slice();
}
});
} else {
each( spaces, function( spaceName, space ) {
var cache = space.cache;
each( space.props, function( key, prop ) {
// if the cache doesn't exist, and we know how to convert
if ( !inst[ cache ] && space.to ) {
// if the value was null, we don't need to copy it
// if the key was alpha, we don't need to copy it either
if ( key === "alpha" || red[ key ] == null ) {
return;
}
inst[ cache ] = space.to( inst._rgba );
}
// this is the only case where we allow nulls for ALL properties.
// call clamp with alwaysAllowEmpty
inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
});
// everything defined but alpha?
if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
// use the default of 1
inst[ cache ][ 3 ] = 1;
if ( space.from ) {
inst._rgba = space.from( inst[ cache ] );
}
}
});
}
return this;
}
},
is: function( compare ) {
var is = color( compare ),
same = true,
inst = this;
each( spaces, function( _, space ) {
var localCache,
isCache = is[ space.cache ];
if (isCache) {
localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
each( space.props, function( _, prop ) {
if ( isCache[ prop.idx ] != null ) {
same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
return same;
}
});
}
return same;
});
return same;
},
_space: function() {
var used = [],
inst = this;
each( spaces, function( spaceName, space ) {
if ( inst[ space.cache ] ) {
used.push( spaceName );
}
});
return used.pop();
},
transition: function( other, distance ) {
var end = color( other ),
spaceName = end._space(),
space = spaces[ spaceName ],
startColor = this.alpha() === 0 ? color( "transparent" ) : this,
start = startColor[ space.cache ] || space.to( startColor._rgba ),
result = start.slice();
end = end[ space.cache ];
each( space.props, function( key, prop ) {
var index = prop.idx,
startValue = start[ index ],
endValue = end[ index ],
type = propTypes[ prop.type ] || {};
// if null, don't override start value
if ( endValue === null ) {
return;
}
// if null - use end
if ( startValue === null ) {
result[ index ] = endValue;
} else {
if ( type.mod ) {
if ( endValue - startValue > type.mod / 2 ) {
startValue += type.mod;
} else if ( startValue - endValue > type.mod / 2 ) {
startValue -= type.mod;
}
}
result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
}
});
return this[ spaceName ]( result );
},
blend: function( opaque ) {
// if we are already opaque - return ourself
if ( this._rgba[ 3 ] === 1 ) {
return this;
}
var rgb = this._rgba.slice(),
a = rgb.pop(),
blend = color( opaque )._rgba;
return color( jQuery.map( rgb, function( v, i ) {
return ( 1 - a ) * blend[ i ] + a * v;
}));
},
toRgbaString: function() {
var prefix = "rgba(",
rgba = jQuery.map( this._rgba, function( v, i ) {
return v == null ? ( i > 2 ? 1 : 0 ) : v;
});
if ( rgba[ 3 ] === 1 ) {
rgba.pop();
prefix = "rgb(";
}
return prefix + rgba.join() + ")";
},
toHslaString: function() {
var prefix = "hsla(",
hsla = jQuery.map( this.hsla(), function( v, i ) {
if ( v == null ) {
v = i > 2 ? 1 : 0;
}
// catch 1 and 2
if ( i && i < 3 ) {
v = Math.round( v * 100 ) + "%";
}
return v;
});
if ( hsla[ 3 ] === 1 ) {
hsla.pop();
prefix = "hsl(";
}
return prefix + hsla.join() + ")";
},
toHexString: function( includeAlpha ) {
var rgba = this._rgba.slice(),
alpha = rgba.pop();
if ( includeAlpha ) {
rgba.push( ~~( alpha * 255 ) );
}
return "#" + jQuery.map( rgba, function( v ) {
// default to 0 when nulls exist
v = ( v || 0 ).toString( 16 );
return v.length === 1 ? "0" + v : v;
}).join("");
},
toString: function() {
return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
}
});
color.fn.parse.prototype = color.fn;
// hsla conversions adapted from:
// https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
function hue2rgb( p, q, h ) {
h = ( h + 1 ) % 1;
if ( h * 6 < 1 ) {
return p + (q - p) * h * 6;
}
if ( h * 2 < 1) {
return q;
}
if ( h * 3 < 2 ) {
return p + (q - p) * ((2/3) - h) * 6;
}
return p;
}
spaces.hsla.to = function ( rgba ) {
if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
return [ null, null, null, rgba[ 3 ] ];
}
var r = rgba[ 0 ] / 255,
g = rgba[ 1 ] / 255,
b = rgba[ 2 ] / 255,
a = rgba[ 3 ],
max = Math.max( r, g, b ),
min = Math.min( r, g, b ),
diff = max - min,
add = max + min,
l = add * 0.5,
h, s;
if ( min === max ) {
h = 0;
} else if ( r === max ) {
h = ( 60 * ( g - b ) / diff ) + 360;
} else if ( g === max ) {
h = ( 60 * ( b - r ) / diff ) + 120;
} else {
h = ( 60 * ( r - g ) / diff ) + 240;
}
// chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
// otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
if ( diff === 0 ) {
s = 0;
} else if ( l <= 0.5 ) {
s = diff / add;
} else {
s = diff / ( 2 - add );
}
return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
};
spaces.hsla.from = function ( hsla ) {
if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
return [ null, null, null, hsla[ 3 ] ];
}
var h = hsla[ 0 ] / 360,
s = hsla[ 1 ],
l = hsla[ 2 ],
a = hsla[ 3 ],
q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
p = 2 * l - q;
return [
Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
Math.round( hue2rgb( p, q, h ) * 255 ),
Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
a
];
};
each( spaces, function( spaceName, space ) {
var props = space.props,
cache = space.cache,
to = space.to,
from = space.from;
// makes rgba() and hsla()
color.fn[ spaceName ] = function( value ) {
// generate a cache for this space if it doesn't exist
if ( to && !this[ cache ] ) {
this[ cache ] = to( this._rgba );
}
if ( value === undefined ) {
return this[ cache ].slice();
}
var ret,
type = jQuery.type( value ),
arr = ( type === "array" || type === "object" ) ? value : arguments,
local = this[ cache ].slice();
each( props, function( key, prop ) {
var val = arr[ type === "object" ? key : prop.idx ];
if ( val == null ) {
val = local[ prop.idx ];
}
local[ prop.idx ] = clamp( val, prop );
});
if ( from ) {
ret = color( from( local ) );
ret[ cache ] = local;
return ret;
} else {
return color( local );
}
};
// makes red() green() blue() alpha() hue() saturation() lightness()
each( props, function( key, prop ) {
// alpha is included in more than one space
if ( color.fn[ key ] ) {
return;
}
color.fn[ key ] = function( value ) {
var vtype = jQuery.type( value ),
fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
local = this[ fn ](),
cur = local[ prop.idx ],
match;
if ( vtype === "undefined" ) {
return cur;
}
if ( vtype === "function" ) {
value = value.call( this, cur );
vtype = jQuery.type( value );
}
if ( value == null && prop.empty ) {
return this;
}
if ( vtype === "string" ) {
match = rplusequals.exec( value );
if ( match ) {
value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
}
}
local[ prop.idx ] = value;
return this[ fn ]( local );
};
});
});
// add cssHook and .fx.step function for each named hook.
// accept a space separated string of properties
color.hook = function( hook ) {
var hooks = hook.split( " " );
each( hooks, function( i, hook ) {
jQuery.cssHooks[ hook ] = {
set: function( elem, value ) {
var parsed, curElem,
backgroundColor = "";
if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
value = color( parsed || value );
if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
curElem = hook === "backgroundColor" ? elem.parentNode : elem;
while (
(backgroundColor === "" || backgroundColor === "transparent") &&
curElem && curElem.style
) {
try {
backgroundColor = jQuery.css( curElem, "backgroundColor" );
curElem = curElem.parentNode;
} catch ( e ) {
}
}
value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
backgroundColor :
"_default" );
}
value = value.toRgbaString();
}
try {
elem.style[ hook ] = value;
} catch( e ) {
// wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
}
}
};
jQuery.fx.step[ hook ] = function( fx ) {
if ( !fx.colorInit ) {
fx.start = color( fx.elem, hook );
fx.end = color( fx.end );
fx.colorInit = true;
}
jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
};
});
};
color.hook( stepHooks );
jQuery.cssHooks.borderColor = {
expand: function( value ) {
var expanded = {};
each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
expanded[ "border" + part + "Color" ] = value;
});
return expanded;
}
};
// Basic color names only.
// Usage of any of the other color names requires adding yourself or including
// jquery.color.svg-names.js.
colors = jQuery.Color.names = {
// 4.1. Basic color keywords
aqua: "#00ffff",
black: "#000000",
blue: "#0000ff",
fuchsia: "#ff00ff",
gray: "#808080",
green: "#008000",
lime: "#00ff00",
maroon: "#800000",
navy: "#000080",
olive: "#808000",
purple: "#800080",
red: "#ff0000",
silver: "#c0c0c0",
teal: "#008080",
white: "#ffffff",
yellow: "#ffff00",
// 4.2.3. "transparent" color keyword
transparent: [ null, null, null, 0 ],
_default: "#ffffff"
};
}( jQuery ));
/*
* jQuery Color Animations v@VERSION
* https://github.com/jquery/jquery-color
*
* Copyright 2013 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* Date: @DATE
*/
(function(o,d){var k="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",h=/^([\-+])=\s*(\d+\.?\d*)/,g=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(p){return[p[1],p[2],p[3],p[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(p){return[p[1]*2.55,p[2]*2.55,p[3]*2.55,p[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(p){return[parseInt(p[1],16),parseInt(p[2],16),parseInt(p[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(p){return[parseInt(p[1]+p[1],16),parseInt(p[2]+p[2],16),parseInt(p[3]+p[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(p){return[p[1],p[2]/100,p[3]/100,p[4]]}}],e=o.Color=function(q,r,p,s){return new o.Color.fn.parse(q,r,p,s)},j={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},n={"byte":{floor:true,max:255},percent:{max:1},degrees:{mod:360,floor:true}},m=e.support={},b=o("<p>")[0],a,l=o.each;b.style.cssText="background-color:rgba(1,1,1,.5)";m.rgba=b.style.backgroundColor.indexOf("rgba")>-1;l(j,function(p,q){q.cache="_"+p;q.props.alpha={idx:3,type:"percent",def:1}});function i(q,s,r){var p=n[s.type]||{};if(q==null){return(r||!s.def)?null:s.def}q=p.floor?~~q:parseFloat(q);if(isNaN(q)){return s.def}if(p.mod){return(q+p.mod)%p.mod}return 0>q?0:p.max<q?p.max:q}function f(p){var r=e(),q=r._rgba=[];p=p.toLowerCase();l(g,function(w,x){var u,v=x.re.exec(p),t=v&&x.parse(v),s=x.space||"rgba";if(t){u=r[s](t);r[j[s].cache]=u[j[s].cache];q=r._rgba=u._rgba;return false}});if(q.length){if(q.join()==="0,0,0,0"){o.extend(q,a.transparent)}return r}return a[p]}e.fn=o.extend(e.prototype,{parse:function(v,t,p,u){if(v===d){this._rgba=[null,null,null,null];return this}if(v.jquery||v.nodeType){v=o(v).css(t);t=d}var s=this,r=o.type(v),q=this._rgba=[];if(t!==d){v=[v,t,p,u];r="array"}if(r==="string"){return this.parse(f(v)||a._default)}if(r==="array"){l(j.rgba.props,function(w,x){q[x.idx]=i(v[x.idx],x)});return this}if(r==="object"){if(v instanceof e){l(j,function(w,x){if(v[x.cache]){s[x.cache]=v[x.cache].slice()}})}else{l(j,function(x,y){var w=y.cache;l(y.props,function(z,A){if(!s[w]&&y.to){if(z==="alpha"||v[z]==null){return}s[w]=y.to(s._rgba)}s[w][A.idx]=i(v[z],A,true)});if(s[w]&&o.inArray(null,s[w].slice(0,3))<0){s[w][3]=1;if(y.from){s._rgba=y.from(s[w])}}})}return this}},is:function(r){var p=e(r),s=true,q=this;l(j,function(t,v){var w,u=p[v.cache];if(u){w=q[v.cache]||v.to&&v.to(q._rgba)||[];l(v.props,function(x,y){if(u[y.idx]!=null){s=(u[y.idx]===w[y.idx]);return s}})}return s});return s},_space:function(){var p=[],q=this;l(j,function(r,s){if(q[s.cache]){p.push(r)}});return p.pop()},transition:function(q,w){var r=e(q),s=r._space(),t=j[s],u=this.alpha()===0?e("transparent"):this,v=u[t.cache]||t.to(u._rgba),p=v.slice();r=r[t.cache];l(t.props,function(A,C){var z=C.idx,y=v[z],x=r[z],B=n[C.type]||{};if(x===null){return}if(y===null){p[z]=x}else{if(B.mod){if(x-y>B.mod/2){y+=B.mod}else{if(y-x>B.mod/2){y-=B.mod}}}p[z]=i((x-y)*w+y,C)}});return this[s](p)},blend:function(s){if(this._rgba[3]===1){return this}var r=this._rgba.slice(),q=r.pop(),p=e(s)._rgba;return e(o.map(r,function(t,u){return(1-q)*p[u]+q*t}))},toRgbaString:function(){var q="rgba(",p=o.map(this._rgba,function(r,s){return r==null?(s>2?1:0):r});if(p[3]===1){p.pop();q="rgb("}return q+p.join()+")"},toHslaString:function(){var q="hsla(",p=o.map(this.hsla(),function(r,s){if(r==null){r=s>2?1:0}if(s&&s<3){r=Math.round(r*100)+"%"}return r});if(p[3]===1){p.pop();q="hsl("}return q+p.join()+")"},toHexString:function(p){var q=this._rgba.slice(),r=q.pop();if(p){q.push(~~(r*255))}return"#"+o.map(q,function(s){s=(s||0).toString(16);return s.length===1?"0"+s:s}).join("")},toString:function(){return this._rgba[3]===0?"transparent":this.toRgbaString()}});e.fn.parse.prototype=e.fn;function c(t,s,r){r=(r+1)%1;if(r*6<1){return t+(s-t)*r*6}if(r*2<1){return s}if(r*3<2){return t+(s-t)*((2/3)-r)*6}return t}j.hsla.to=function(t){if(t[0]==null||t[1]==null||t[2]==null){return[null,null,null,t[3]]}var p=t[0]/255,w=t[1]/255,x=t[2]/255,z=t[3],y=Math.max(p,w,x),u=Math.min(p,w,x),A=y-u,B=y+u,q=B*0.5,v,C;if(u===y){v=0}else{if(p===y){v=(60*(w-x)/A)+360}else{if(w===y){v=(60*(x-p)/A)+120}else{v=(60*(p-w)/A)+240}}}if(A===0){C=0}else{if(q<=0.5){C=A/B}else{C=A/(2-B)}}return[Math.round(v)%360,C,q,z==null?1:z]};j.hsla.from=function(w){if(w[0]==null||w[1]==null||w[2]==null){return[null,null,null,w[3]]}var v=w[0]/360,u=w[1],t=w[2],r=w[3],x=t<=0.5?t*(1+u):t+u-t*u,y=2*t-x;return[Math.round(c(y,x,v+(1/3))*255),Math.round(c(y,x,v)*255),Math.round(c(y,x,v-(1/3))*255),r]};l(j,function(q,s){var r=s.props,p=s.cache,u=s.to,t=s.from;e.fn[q]=function(z){if(u&&!this[p]){this[p]=u(this._rgba)}if(z===d){return this[p].slice()}var w,y=o.type(z),v=(y==="array"||y==="object")?z:arguments,x=this[p].slice();l(r,function(A,C){var B=v[y==="object"?A:C.idx];if(B==null){B=x[C.idx]}x[C.idx]=i(B,C)});if(t){w=e(t(x));w[p]=x;return w}else{return e(x)}};l(r,function(v,w){if(e.fn[v]){return}e.fn[v]=function(A){var C=o.type(A),z=(v==="alpha"?(this._hsla?"hsla":"rgba"):q),y=this[z](),B=y[w.idx],x;if(C==="undefined"){return B}if(C==="function"){A=A.call(this,B);C=o.type(A)}if(A==null&&w.empty){return this}if(C==="string"){x=h.exec(A);if(x){A=B+parseFloat(x[2])*(x[1]==="+"?1:-1)}}y[w.idx]=A;return this[z](y)}})});e.hook=function(q){var p=q.split(" ");l(p,function(r,s){o.cssHooks[s]={set:function(w,x){var u,v,t="";if(x!=="transparent"&&(o.type(x)!=="string"||(u=f(x)))){x=e(u||x);if(!m.rgba&&x._rgba[3]!==1){v=s==="backgroundColor"?w.parentNode:w;while((t===""||t==="transparent")&&v&&v.style){try{t=o.css(v,"backgroundColor");v=v.parentNode}catch(y){}}x=x.blend(t&&t!=="transparent"?t:"_default")}x=x.toRgbaString()}try{w.style[s]=x}catch(y){}}};o.fx.step[s]=function(t){if(!t.colorInit){t.start=e(t.elem,s);t.end=e(t.end);t.colorInit=true}o.cssHooks[s].set(t.elem,t.start.transition(t.end,t.pos))}})};e.hook(k);o.cssHooks.borderColor={expand:function(q){var p={};l(["Top","Right","Bottom","Left"],function(s,r){p["border"+r+"Color"]=q});return p}};a=o.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(jQuery));
\ No newline at end of file
/*!
* jQuery Color Animations v@VERSION - SVG Color Names
* https://github.com/jquery/jquery-color
*
* Remaining HTML/CSS color names per W3C's CSS Color Module Level 3.
* http://www.w3.org/TR/css3-color/#svg-color
*
* Copyright 2013 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* Date: @DATE
*/
jQuery.extend( jQuery.Color.names, {
// 4.3. Extended color keywords (minus the basic ones in core color plugin)
aliceblue: "#f0f8ff",
antiquewhite: "#faebd7",
aquamarine: "#7fffd4",
azure: "#f0ffff",
beige: "#f5f5dc",
bisque: "#ffe4c4",
blanchedalmond: "#ffebcd",
blueviolet: "#8a2be2",
brown: "#a52a2a",
burlywood: "#deb887",
cadetblue: "#5f9ea0",
chartreuse: "#7fff00",
chocolate: "#d2691e",
coral: "#ff7f50",
cornflowerblue: "#6495ed",
cornsilk: "#fff8dc",
crimson: "#dc143c",
cyan: "#00ffff",
darkblue: "#00008b",
darkcyan: "#008b8b",
darkgoldenrod: "#b8860b",
darkgray: "#a9a9a9",
darkgreen: "#006400",
darkgrey: "#a9a9a9",
darkkhaki: "#bdb76b",
darkmagenta: "#8b008b",
darkolivegreen: "#556b2f",
darkorange: "#ff8c00",
darkorchid: "#9932cc",
darkred: "#8b0000",
darksalmon: "#e9967a",
darkseagreen: "#8fbc8f",
darkslateblue: "#483d8b",
darkslategray: "#2f4f4f",
darkslategrey: "#2f4f4f",
darkturquoise: "#00ced1",
darkviolet: "#9400d3",
deeppink: "#ff1493",
deepskyblue: "#00bfff",
dimgray: "#696969",
dimgrey: "#696969",
dodgerblue: "#1e90ff",
firebrick: "#b22222",
floralwhite: "#fffaf0",
forestgreen: "#228b22",
gainsboro: "#dcdcdc",
ghostwhite: "#f8f8ff",
gold: "#ffd700",
goldenrod: "#daa520",
greenyellow: "#adff2f",
grey: "#808080",
honeydew: "#f0fff0",
hotpink: "#ff69b4",
indianred: "#cd5c5c",
indigo: "#4b0082",
ivory: "#fffff0",
khaki: "#f0e68c",
lavender: "#e6e6fa",
lavenderblush: "#fff0f5",
lawngreen: "#7cfc00",
lemonchiffon: "#fffacd",
lightblue: "#add8e6",
lightcoral: "#f08080",
lightcyan: "#e0ffff",
lightgoldenrodyellow: "#fafad2",
lightgray: "#d3d3d3",
lightgreen: "#90ee90",
lightgrey: "#d3d3d3",
lightpink: "#ffb6c1",
lightsalmon: "#ffa07a",
lightseagreen: "#20b2aa",
lightskyblue: "#87cefa",
lightslategray: "#778899",
lightslategrey: "#778899",
lightsteelblue: "#b0c4de",
lightyellow: "#ffffe0",
limegreen: "#32cd32",
linen: "#faf0e6",
mediumaquamarine: "#66cdaa",
mediumblue: "#0000cd",
mediumorchid: "#ba55d3",
mediumpurple: "#9370db",
mediumseagreen: "#3cb371",
mediumslateblue: "#7b68ee",
mediumspringgreen: "#00fa9a",
mediumturquoise: "#48d1cc",
mediumvioletred: "#c71585",
midnightblue: "#191970",
mintcream: "#f5fffa",
mistyrose: "#ffe4e1",
moccasin: "#ffe4b5",
navajowhite: "#ffdead",
oldlace: "#fdf5e6",
olivedrab: "#6b8e23",
orange: "#ffa500",
orangered: "#ff4500",
orchid: "#da70d6",
palegoldenrod: "#eee8aa",
palegreen: "#98fb98",
paleturquoise: "#afeeee",
palevioletred: "#db7093",
papayawhip: "#ffefd5",
peachpuff: "#ffdab9",
peru: "#cd853f",
pink: "#ffc0cb",
plum: "#dda0dd",
powderblue: "#b0e0e6",
rosybrown: "#bc8f8f",
royalblue: "#4169e1",
saddlebrown: "#8b4513",
salmon: "#fa8072",
sandybrown: "#f4a460",
seagreen: "#2e8b57",
seashell: "#fff5ee",
sienna: "#a0522d",
skyblue: "#87ceeb",
slateblue: "#6a5acd",
slategray: "#708090",
slategrey: "#708090",
snow: "#fffafa",
springgreen: "#00ff7f",
steelblue: "#4682b4",
tan: "#d2b48c",
thistle: "#d8bfd8",
tomato: "#ff6347",
turquoise: "#40e0d0",
violet: "#ee82ee",
wheat: "#f5deb3",
whitesmoke: "#f5f5f5",
yellowgreen: "#9acd32"
});
/*
* jQuery Color Animations v@VERSION - SVG Color Names
* https://github.com/jquery/jquery-color
*
* Remaining HTML/CSS color names per W3C's CSS Color Module Level 3.
* http://www.w3.org/TR/css3-color/#svg-color
*
* Copyright 2013 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* Date: @DATE
*/
jQuery.extend(jQuery.Color.names,{aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",blanchedalmond:"#ffebcd",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",limegreen:"#32cd32",linen:"#faf0e6",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",oldlace:"#fdf5e6",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",whitesmoke:"#f5f5f5",yellowgreen:"#9acd32"});
\ No newline at end of file
{
"name": "jquery-color",
"title": "jQuery Color",
"description": "jQuery plugin for color manipulation and animation support.",
"version": "2.1.3pre",
"homepage": "https://github.com/jquery/jquery-color",
"author": {
"name": "jQuery Foundation and other contributors",
"url": "https://github.com/jquery/jquery-color/blob/master/AUTHORS.txt"
},
"maintainers": [
{
"name": "Corey Frang",
"email": "gnarf37@gmail.com",
"url": "http://gnarf.net"
}
],
"repository": {
"type": "git",
"url": "git://github.com/jquery/jquery-color.git"
},
"bugs": "https://github.com/jquery/jquery-color/issues",
"licenses": [
{
"type": "MIT",
"url": "https://github.com/jquery/jquery-color/blob/master/MIT-LICENSE.txt"
}
],
"dependencies": {},
"devDependencies": {
"grunt": "0.3.17",
"grunt-compare-size": "0.1.4",
"grunt-git-authors": "1.0.0",
"testswarm": "~1.1.0"
},
"keywords": [ "color", "animation" ]
}
// load testswarm agent
(function() {
var url = window.location.search;
url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) );
if ( !url || url.indexOf("http") !== 0 ) {
return;
}
document.write("<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date).getTime() + "'></scr" + "ipt>");
})();
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery-Color Test Suite</title>
<link rel="Stylesheet" media="screen" href="qunit/qunit/qunit.css" />
<script src="data/testinit.js"></script>
<script src="jquery.js"></script>
<script src="../jquery.color.js"></script>
<script src="qunit/qunit/qunit.js"></script>
<script src="unit/color.js"></script>
<script src="data/swarminject.js"></script>
</head>
<body id="body">
<h1 id="qunit-header">jQuery-Color Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
</body>
</html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
(function() {
var parts = document.location.search.slice( 1 ).split( "&" ),
length = parts.length,
i = 0,
current,
version,
url;
for ( ; i < length; i++ ) {
current = parts[ i ].split( "=" );
if ( current[ 0 ] === "jquery" ) {
version = current[ 1 ];
break;
}
}
if ( version === "git" ) {
url = "http://code.jquery.com/jquery-git.js";
} else {
url = "jquery-" + ( version || "1.7.2" ) + ".js";
}
document.write( "<script src='" + url + "'></script>" );
}() );
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="jquery-1.5.1.js"></script>
<script type="text/javascript" src="../jquery.color.js"></script>
</head>
<body>
<div id="test" style="background-color: #00ffff">Test string</div>
<script type="text/javascript">
//<![CDATA[
var $div = $("#test");
$div./*animate({"background-color": "#ffff00"}, 300).*/
animate({"background-color": 'transparent'}, 400);
// var savedColor = $div.css("backgroundColor");
// alert(savedColor);
// $div.animate({"background-color": "#ffff00"}, 300).
// animate({"background-color": savedColor}, 400);
//]]>
</script>
</body>
</html>
{
"boss": true,
"browser": true,
"curly": true,
"eqnull": true,
"eqeqeq": true,
"expr": true,
"jquery": true,
"latedef": true,
"noarg": true,
"onevar": true,
"quotmark": "double",
"trailing": true,
"undef": true,
"unused": true,
"predef": [
"asyncTest",
"deepEqual",
"equal",
"expect",
"module",
"notEqual",
"ok",
"start",
"stop",
"strictEqual",
"test"
]
}
module( "parse" );
function testParts( color, parts ) {
var prefix = parts.prefix || "";
if ( parts.expect ) {
expect( parts.expect );
}
jQuery.each( parts, function( key , value ) {
// these two properties are just helpers for the test function, ignore them
if ( key === "expect" || key === "prefix" ) {
return;
}
strictEqual( color[ key ](), value, prefix + "."+key+"() is "+value);
});
}
function parseTest( str, results, descr ) {
test( descr || "jQuery.Color( \""+str+"\" )", function() {
var color = descr ? str : jQuery.Color( str );
testParts( color, results );
});
}
test( "jQuery.Color( 255, 255, 255 )", function() {
expect( 4 );
testParts( jQuery.Color( 255, 255, 255 ), {
expect: 4,
red: 255,
green: 255,
blue: 255,
alpha: 1
});
});
test( "jQuery.Color( element, \"color\" )", function() {
var $div = jQuery( "<div>" ).appendTo( "body" ).css( "color", "#fff" );
expect( 8 );
testParts( jQuery.Color( $div, "color" ), {
prefix: "jQuery(<div>): ",
red: 255,
green: 255,
blue: 255,
alpha: 1
});
testParts( jQuery.Color( $div[ 0 ], "color" ), {
prefix: "<div>: ",
red: 255,
green: 255,
blue: 255,
alpha: 1
});
$div.remove();
});
parseTest( jQuery.Color({ red: 100 }), {
expect: 4,
red: 100,
green: null,
blue: null,
alpha: null
}, "jQuery.Color({ red: 100 })" );
test( "jQuery.Color({ blue: 100 })", function() {
var blue = jQuery.Color({ blue: 100 });
testParts( blue, {
red: null,
green: null,
blue: 100,
alpha: null
});
ok( !blue._hsla, "No HSLA cache");
});
test( "jQuery.Color({ alpha: 1 })", function() {
var blue = jQuery.Color({ alpha: 1 });
testParts( blue, {
red: null,
green: null,
blue: null,
alpha: 1
});
ok( !blue._hsla, "No HSLA cache");
});
test( "jQuery.Color({ alpha: 1, hue: 100 })", function() {
var blue = jQuery.Color({ alpha: 1, hue: 100 });
testParts( blue, {
red: null,
green: null,
blue: null,
alpha: 1,
hue: 100,
saturation: null,
lightness: null
});
deepEqual( blue._hsla, [ 100, null, null, 1 ], "HSLA cache has correct values");
});
test( "jQuery.Color({ hue: 100, saturation: 1, lightness: 0.5 })", function() {
var blue = jQuery.Color({ hue: 100, saturation: 1, lightness: 0.5 });
testParts( blue, {
red: 85,
green: 255,
blue: 0,
alpha: 1,
hue: 100,
saturation: 1,
lightness: 0.5
});
deepEqual( blue._rgba, [ 85, 255, 0, 1 ], "RGBA cache has correct values");
deepEqual( blue._hsla, [ 100, 1, 0.5, 1 ], "HSLA cache has correct values");
});
parseTest( jQuery.Color( jQuery.Color( "red" ) ), {
expect: 4,
red: 255,
green: 0,
blue: 0,
alpha: 1
}, "jQuery.Color( jQuery.Color(\"red\") )" );
parseTest( jQuery.Color([ 255, 255, 255 ]), {
expect: 4,
red: 255,
green: 255,
blue: 255,
alpha: 1
}, "jQuery.Color([ 255, 255, 255 ])" );
parseTest( "", {
expect: 4,
red: 255,
green: 255,
blue: 255,
alpha: 1
});
var sevens = {
expect: 4,
red: 119,
green: 119,
blue: 119,
alpha: 1
};
parseTest( "#777", sevens );
parseTest( "#777777", sevens );
var fiftypercent = {
expect: 4,
red: 127,
green: 127,
blue: 127,
alpha: 1
}, fiftypercentalpha = {
expect: 4,
red: 127,
green: 127,
blue: 127,
alpha: 0.5
};
parseTest( "rgb(127,127,127)", fiftypercent );
parseTest( "rgb(50%,50%,50%)", fiftypercent );
parseTest( "rgba(127,127,127,1)", fiftypercent );
parseTest( "rgba(50%,50%,50%,1)", fiftypercent );
parseTest( "rgba(127,127,127,0.5)", fiftypercentalpha );
parseTest( "rgba(50%,50%,50%,0.5)", fiftypercentalpha );
parseTest( "rgba(127, 127, 127, .5)", fiftypercentalpha );
parseTest( "rgba(50%, 50%, 50%, .5)", fiftypercentalpha );
parseTest( "rgba(0, 0, 0, 0)", {
expect: 4,
red: null,
green: null,
blue: null,
alpha: 0
});
parseTest("red", {
expect: 4,
red: 255,
green: 0,
blue: 0,
alpha: 1
});
parseTest("transparent", {
expect: 4,
red: null,
green: null,
blue: null,
alpha: 0
});
module( "color" );
test( "red green blue alpha Setters", function() {
var props = "red green blue alpha".split(" "),
color = jQuery.Color( [0,0,0,0] );
expect( 4 * props.length );
jQuery.each( props, function( i, fn ) {
var tv = fn==="alpha" ? 0.5 : 255,
set = color[ fn ]( tv ),
clamp = fn==="alpha" ? 1 : 255,
clamped = color[ fn ]( clamp + 1 ),
plused = color[ fn ]( "+=1" );
equal( set[ fn ](), tv, "color."+fn+"("+tv+")."+fn+"()" );
equal( clamped[ fn ](), clamp, "color."+fn+"("+(clamp+1)+") clamped at "+clamp );
equal( color[ fn ](), 0, "color."+fn+"() still 0" );
equal( plused[ fn ](), 1, "color."+fn+"(\"+=1\")" );
});
});
test( ".rgba()", function() {
var color = jQuery.Color( "black" ),
getter = color.rgba(),
set1 = color.rgba( null, 100, null, 0 ),
set2 = color.rgba([ null, null, 100, 0.5 ]),
set3 = color.rgba({ red: 300, alpha: 2 });
expect( 14 );
deepEqual( getter, color._rgba, "Returned a array has same values" );
notEqual( getter, color._rgba, "Returned a COPY of the rgba" );
testParts( set1, {
prefix: ".rgba( null, 100, null, 0 )",
red: 0,
green: 100,
blue: 0,
alpha: 0
});
testParts( set2, {
prefix: ".rgba([ null, null, 100, 0 ])",
red: 0,
green: 0,
blue: 100,
alpha: 0.5
});
testParts( set3, {
prefix: ".rgba({ red: 300, alpha: 2 })",
red: 255,
green: 0,
blue: 0,
alpha: 1
});
});
test( ".blend()", function() {
var halfwhite = jQuery.Color( "white" ).alpha( 0.5 ),
red = jQuery.Color( "red" ),
blend = halfwhite.blend( red );
expect( 8 );
testParts( blend, {
prefix: "Blending with color object: ",
red: 255,
green: 127,
blue: 127,
alpha: 1
});
testParts( halfwhite.blend("red"), {
prefix: "Using string as color: ",
red: 255,
green: 127,
blue: 127,
alpha: 1
});
});
test( ".transition() works with $.Colors", function() {
var black = jQuery.Color( "black" ),
whiteAlpha = jQuery.Color( "white" ).alpha( 0.5 ),
trans = jQuery.Color( "transparent" ),
fifty = black.transition( whiteAlpha, 0.5 );
expect( 16 );
testParts( fifty, {
prefix: "black -> whiteAlpha 0.5",
red: 127,
green: 127,
blue: 127,
alpha: 0.75
});
testParts( black.transition( trans, 0.5 ), {
prefix: "black -> transparent 0.5 ",
red: 0,
green: 0,
blue: 0,
alpha: 0.5
});
testParts( whiteAlpha.transition( trans, 0.5 ), {
prefix: "whiteAlpha -> transparent 0.5 ",
red: 255,
green: 255,
blue: 255,
alpha: 0.25
});
// fixes issue #32
testParts( jQuery.Color( 255, 0, 0, 0 ).transition( black, 0.5 ), {
prefix: "transparent red -> black 0.5",
red: 0,
green: 0,
blue: 0,
alpha: 0.5
});
});
test( ".transtion() works with strings and objects", function() {
var black = jQuery.Color( "black" );
testParts( black.transition( "white", 0.5 ), {
prefix: "black -> 'white'",
red: 127,
green: 127,
blue: 127
});
testParts( black.transition( "red", 0.5 ), {
prefix: "black -> 'red'",
red: 127,
green: 0,
blue: 0
});
testParts( black.transition({ blue: 255 }, 0.5 ), {
prefix: "black -> { blue: 255 }",
red: 0,
green: 0,
blue: 127
});
testParts( black.transition([ 200, 200, 200 ], 0.5 ), {
prefix: "black -> [ 200, 200, 200 ]",
red: 100,
green: 100,
blue: 100
});
});
test( ".is()", function() {
var red = jQuery.Color( "red" );
ok( red.is( red ), "Red is itself");
ok( red.is({ red: 255 }), "Red is equal to { red: 255 }");
ok( red.is({ saturation: 1 }), "Red is equal to { saturation: 1 }");
ok( red.is([255,0,0]), "Red is equal to [255,0,0]");
ok( red.is("red"), "Red is equal to \"red\"");
ok( !red.is("blue"), "Red is not blue");
ok( !red.is({ alpha: 0 }), "Red is not { alpha: 0 }");
});
test( ".toRgbaString()", function() {
var black = jQuery.Color( "black" ),
trans = black.alpha( 0.5 );
expect( 2 );
equal( black.toRgbaString(), "rgb(0,0,0)" );
equal( trans.toRgbaString(), "rgba(0,0,0,0.5)" );
});
test( ".toHexString()", function() {
var almostBlack = jQuery.Color( "black" ).red( 2 ).blue( 16 ),
trans = almostBlack.alpha( 0.5 );
expect( 2 );
equal( almostBlack.toHexString(), "#020010" , "to hex");
equal( trans.toHexString( true ), "#0200107f", "to hex with alpha" );
});
test( "toString() methods keep alpha intact", function() {
var trans = jQuery.Color( "transparent" ),
opaque = jQuery.Color( "red" );
expect( 4 );
trans.toRgbaString();
opaque.toRgbaString();
equal( trans.alpha(), 0, "toRgbaString()" );
equal( opaque.alpha(), 1, "toRgbaString()" );
trans.toHexString();
opaque.toHexString();
equal( trans.alpha(), 0, "toHexString()" );
equal( opaque.alpha(), 1, "toHexString()" );
});
module( "hsla" );
parseTest("hsla(180,50%,50%,0.5)", {
expect: 7,
hue: 180,
saturation: 0.5,
lightness: 0.5,
red: 64,
green: 191,
blue: 191,
alpha: 0.5
});
parseTest("hsla( 180, 50%, 50%, 1 )", {
expect: 7,
hue: 180,
saturation: 0.5,
lightness: 0.5,
red: 64,
green: 191,
blue: 191,
alpha: 1
});
parseTest("hsla( 180, 50%, 50%, .5 )", {
expect: 7,
hue: 180,
saturation: 0.5,
lightness: 0.5,
red: 64,
green: 191,
blue: 191,
alpha: 0.5
});
parseTest("hsl(72, 77%, 59%)", {
expect: 7,
hue: 72,
saturation: 0.77,
lightness: 0.59,
red: 199,
green: 231,
blue: 70,
alpha: 1
});
parseTest( jQuery.Color({ alpha: 0 }), {
expect: 7,
hue: null,
saturation: null,
lightness: null,
alpha: 0,
red: null,
green: null,
blue: null
}, "jQuery.Color({ alpha: 0 })" );
parseTest( jQuery.Color({ saturation: 0 }), {
expect: 7,
hue: null,
saturation: 0,
lightness: null,
alpha: null,
red: null,
green: null,
blue: null
}, "jQuery.Color({ saturation: 0 })" );
parseTest( jQuery.Color({ saturation: 0, alpha: 0 }), {
expect: 7,
hue: null,
saturation: 0,
lightness: null,
alpha: 0,
red: null,
green: null,
blue: null
}, "jQuery.Color({ saturation: 0, alpha: 0 })" );
test("HSLA Conversions", function() {
expect(11);
equal( jQuery.Color( "#000" ).toHslaString(), "hsl(0,0%,0%)", "HSLA value from #000");
equal( jQuery.Color( "#fff" ).toHslaString(), "hsl(0,0%,100%)", "HSLA value from #fff");
equal( jQuery.Color( "#f00" ).toHslaString(), "hsl(0,100%,50%)", "HSLA value from #f00");
equal( jQuery.Color( "#ff0" ).toHslaString(), "hsl(60,100%,50%)", "HSLA value from #ff0");
equal( jQuery.Color( "#0f0" ).toHslaString(), "hsl(120,100%,50%)", "HSLA value from #0f0");
equal( jQuery.Color( "#0ff" ).toHslaString(), "hsl(180,100%,50%)", "HSLA value from #0ff");
equal( jQuery.Color( "#00f" ).toHslaString(), "hsl(240,100%,50%)", "HSLA value from #00f");
equal( jQuery.Color( "#f0f" ).toHslaString(), "hsl(300,100%,50%)", "HSLA value from #f0f");
equal( jQuery.Color( "#7f007f" ).toHslaString(), "hsl(300,100%,25%)", "HSLA value from #7f007f");
equal( jQuery.Color( "#ff7fff" ).toHslaString(), "hsl(300,100%,75%)", "HSLA value from #ff7fff");
equal( jQuery.Color( "rgba(127,127,127,0.1)" ).toHslaString(), "hsla(0,0%,50%,0.1)", "HSLA value from rgba(127,127,127,0.1)");
});
test("HSLA Transitions", function() {
var red = jQuery.Color("red"),
desaturate = red.transition( jQuery.Color({ saturation: 0 }), 0.5 ),
hue10 = red.transition( jQuery.Color({ hue: 10 }), 0.5),
hue350 = red.transition( jQuery.Color({ hue: 350 }), 0.5),
hueWrapPos = jQuery.Color({ hue: 350 }).transition( jQuery.Color({ hue: 10 }));
testParts( desaturate, {
prefix: "red -> desaturatue 0.5",
hue: 0,
saturation: 0.5,
lightness: 0.5,
alpha: 1
});
testParts( hue10, {
prefix: "red -> hue 10 0.5",
hue: 5,
saturation: 1,
lightness: 0.5,
alpha: 1
});
testParts( hue350, {
prefix: "red -> hue 350 0.5",
hue: 355,
saturation: 1,
lightness: 0.5,
alpha: 1
});
testParts( hueWrapPos, {
prefix: " hue 350 -> hue 10 0.5",
hue: 0,
saturation: null,
lightness: null,
alpha: 1
});
});
test( "hue saturation lightness alpha Setters", function() {
var props = "hue saturation lightness alpha".split(" "),
color = jQuery.Color( [0,0,0,0] );
expect( 4 * props.length );
jQuery.each( props, function( i, fn ) {
var tv = fn === "hue" ? 359 : 0.5 ,
set = color[ fn ]( tv ),
clamp = fn === "hue" ? -360 : 1,
clamped = color[ fn ]( clamp + 1 ),
plused = color[ fn ]( "+=1" );
equal( set[ fn ](), tv, "color."+fn+"("+tv+")."+fn+"()" );
equal( clamped[ fn ](), 1, "color."+fn+"("+(clamp+1)+") clamped at 1" );
equal( color[ fn ](), 0, "color."+fn+"() still 0" );
equal( plused[ fn ](), 1, "color."+fn+"(\"+=1\")" );
});
});
test( "alpha setter leaves space as hsla", function() {
var test = jQuery.Color({hue: 0, saturation: 0, lightness: 0, alpha: 0}).alpha( 1 );
ok( test._hsla, "HSLA cache still exists after calling alpha setter" );
});
module( "animate" );
test( "animated", function() {
var el = jQuery( "<div></div>" ).appendTo( "body" ).css({ color: "#000000" });
expect( 8 );
stop();
el.animate({ color: "#ffffff" }, 1, function() {
testParts( jQuery.Color( el, "color" ), {
prefix: "Post Animated Color finished properly",
red: 255,
green: 255,
blue: 255,
alpha: 1
});
el.css( "color", "white" ).animate({ color: "#000000" }, 200).stop( true );
testParts( jQuery.Color( el, "color" ), {
prefix: "Immediately Stopped.. Animated Color didn't change",
red: 255,
green: 255,
blue: 255,
alpha: 1
});
el.remove();
start();
});
});
asyncTest( "animated documentFragment", function() {
var el = jQuery( "<div></div>" );
expect(1);
el.animate({ color: "red" }, 200, function() {
ok( true, "Animation of color on documentFragment did not fail" );
start();
});
});
test( "animate borderColor", function() {
var el = jQuery( "<div style='border: 1px solid blue;'></div>" ).appendTo( "body" );
stop();
el.animate({ borderColor: "#00f" }, {
step: function() {
testParts( jQuery.Color( el, "borderTopColor" ), {
red: 0,
green: 0,
blue: 255,
alpha: 1
});
el.stop().remove();
start();
}
});
});
test( "Setting CSS to empty string / inherit", function() {
var el = jQuery( "<div></div>" ).appendTo( "body" ).css({ color: "#fff" });
expect( 2 );
el.css( "color", "" );
equal( el[0].style.color, "", "CSS was set to empty string" );
el.css( "color", "inherit" );
ok( el[0].style.color === "" || el[0].style.color === "inherit", "Setting CSS to inherit didn't throw error" );
});
test( "Setting CSS to transparent", function() {
expect( 1 );
var parentEl = jQuery("<div></div>").appendTo("body").css({ backgroundColor: "blue" }),
el = jQuery("<div></div>").appendTo( parentEl );
el.css( "backgroundColor", "transparent" );
equal( jQuery.Color( el[ 0 ].style.backgroundColor ).alpha(), 0, "CSS was set to transparent" );
});
test( "jQuery.Color.hook() - Create new hooks for color properties", 2, function() {
// these shouldn't be there, but just in case....
delete jQuery.cssHooks.testy;
delete jQuery.fx.step.testy;
jQuery.Color.hook( "testy" );
ok( jQuery.cssHooks.testy, "testy cssHook created" );
ok( jQuery.fx.step.testy, "fx.step testy hook created" );
delete jQuery.cssHooks.testy;
delete jQuery.fx.step.testy;
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment