aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.effects.core.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/jquery.effects.core.js')
-rw-r--r--ui/jquery.effects.core.js101
1 files changed, 61 insertions, 40 deletions
diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js
index 24df7178c..626ab1a89 100644
--- a/ui/jquery.effects.core.js
+++ b/ui/jquery.effects.core.js
@@ -1,4 +1,4 @@
-/*
+/*!
* jQuery UI Effects @VERSION
*
* Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
@@ -7,9 +7,11 @@
*
* http://docs.jquery.com/UI/Effects/
*/
-;jQuery.effects || (function($, undefined) {
+;(jQuery.effects || (function($, undefined) {
-var backCompat = $.uiBackCompat !== false;
+var backCompat = $.uiBackCompat !== false,
+ // prefix used for storing data on .data()
+ dataSpace = "ui-effects-";
$.effects = {
effect: {}
@@ -18,6 +20,7 @@ $.effects = {
/******************************************************************************/
/****************************** COLOR ANIMATIONS ******************************/
/******************************************************************************/
+(function() {
// override the animation for color styles
$.each(["backgroundColor", "borderBottomColor", "borderLeftColor",
@@ -46,28 +49,34 @@ function getRGB(color) {
var result;
// Check if we're already dealing with an array of colors
- if ( color && color.constructor === Array && color.length === 3 )
- return color;
+ if ( color && color.constructor === Array && color.length === 3 ) {
+ return color;
+ }
// Look for rgb(num,num,num)
- if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
- return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)];
+ if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) {
+ return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)];
+ }
// Look for rgb(num%,num%,num%)
- if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
- return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
+ if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) {
+ return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
+ }
// Look for #a0b1c2
- if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
- return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
+ if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) {
+ return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
+ }
// Look for #fff
- if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
- return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
+ if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) {
+ return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
+ }
// Look for rgba(0, 0, 0, 0) == transparent in Safari 3
- if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
- return colors["transparent"];
+ if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) {
+ return colors.transparent;
+ }
// Otherwise, we're most likely dealing with a named color
return colors[$.trim(color).toLowerCase()];
@@ -80,14 +89,15 @@ function getColor(elem, attr) {
color = $.css(elem, attr);
// Keep going until we find an element that has color, or we hit the body
- if ( color != "" && color !== "transparent" || $.nodeName(elem, "body") )
- break;
+ if ( color && color !== "transparent" || $.nodeName(elem, "body") ) {
+ break;
+ }
attr = "backgroundColor";
} while ( elem = elem.parentNode );
return getRGB(color);
-};
+}
// Some named colors to work with
// From Interface by Stefan Petre
@@ -140,11 +150,12 @@ var colors = {
transparent: [255,255,255]
};
-
+})();
/******************************************************************************/
/****************************** CLASS ANIMATIONS ******************************/
/******************************************************************************/
+(function() {
var classAnimationActions = [ "add", "remove", "toggle" ],
shorthandStyles = {
@@ -157,9 +168,7 @@ var classAnimationActions = [ "add", "remove", "toggle" ],
borderWidth: 1,
margin: 1,
padding: 1
- },
- // prefix used for storing data on .data()
- dataSpace = "ui-effects-";
+ };
$.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
$.fx.step[ prop ] = function( fx ) {
@@ -171,9 +180,9 @@ $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopS
});
function getElementStyles() {
- var style = this.ownerDocument.defaultView
- ? this.ownerDocument.defaultView.getComputedStyle( this, null )
- : this.currentStyle,
+ var style = this.ownerDocument.defaultView ?
+ this.ownerDocument.defaultView.getComputedStyle( this, null ) :
+ this.currentStyle,
newStyle = {},
key,
camelCase,
@@ -206,7 +215,7 @@ function styleDifference( oldStyle, newStyle ) {
for ( name in newStyle ) {
value = newStyle[ name ];
- if ( oldStyle[ name ] != value ) {
+ if ( oldStyle[ name ] !== value ) {
if ( !shorthandStyles[ name ] ) {
if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
diff[ name ] = value;
@@ -332,12 +341,14 @@ $.fn.extend({
}
});
-
+})();
/******************************************************************************/
/*********************************** EFFECTS **********************************/
/******************************************************************************/
+(function() {
+
$.extend( $.effects, {
version: "@VERSION",
@@ -375,13 +386,13 @@ $.extend( $.effects, {
case "middle": y = 0.5; break;
case "bottom": y = 1; break;
default: y = origin[ 0 ] / original.height;
- };
+ }
switch ( origin[ 1 ] ) {
case "left": x = 0; break;
case "center": x = 0.5; break;
case "right": x = 1; break;
default: x = origin[ 1 ] / original.width;
- };
+ }
return {
x: x,
y: y
@@ -473,9 +484,11 @@ $.extend( $.effects, {
setTransition: function( element, list, factor, value ) {
value = value || {};
- $.each( list, function(i, x){
+ $.each( list, function( i, x ) {
var unit = element.cssUnit( x );
- if ( unit[ 0 ] > 0 ) value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
+ if ( unit[ 0 ] > 0 ) {
+ value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
+ }
});
return value;
}
@@ -484,9 +497,10 @@ $.extend( $.effects, {
// return an effect options object for the given parameters:
function _normalizeArguments( effect, options, speed, callback ) {
- // short path for passing an effect options object:
+ // allow passing all optinos as the first parameter
if ( $.isPlainObject( effect ) ) {
- return effect;
+ options = effect;
+ effect = effect.effect;
}
// convert to an object
@@ -505,7 +519,7 @@ function _normalizeArguments( effect, options, speed, callback ) {
}
// catch (effect, speed, ?)
- if ( $.type( options ) === "number" || $.fx.speeds[ options ]) {
+ if ( typeof options === "number" || $.fx.speeds[ options ] ) {
callback = speed;
speed = options;
options = {};
@@ -523,8 +537,10 @@ function _normalizeArguments( effect, options, speed, callback ) {
}
speed = speed || options.duration;
- effect.duration = $.fx.off ? 0 : typeof speed === "number"
- ? speed : speed in $.fx.speeds ? $.fx.speeds[ speed ] : $.fx.speeds._default;
+ effect.duration = $.fx.off ? 0 :
+ typeof speed === "number" ? speed :
+ speed in $.fx.speeds ? $.fx.speeds[ speed ] :
+ $.fx.speeds._default;
effect.complete = callback || options.complete;
@@ -649,19 +665,22 @@ $.fn.extend({
val = [];
$.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
- if ( style.indexOf( unit ) > 0 )
+ if ( style.indexOf( unit ) > 0 ) {
val = [ parseFloat( style ), unit ];
+ }
});
return val;
}
});
-
+})();
/******************************************************************************/
/*********************************** EASING ***********************************/
/******************************************************************************/
+(function() {
+
// based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
var baseEasings = {};
@@ -701,10 +720,12 @@ $.each( baseEasings, function( name, easeIn ) {
return 1 - easeIn( 1 - p );
};
$.easing[ "easeInOut" + name ] = function( p ) {
- return p < .5 ?
+ return p < 0.5 ?
easeIn( p * 2 ) / 2 :
easeIn( p * -2 + 2 ) / -2 + 1;
};
});
-})(jQuery);
+})();
+
+})(jQuery));