mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Effects Core: Upgrading jQuery Color to 2.1.1
This commit is contained in:
parent
67b5bc7b3d
commit
f1a44a3fac
108
ui/jquery.ui.effect.js
vendored
108
ui/jquery.ui.effect.js
vendored
@ -19,24 +19,24 @@ $.effects = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* jQuery Color Animations v2.0.0
|
* jQuery Color Animations v2.1.1
|
||||||
* http://jquery.com/
|
* https://github.com/jquery/jquery-color
|
||||||
*
|
*
|
||||||
* Copyright 2012 jQuery Foundation and other contributors
|
* Copyright 2012 jQuery Foundation and other contributors
|
||||||
* Released under the MIT license.
|
* Released under the MIT license.
|
||||||
* http://jquery.org/license
|
* http://jquery.org/license
|
||||||
*
|
*
|
||||||
* Date: Mon Aug 13 13:41:02 2012 -0500
|
* Date: Sun Oct 28 15:08:06 2012 -0400
|
||||||
*/
|
*/
|
||||||
(function( jQuery, undefined ) {
|
(function( jQuery, undefined ) {
|
||||||
|
|
||||||
var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor".split(" "),
|
var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
|
||||||
|
|
||||||
// plusequals test for += 100 -= 100
|
// plusequals test for += 100 -= 100
|
||||||
rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
|
rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
|
||||||
// a set of RE's that can match strings and generate color tuples.
|
// a set of RE's that can match strings and generate color tuples.
|
||||||
stringParsers = [{
|
stringParsers = [{
|
||||||
re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
|
re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
|
||||||
parse: function( execResult ) {
|
parse: function( execResult ) {
|
||||||
return [
|
return [
|
||||||
execResult[ 1 ],
|
execResult[ 1 ],
|
||||||
@ -46,7 +46,7 @@ $.effects = {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
|
re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
|
||||||
parse: function( execResult ) {
|
parse: function( execResult ) {
|
||||||
return [
|
return [
|
||||||
execResult[ 1 ] * 2.55,
|
execResult[ 1 ] * 2.55,
|
||||||
@ -76,7 +76,7 @@ $.effects = {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
|
re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
|
||||||
space: "hsla",
|
space: "hsla",
|
||||||
parse: function( execResult ) {
|
parse: function( execResult ) {
|
||||||
return [
|
return [
|
||||||
@ -293,7 +293,7 @@ color.fn = jQuery.extend( color.prototype, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// everything defined but alpha?
|
// everything defined but alpha?
|
||||||
if ( inst[ cache ] && $.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
|
if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
|
||||||
// use the default of 1
|
// use the default of 1
|
||||||
inst[ cache ][ 3 ] = 1;
|
inst[ cache ][ 3 ] = 1;
|
||||||
if ( space.from ) {
|
if ( space.from ) {
|
||||||
@ -481,8 +481,10 @@ spaces.hsla.to = function ( rgba ) {
|
|||||||
h = ( 60 * ( r - g ) / diff ) + 240;
|
h = ( 60 * ( r - g ) / diff ) + 240;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( l === 0 || l === 1 ) {
|
// chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
|
||||||
s = l;
|
// otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
|
||||||
|
if ( diff === 0 ) {
|
||||||
|
s = 0;
|
||||||
} else if ( l <= 0.5 ) {
|
} else if ( l <= 0.5 ) {
|
||||||
s = diff / add;
|
s = diff / add;
|
||||||
} else {
|
} else {
|
||||||
@ -586,51 +588,58 @@ each( spaces, function( spaceName, space ) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// add .fx.step functions
|
// add cssHook and .fx.step function for each named hook.
|
||||||
each( stepHooks, function( i, hook ) {
|
// accept a space separated string of properties
|
||||||
jQuery.cssHooks[ hook ] = {
|
color.hook = function( hook ) {
|
||||||
set: function( elem, value ) {
|
var hooks = hook.split( " " );
|
||||||
var parsed, curElem,
|
each( hooks, function( i, hook ) {
|
||||||
backgroundColor = "";
|
jQuery.cssHooks[ hook ] = {
|
||||||
|
set: function( elem, value ) {
|
||||||
|
var parsed, curElem,
|
||||||
|
backgroundColor = "";
|
||||||
|
|
||||||
if ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) {
|
if ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) {
|
||||||
value = color( parsed || value );
|
value = color( parsed || value );
|
||||||
if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
|
if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
|
||||||
curElem = hook === "backgroundColor" ? elem.parentNode : elem;
|
curElem = hook === "backgroundColor" ? elem.parentNode : elem;
|
||||||
while (
|
while (
|
||||||
(backgroundColor === "" || backgroundColor === "transparent") &&
|
(backgroundColor === "" || backgroundColor === "transparent") &&
|
||||||
curElem && curElem.style
|
curElem && curElem.style
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
backgroundColor = jQuery.css( curElem, "backgroundColor" );
|
backgroundColor = jQuery.css( curElem, "backgroundColor" );
|
||||||
curElem = curElem.parentNode;
|
curElem = curElem.parentNode;
|
||||||
} catch ( e ) {
|
} catch ( e ) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
|
||||||
|
backgroundColor :
|
||||||
|
"_default" );
|
||||||
}
|
}
|
||||||
|
|
||||||
value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
|
value = value.toRgbaString();
|
||||||
backgroundColor :
|
|
||||||
"_default" );
|
|
||||||
}
|
}
|
||||||
|
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 ) );
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
value = value.toRgbaString();
|
};
|
||||||
}
|
|
||||||
try {
|
color.hook( stepHooks );
|
||||||
elem.style[ hook ] = value;
|
|
||||||
} catch( error ) {
|
|
||||||
// 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 ) );
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery.cssHooks.borderColor = {
|
jQuery.cssHooks.borderColor = {
|
||||||
expand: function( value ) {
|
expand: function( value ) {
|
||||||
@ -674,7 +683,6 @@ colors = jQuery.Color.names = {
|
|||||||
})( jQuery );
|
})( jQuery );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/****************************** CLASS ANIMATIONS ******************************/
|
/****************************** CLASS ANIMATIONS ******************************/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user