UPDATE 4.4.0.0
[phpmyadmin.git] / js / jquery / src / jquery-ui / effect.js
bloba601c1e01376472aa3018b9ad168f1f5105eba19
1 /*!
2  * jQuery UI Effects 1.11.2
3  * http://jqueryui.com
4  *
5  * Copyright 2014 jQuery Foundation and other contributors
6  * Released under the MIT license.
7  * http://jquery.org/license
8  *
9  * http://api.jqueryui.com/category/effects-core/
10  */
11 (function( factory ) {
12         if ( typeof define === "function" && define.amd ) {
14                 // AMD. Register as an anonymous module.
15                 define( [ "jquery" ], factory );
16         } else {
18                 // Browser globals
19                 factory( jQuery );
20         }
21 }(function( $ ) {
23 var dataSpace = "ui-effects-",
25         // Create a local jQuery because jQuery Color relies on it and the
26         // global may not exist with AMD and a custom build (#10199)
27         jQuery = $;
29 $.effects = {
30         effect: {}
33 /*!
34  * jQuery Color Animations v2.1.2
35  * https://github.com/jquery/jquery-color
36  *
37  * Copyright 2014 jQuery Foundation and other contributors
38  * Released under the MIT license.
39  * http://jquery.org/license
40  *
41  * Date: Wed Jan 16 08:47:09 2013 -0600
42  */
43 (function( jQuery, undefined ) {
45         var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
47         // plusequals test for += 100 -= 100
48         rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
49         // a set of RE's that can match strings and generate color tuples.
50         stringParsers = [ {
51                         re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
52                         parse: function( execResult ) {
53                                 return [
54                                         execResult[ 1 ],
55                                         execResult[ 2 ],
56                                         execResult[ 3 ],
57                                         execResult[ 4 ]
58                                 ];
59                         }
60                 }, {
61                         re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
62                         parse: function( execResult ) {
63                                 return [
64                                         execResult[ 1 ] * 2.55,
65                                         execResult[ 2 ] * 2.55,
66                                         execResult[ 3 ] * 2.55,
67                                         execResult[ 4 ]
68                                 ];
69                         }
70                 }, {
71                         // this regex ignores A-F because it's compared against an already lowercased string
72                         re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
73                         parse: function( execResult ) {
74                                 return [
75                                         parseInt( execResult[ 1 ], 16 ),
76                                         parseInt( execResult[ 2 ], 16 ),
77                                         parseInt( execResult[ 3 ], 16 )
78                                 ];
79                         }
80                 }, {
81                         // this regex ignores A-F because it's compared against an already lowercased string
82                         re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
83                         parse: function( execResult ) {
84                                 return [
85                                         parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
86                                         parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
87                                         parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
88                                 ];
89                         }
90                 }, {
91                         re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
92                         space: "hsla",
93                         parse: function( execResult ) {
94                                 return [
95                                         execResult[ 1 ],
96                                         execResult[ 2 ] / 100,
97                                         execResult[ 3 ] / 100,
98                                         execResult[ 4 ]
99                                 ];
100                         }
101                 } ],
103         // jQuery.Color( )
104         color = jQuery.Color = function( color, green, blue, alpha ) {
105                 return new jQuery.Color.fn.parse( color, green, blue, alpha );
106         },
107         spaces = {
108                 rgba: {
109                         props: {
110                                 red: {
111                                         idx: 0,
112                                         type: "byte"
113                                 },
114                                 green: {
115                                         idx: 1,
116                                         type: "byte"
117                                 },
118                                 blue: {
119                                         idx: 2,
120                                         type: "byte"
121                                 }
122                         }
123                 },
125                 hsla: {
126                         props: {
127                                 hue: {
128                                         idx: 0,
129                                         type: "degrees"
130                                 },
131                                 saturation: {
132                                         idx: 1,
133                                         type: "percent"
134                                 },
135                                 lightness: {
136                                         idx: 2,
137                                         type: "percent"
138                                 }
139                         }
140                 }
141         },
142         propTypes = {
143                 "byte": {
144                         floor: true,
145                         max: 255
146                 },
147                 "percent": {
148                         max: 1
149                 },
150                 "degrees": {
151                         mod: 360,
152                         floor: true
153                 }
154         },
155         support = color.support = {},
157         // element for support tests
158         supportElem = jQuery( "<p>" )[ 0 ],
160         // colors = jQuery.Color.names
161         colors,
163         // local aliases of functions called often
164         each = jQuery.each;
166 // determine rgba support immediately
167 supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
168 support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
170 // define cache name and alpha properties
171 // for rgba and hsla spaces
172 each( spaces, function( spaceName, space ) {
173         space.cache = "_" + spaceName;
174         space.props.alpha = {
175                 idx: 3,
176                 type: "percent",
177                 def: 1
178         };
181 function clamp( value, prop, allowEmpty ) {
182         var type = propTypes[ prop.type ] || {};
184         if ( value == null ) {
185                 return (allowEmpty || !prop.def) ? null : prop.def;
186         }
188         // ~~ is an short way of doing floor for positive numbers
189         value = type.floor ? ~~value : parseFloat( value );
191         // IE will pass in empty strings as value for alpha,
192         // which will hit this case
193         if ( isNaN( value ) ) {
194                 return prop.def;
195         }
197         if ( type.mod ) {
198                 // we add mod before modding to make sure that negatives values
199                 // get converted properly: -10 -> 350
200                 return (value + type.mod) % type.mod;
201         }
203         // for now all property types without mod have min and max
204         return 0 > value ? 0 : type.max < value ? type.max : value;
207 function stringParse( string ) {
208         var inst = color(),
209                 rgba = inst._rgba = [];
211         string = string.toLowerCase();
213         each( stringParsers, function( i, parser ) {
214                 var parsed,
215                         match = parser.re.exec( string ),
216                         values = match && parser.parse( match ),
217                         spaceName = parser.space || "rgba";
219                 if ( values ) {
220                         parsed = inst[ spaceName ]( values );
222                         // if this was an rgba parse the assignment might happen twice
223                         // oh well....
224                         inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
225                         rgba = inst._rgba = parsed._rgba;
227                         // exit each( stringParsers ) here because we matched
228                         return false;
229                 }
230         });
232         // Found a stringParser that handled it
233         if ( rgba.length ) {
235                 // if this came from a parsed string, force "transparent" when alpha is 0
236                 // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
237                 if ( rgba.join() === "0,0,0,0" ) {
238                         jQuery.extend( rgba, colors.transparent );
239                 }
240                 return inst;
241         }
243         // named colors
244         return colors[ string ];
247 color.fn = jQuery.extend( color.prototype, {
248         parse: function( red, green, blue, alpha ) {
249                 if ( red === undefined ) {
250                         this._rgba = [ null, null, null, null ];
251                         return this;
252                 }
253                 if ( red.jquery || red.nodeType ) {
254                         red = jQuery( red ).css( green );
255                         green = undefined;
256                 }
258                 var inst = this,
259                         type = jQuery.type( red ),
260                         rgba = this._rgba = [];
262                 // more than 1 argument specified - assume ( red, green, blue, alpha )
263                 if ( green !== undefined ) {
264                         red = [ red, green, blue, alpha ];
265                         type = "array";
266                 }
268                 if ( type === "string" ) {
269                         return this.parse( stringParse( red ) || colors._default );
270                 }
272                 if ( type === "array" ) {
273                         each( spaces.rgba.props, function( key, prop ) {
274                                 rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
275                         });
276                         return this;
277                 }
279                 if ( type === "object" ) {
280                         if ( red instanceof color ) {
281                                 each( spaces, function( spaceName, space ) {
282                                         if ( red[ space.cache ] ) {
283                                                 inst[ space.cache ] = red[ space.cache ].slice();
284                                         }
285                                 });
286                         } else {
287                                 each( spaces, function( spaceName, space ) {
288                                         var cache = space.cache;
289                                         each( space.props, function( key, prop ) {
291                                                 // if the cache doesn't exist, and we know how to convert
292                                                 if ( !inst[ cache ] && space.to ) {
294                                                         // if the value was null, we don't need to copy it
295                                                         // if the key was alpha, we don't need to copy it either
296                                                         if ( key === "alpha" || red[ key ] == null ) {
297                                                                 return;
298                                                         }
299                                                         inst[ cache ] = space.to( inst._rgba );
300                                                 }
302                                                 // this is the only case where we allow nulls for ALL properties.
303                                                 // call clamp with alwaysAllowEmpty
304                                                 inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
305                                         });
307                                         // everything defined but alpha?
308                                         if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
309                                                 // use the default of 1
310                                                 inst[ cache ][ 3 ] = 1;
311                                                 if ( space.from ) {
312                                                         inst._rgba = space.from( inst[ cache ] );
313                                                 }
314                                         }
315                                 });
316                         }
317                         return this;
318                 }
319         },
320         is: function( compare ) {
321                 var is = color( compare ),
322                         same = true,
323                         inst = this;
325                 each( spaces, function( _, space ) {
326                         var localCache,
327                                 isCache = is[ space.cache ];
328                         if (isCache) {
329                                 localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
330                                 each( space.props, function( _, prop ) {
331                                         if ( isCache[ prop.idx ] != null ) {
332                                                 same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
333                                                 return same;
334                                         }
335                                 });
336                         }
337                         return same;
338                 });
339                 return same;
340         },
341         _space: function() {
342                 var used = [],
343                         inst = this;
344                 each( spaces, function( spaceName, space ) {
345                         if ( inst[ space.cache ] ) {
346                                 used.push( spaceName );
347                         }
348                 });
349                 return used.pop();
350         },
351         transition: function( other, distance ) {
352                 var end = color( other ),
353                         spaceName = end._space(),
354                         space = spaces[ spaceName ],
355                         startColor = this.alpha() === 0 ? color( "transparent" ) : this,
356                         start = startColor[ space.cache ] || space.to( startColor._rgba ),
357                         result = start.slice();
359                 end = end[ space.cache ];
360                 each( space.props, function( key, prop ) {
361                         var index = prop.idx,
362                                 startValue = start[ index ],
363                                 endValue = end[ index ],
364                                 type = propTypes[ prop.type ] || {};
366                         // if null, don't override start value
367                         if ( endValue === null ) {
368                                 return;
369                         }
370                         // if null - use end
371                         if ( startValue === null ) {
372                                 result[ index ] = endValue;
373                         } else {
374                                 if ( type.mod ) {
375                                         if ( endValue - startValue > type.mod / 2 ) {
376                                                 startValue += type.mod;
377                                         } else if ( startValue - endValue > type.mod / 2 ) {
378                                                 startValue -= type.mod;
379                                         }
380                                 }
381                                 result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
382                         }
383                 });
384                 return this[ spaceName ]( result );
385         },
386         blend: function( opaque ) {
387                 // if we are already opaque - return ourself
388                 if ( this._rgba[ 3 ] === 1 ) {
389                         return this;
390                 }
392                 var rgb = this._rgba.slice(),
393                         a = rgb.pop(),
394                         blend = color( opaque )._rgba;
396                 return color( jQuery.map( rgb, function( v, i ) {
397                         return ( 1 - a ) * blend[ i ] + a * v;
398                 }));
399         },
400         toRgbaString: function() {
401                 var prefix = "rgba(",
402                         rgba = jQuery.map( this._rgba, function( v, i ) {
403                                 return v == null ? ( i > 2 ? 1 : 0 ) : v;
404                         });
406                 if ( rgba[ 3 ] === 1 ) {
407                         rgba.pop();
408                         prefix = "rgb(";
409                 }
411                 return prefix + rgba.join() + ")";
412         },
413         toHslaString: function() {
414                 var prefix = "hsla(",
415                         hsla = jQuery.map( this.hsla(), function( v, i ) {
416                                 if ( v == null ) {
417                                         v = i > 2 ? 1 : 0;
418                                 }
420                                 // catch 1 and 2
421                                 if ( i && i < 3 ) {
422                                         v = Math.round( v * 100 ) + "%";
423                                 }
424                                 return v;
425                         });
427                 if ( hsla[ 3 ] === 1 ) {
428                         hsla.pop();
429                         prefix = "hsl(";
430                 }
431                 return prefix + hsla.join() + ")";
432         },
433         toHexString: function( includeAlpha ) {
434                 var rgba = this._rgba.slice(),
435                         alpha = rgba.pop();
437                 if ( includeAlpha ) {
438                         rgba.push( ~~( alpha * 255 ) );
439                 }
441                 return "#" + jQuery.map( rgba, function( v ) {
443                         // default to 0 when nulls exist
444                         v = ( v || 0 ).toString( 16 );
445                         return v.length === 1 ? "0" + v : v;
446                 }).join("");
447         },
448         toString: function() {
449                 return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
450         }
452 color.fn.parse.prototype = color.fn;
454 // hsla conversions adapted from:
455 // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
457 function hue2rgb( p, q, h ) {
458         h = ( h + 1 ) % 1;
459         if ( h * 6 < 1 ) {
460                 return p + ( q - p ) * h * 6;
461         }
462         if ( h * 2 < 1) {
463                 return q;
464         }
465         if ( h * 3 < 2 ) {
466                 return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
467         }
468         return p;
471 spaces.hsla.to = function( rgba ) {
472         if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
473                 return [ null, null, null, rgba[ 3 ] ];
474         }
475         var r = rgba[ 0 ] / 255,
476                 g = rgba[ 1 ] / 255,
477                 b = rgba[ 2 ] / 255,
478                 a = rgba[ 3 ],
479                 max = Math.max( r, g, b ),
480                 min = Math.min( r, g, b ),
481                 diff = max - min,
482                 add = max + min,
483                 l = add * 0.5,
484                 h, s;
486         if ( min === max ) {
487                 h = 0;
488         } else if ( r === max ) {
489                 h = ( 60 * ( g - b ) / diff ) + 360;
490         } else if ( g === max ) {
491                 h = ( 60 * ( b - r ) / diff ) + 120;
492         } else {
493                 h = ( 60 * ( r - g ) / diff ) + 240;
494         }
496         // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
497         // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
498         if ( diff === 0 ) {
499                 s = 0;
500         } else if ( l <= 0.5 ) {
501                 s = diff / add;
502         } else {
503                 s = diff / ( 2 - add );
504         }
505         return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
508 spaces.hsla.from = function( hsla ) {
509         if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
510                 return [ null, null, null, hsla[ 3 ] ];
511         }
512         var h = hsla[ 0 ] / 360,
513                 s = hsla[ 1 ],
514                 l = hsla[ 2 ],
515                 a = hsla[ 3 ],
516                 q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
517                 p = 2 * l - q;
519         return [
520                 Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
521                 Math.round( hue2rgb( p, q, h ) * 255 ),
522                 Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
523                 a
524         ];
527 each( spaces, function( spaceName, space ) {
528         var props = space.props,
529                 cache = space.cache,
530                 to = space.to,
531                 from = space.from;
533         // makes rgba() and hsla()
534         color.fn[ spaceName ] = function( value ) {
536                 // generate a cache for this space if it doesn't exist
537                 if ( to && !this[ cache ] ) {
538                         this[ cache ] = to( this._rgba );
539                 }
540                 if ( value === undefined ) {
541                         return this[ cache ].slice();
542                 }
544                 var ret,
545                         type = jQuery.type( value ),
546                         arr = ( type === "array" || type === "object" ) ? value : arguments,
547                         local = this[ cache ].slice();
549                 each( props, function( key, prop ) {
550                         var val = arr[ type === "object" ? key : prop.idx ];
551                         if ( val == null ) {
552                                 val = local[ prop.idx ];
553                         }
554                         local[ prop.idx ] = clamp( val, prop );
555                 });
557                 if ( from ) {
558                         ret = color( from( local ) );
559                         ret[ cache ] = local;
560                         return ret;
561                 } else {
562                         return color( local );
563                 }
564         };
566         // makes red() green() blue() alpha() hue() saturation() lightness()
567         each( props, function( key, prop ) {
568                 // alpha is included in more than one space
569                 if ( color.fn[ key ] ) {
570                         return;
571                 }
572                 color.fn[ key ] = function( value ) {
573                         var vtype = jQuery.type( value ),
574                                 fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
575                                 local = this[ fn ](),
576                                 cur = local[ prop.idx ],
577                                 match;
579                         if ( vtype === "undefined" ) {
580                                 return cur;
581                         }
583                         if ( vtype === "function" ) {
584                                 value = value.call( this, cur );
585                                 vtype = jQuery.type( value );
586                         }
587                         if ( value == null && prop.empty ) {
588                                 return this;
589                         }
590                         if ( vtype === "string" ) {
591                                 match = rplusequals.exec( value );
592                                 if ( match ) {
593                                         value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
594                                 }
595                         }
596                         local[ prop.idx ] = value;
597                         return this[ fn ]( local );
598                 };
599         });
602 // add cssHook and .fx.step function for each named hook.
603 // accept a space separated string of properties
604 color.hook = function( hook ) {
605         var hooks = hook.split( " " );
606         each( hooks, function( i, hook ) {
607                 jQuery.cssHooks[ hook ] = {
608                         set: function( elem, value ) {
609                                 var parsed, curElem,
610                                         backgroundColor = "";
612                                 if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
613                                         value = color( parsed || value );
614                                         if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
615                                                 curElem = hook === "backgroundColor" ? elem.parentNode : elem;
616                                                 while (
617                                                         (backgroundColor === "" || backgroundColor === "transparent") &&
618                                                         curElem && curElem.style
619                                                 ) {
620                                                         try {
621                                                                 backgroundColor = jQuery.css( curElem, "backgroundColor" );
622                                                                 curElem = curElem.parentNode;
623                                                         } catch ( e ) {
624                                                         }
625                                                 }
627                                                 value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
628                                                         backgroundColor :
629                                                         "_default" );
630                                         }
632                                         value = value.toRgbaString();
633                                 }
634                                 try {
635                                         elem.style[ hook ] = value;
636                                 } catch ( e ) {
637                                         // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
638                                 }
639                         }
640                 };
641                 jQuery.fx.step[ hook ] = function( fx ) {
642                         if ( !fx.colorInit ) {
643                                 fx.start = color( fx.elem, hook );
644                                 fx.end = color( fx.end );
645                                 fx.colorInit = true;
646                         }
647                         jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
648                 };
649         });
653 color.hook( stepHooks );
655 jQuery.cssHooks.borderColor = {
656         expand: function( value ) {
657                 var expanded = {};
659                 each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
660                         expanded[ "border" + part + "Color" ] = value;
661                 });
662                 return expanded;
663         }
666 // Basic color names only.
667 // Usage of any of the other color names requires adding yourself or including
668 // jquery.color.svg-names.js.
669 colors = jQuery.Color.names = {
670         // 4.1. Basic color keywords
671         aqua: "#00ffff",
672         black: "#000000",
673         blue: "#0000ff",
674         fuchsia: "#ff00ff",
675         gray: "#808080",
676         green: "#008000",
677         lime: "#00ff00",
678         maroon: "#800000",
679         navy: "#000080",
680         olive: "#808000",
681         purple: "#800080",
682         red: "#ff0000",
683         silver: "#c0c0c0",
684         teal: "#008080",
685         white: "#ffffff",
686         yellow: "#ffff00",
688         // 4.2.3. "transparent" color keyword
689         transparent: [ null, null, null, 0 ],
691         _default: "#ffffff"
694 })( jQuery );
696 /******************************************************************************/
697 /****************************** CLASS ANIMATIONS ******************************/
698 /******************************************************************************/
699 (function() {
701 var classAnimationActions = [ "add", "remove", "toggle" ],
702         shorthandStyles = {
703                 border: 1,
704                 borderBottom: 1,
705                 borderColor: 1,
706                 borderLeft: 1,
707                 borderRight: 1,
708                 borderTop: 1,
709                 borderWidth: 1,
710                 margin: 1,
711                 padding: 1
712         };
714 $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
715         $.fx.step[ prop ] = function( fx ) {
716                 if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
717                         jQuery.style( fx.elem, prop, fx.end );
718                         fx.setAttr = true;
719                 }
720         };
723 function getElementStyles( elem ) {
724         var key, len,
725                 style = elem.ownerDocument.defaultView ?
726                         elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
727                         elem.currentStyle,
728                 styles = {};
730         if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
731                 len = style.length;
732                 while ( len-- ) {
733                         key = style[ len ];
734                         if ( typeof style[ key ] === "string" ) {
735                                 styles[ $.camelCase( key ) ] = style[ key ];
736                         }
737                 }
738         // support: Opera, IE <9
739         } else {
740                 for ( key in style ) {
741                         if ( typeof style[ key ] === "string" ) {
742                                 styles[ key ] = style[ key ];
743                         }
744                 }
745         }
747         return styles;
750 function styleDifference( oldStyle, newStyle ) {
751         var diff = {},
752                 name, value;
754         for ( name in newStyle ) {
755                 value = newStyle[ name ];
756                 if ( oldStyle[ name ] !== value ) {
757                         if ( !shorthandStyles[ name ] ) {
758                                 if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
759                                         diff[ name ] = value;
760                                 }
761                         }
762                 }
763         }
765         return diff;
768 // support: jQuery <1.8
769 if ( !$.fn.addBack ) {
770         $.fn.addBack = function( selector ) {
771                 return this.add( selector == null ?
772                         this.prevObject : this.prevObject.filter( selector )
773                 );
774         };
777 $.effects.animateClass = function( value, duration, easing, callback ) {
778         var o = $.speed( duration, easing, callback );
780         return this.queue( function() {
781                 var animated = $( this ),
782                         baseClass = animated.attr( "class" ) || "",
783                         applyClassChange,
784                         allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
786                 // map the animated objects to store the original styles.
787                 allAnimations = allAnimations.map(function() {
788                         var el = $( this );
789                         return {
790                                 el: el,
791                                 start: getElementStyles( this )
792                         };
793                 });
795                 // apply class change
796                 applyClassChange = function() {
797                         $.each( classAnimationActions, function(i, action) {
798                                 if ( value[ action ] ) {
799                                         animated[ action + "Class" ]( value[ action ] );
800                                 }
801                         });
802                 };
803                 applyClassChange();
805                 // map all animated objects again - calculate new styles and diff
806                 allAnimations = allAnimations.map(function() {
807                         this.end = getElementStyles( this.el[ 0 ] );
808                         this.diff = styleDifference( this.start, this.end );
809                         return this;
810                 });
812                 // apply original class
813                 animated.attr( "class", baseClass );
815                 // map all animated objects again - this time collecting a promise
816                 allAnimations = allAnimations.map(function() {
817                         var styleInfo = this,
818                                 dfd = $.Deferred(),
819                                 opts = $.extend({}, o, {
820                                         queue: false,
821                                         complete: function() {
822                                                 dfd.resolve( styleInfo );
823                                         }
824                                 });
826                         this.el.animate( this.diff, opts );
827                         return dfd.promise();
828                 });
830                 // once all animations have completed:
831                 $.when.apply( $, allAnimations.get() ).done(function() {
833                         // set the final class
834                         applyClassChange();
836                         // for each animated element,
837                         // clear all css properties that were animated
838                         $.each( arguments, function() {
839                                 var el = this.el;
840                                 $.each( this.diff, function(key) {
841                                         el.css( key, "" );
842                                 });
843                         });
845                         // this is guarnteed to be there if you use jQuery.speed()
846                         // it also handles dequeuing the next anim...
847                         o.complete.call( animated[ 0 ] );
848                 });
849         });
852 $.fn.extend({
853         addClass: (function( orig ) {
854                 return function( classNames, speed, easing, callback ) {
855                         return speed ?
856                                 $.effects.animateClass.call( this,
857                                         { add: classNames }, speed, easing, callback ) :
858                                 orig.apply( this, arguments );
859                 };
860         })( $.fn.addClass ),
862         removeClass: (function( orig ) {
863                 return function( classNames, speed, easing, callback ) {
864                         return arguments.length > 1 ?
865                                 $.effects.animateClass.call( this,
866                                         { remove: classNames }, speed, easing, callback ) :
867                                 orig.apply( this, arguments );
868                 };
869         })( $.fn.removeClass ),
871         toggleClass: (function( orig ) {
872                 return function( classNames, force, speed, easing, callback ) {
873                         if ( typeof force === "boolean" || force === undefined ) {
874                                 if ( !speed ) {
875                                         // without speed parameter
876                                         return orig.apply( this, arguments );
877                                 } else {
878                                         return $.effects.animateClass.call( this,
879                                                 (force ? { add: classNames } : { remove: classNames }),
880                                                 speed, easing, callback );
881                                 }
882                         } else {
883                                 // without force parameter
884                                 return $.effects.animateClass.call( this,
885                                         { toggle: classNames }, force, speed, easing );
886                         }
887                 };
888         })( $.fn.toggleClass ),
890         switchClass: function( remove, add, speed, easing, callback) {
891                 return $.effects.animateClass.call( this, {
892                         add: add,
893                         remove: remove
894                 }, speed, easing, callback );
895         }
898 })();
900 /******************************************************************************/
901 /*********************************** EFFECTS **********************************/
902 /******************************************************************************/
904 (function() {
906 $.extend( $.effects, {
907         version: "1.11.2",
909         // Saves a set of properties in a data storage
910         save: function( element, set ) {
911                 for ( var i = 0; i < set.length; i++ ) {
912                         if ( set[ i ] !== null ) {
913                                 element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
914                         }
915                 }
916         },
918         // Restores a set of previously saved properties from a data storage
919         restore: function( element, set ) {
920                 var val, i;
921                 for ( i = 0; i < set.length; i++ ) {
922                         if ( set[ i ] !== null ) {
923                                 val = element.data( dataSpace + set[ i ] );
924                                 // support: jQuery 1.6.2
925                                 // http://bugs.jquery.com/ticket/9917
926                                 // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
927                                 // We can't differentiate between "" and 0 here, so we just assume
928                                 // empty string since it's likely to be a more common value...
929                                 if ( val === undefined ) {
930                                         val = "";
931                                 }
932                                 element.css( set[ i ], val );
933                         }
934                 }
935         },
937         setMode: function( el, mode ) {
938                 if (mode === "toggle") {
939                         mode = el.is( ":hidden" ) ? "show" : "hide";
940                 }
941                 return mode;
942         },
944         // Translates a [top,left] array into a baseline value
945         // this should be a little more flexible in the future to handle a string & hash
946         getBaseline: function( origin, original ) {
947                 var y, x;
948                 switch ( origin[ 0 ] ) {
949                         case "top": y = 0; break;
950                         case "middle": y = 0.5; break;
951                         case "bottom": y = 1; break;
952                         default: y = origin[ 0 ] / original.height;
953                 }
954                 switch ( origin[ 1 ] ) {
955                         case "left": x = 0; break;
956                         case "center": x = 0.5; break;
957                         case "right": x = 1; break;
958                         default: x = origin[ 1 ] / original.width;
959                 }
960                 return {
961                         x: x,
962                         y: y
963                 };
964         },
966         // Wraps the element around a wrapper that copies position properties
967         createWrapper: function( element ) {
969                 // if the element is already wrapped, return it
970                 if ( element.parent().is( ".ui-effects-wrapper" )) {
971                         return element.parent();
972                 }
974                 // wrap the element
975                 var props = {
976                                 width: element.outerWidth(true),
977                                 height: element.outerHeight(true),
978                                 "float": element.css( "float" )
979                         },
980                         wrapper = $( "<div></div>" )
981                                 .addClass( "ui-effects-wrapper" )
982                                 .css({
983                                         fontSize: "100%",
984                                         background: "transparent",
985                                         border: "none",
986                                         margin: 0,
987                                         padding: 0
988                                 }),
989                         // Store the size in case width/height are defined in % - Fixes #5245
990                         size = {
991                                 width: element.width(),
992                                 height: element.height()
993                         },
994                         active = document.activeElement;
996                 // support: Firefox
997                 // Firefox incorrectly exposes anonymous content
998                 // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
999                 try {
1000                         active.id;
1001                 } catch ( e ) {
1002                         active = document.body;
1003                 }
1005                 element.wrap( wrapper );
1007                 // Fixes #7595 - Elements lose focus when wrapped.
1008                 if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
1009                         $( active ).focus();
1010                 }
1012                 wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
1014                 // transfer positioning properties to the wrapper
1015                 if ( element.css( "position" ) === "static" ) {
1016                         wrapper.css({ position: "relative" });
1017                         element.css({ position: "relative" });
1018                 } else {
1019                         $.extend( props, {
1020                                 position: element.css( "position" ),
1021                                 zIndex: element.css( "z-index" )
1022                         });
1023                         $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
1024                                 props[ pos ] = element.css( pos );
1025                                 if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
1026                                         props[ pos ] = "auto";
1027                                 }
1028                         });
1029                         element.css({
1030                                 position: "relative",
1031                                 top: 0,
1032                                 left: 0,
1033                                 right: "auto",
1034                                 bottom: "auto"
1035                         });
1036                 }
1037                 element.css(size);
1039                 return wrapper.css( props ).show();
1040         },
1042         removeWrapper: function( element ) {
1043                 var active = document.activeElement;
1045                 if ( element.parent().is( ".ui-effects-wrapper" ) ) {
1046                         element.parent().replaceWith( element );
1048                         // Fixes #7595 - Elements lose focus when wrapped.
1049                         if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
1050                                 $( active ).focus();
1051                         }
1052                 }
1054                 return element;
1055         },
1057         setTransition: function( element, list, factor, value ) {
1058                 value = value || {};
1059                 $.each( list, function( i, x ) {
1060                         var unit = element.cssUnit( x );
1061                         if ( unit[ 0 ] > 0 ) {
1062                                 value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
1063                         }
1064                 });
1065                 return value;
1066         }
1069 // return an effect options object for the given parameters:
1070 function _normalizeArguments( effect, options, speed, callback ) {
1072         // allow passing all options as the first parameter
1073         if ( $.isPlainObject( effect ) ) {
1074                 options = effect;
1075                 effect = effect.effect;
1076         }
1078         // convert to an object
1079         effect = { effect: effect };
1081         // catch (effect, null, ...)
1082         if ( options == null ) {
1083                 options = {};
1084         }
1086         // catch (effect, callback)
1087         if ( $.isFunction( options ) ) {
1088                 callback = options;
1089                 speed = null;
1090                 options = {};
1091         }
1093         // catch (effect, speed, ?)
1094         if ( typeof options === "number" || $.fx.speeds[ options ] ) {
1095                 callback = speed;
1096                 speed = options;
1097                 options = {};
1098         }
1100         // catch (effect, options, callback)
1101         if ( $.isFunction( speed ) ) {
1102                 callback = speed;
1103                 speed = null;
1104         }
1106         // add options to effect
1107         if ( options ) {
1108                 $.extend( effect, options );
1109         }
1111         speed = speed || options.duration;
1112         effect.duration = $.fx.off ? 0 :
1113                 typeof speed === "number" ? speed :
1114                 speed in $.fx.speeds ? $.fx.speeds[ speed ] :
1115                 $.fx.speeds._default;
1117         effect.complete = callback || options.complete;
1119         return effect;
1122 function standardAnimationOption( option ) {
1123         // Valid standard speeds (nothing, number, named speed)
1124         if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
1125                 return true;
1126         }
1128         // Invalid strings - treat as "normal" speed
1129         if ( typeof option === "string" && !$.effects.effect[ option ] ) {
1130                 return true;
1131         }
1133         // Complete callback
1134         if ( $.isFunction( option ) ) {
1135                 return true;
1136         }
1138         // Options hash (but not naming an effect)
1139         if ( typeof option === "object" && !option.effect ) {
1140                 return true;
1141         }
1143         // Didn't match any standard API
1144         return false;
1147 $.fn.extend({
1148         effect: function( /* effect, options, speed, callback */ ) {
1149                 var args = _normalizeArguments.apply( this, arguments ),
1150                         mode = args.mode,
1151                         queue = args.queue,
1152                         effectMethod = $.effects.effect[ args.effect ];
1154                 if ( $.fx.off || !effectMethod ) {
1155                         // delegate to the original method (e.g., .show()) if possible
1156                         if ( mode ) {
1157                                 return this[ mode ]( args.duration, args.complete );
1158                         } else {
1159                                 return this.each( function() {
1160                                         if ( args.complete ) {
1161                                                 args.complete.call( this );
1162                                         }
1163                                 });
1164                         }
1165                 }
1167                 function run( next ) {
1168                         var elem = $( this ),
1169                                 complete = args.complete,
1170                                 mode = args.mode;
1172                         function done() {
1173                                 if ( $.isFunction( complete ) ) {
1174                                         complete.call( elem[0] );
1175                                 }
1176                                 if ( $.isFunction( next ) ) {
1177                                         next();
1178                                 }
1179                         }
1181                         // If the element already has the correct final state, delegate to
1182                         // the core methods so the internal tracking of "olddisplay" works.
1183                         if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
1184                                 elem[ mode ]();
1185                                 done();
1186                         } else {
1187                                 effectMethod.call( elem[0], args, done );
1188                         }
1189                 }
1191                 return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
1192         },
1194         show: (function( orig ) {
1195                 return function( option ) {
1196                         if ( standardAnimationOption( option ) ) {
1197                                 return orig.apply( this, arguments );
1198                         } else {
1199                                 var args = _normalizeArguments.apply( this, arguments );
1200                                 args.mode = "show";
1201                                 return this.effect.call( this, args );
1202                         }
1203                 };
1204         })( $.fn.show ),
1206         hide: (function( orig ) {
1207                 return function( option ) {
1208                         if ( standardAnimationOption( option ) ) {
1209                                 return orig.apply( this, arguments );
1210                         } else {
1211                                 var args = _normalizeArguments.apply( this, arguments );
1212                                 args.mode = "hide";
1213                                 return this.effect.call( this, args );
1214                         }
1215                 };
1216         })( $.fn.hide ),
1218         toggle: (function( orig ) {
1219                 return function( option ) {
1220                         if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
1221                                 return orig.apply( this, arguments );
1222                         } else {
1223                                 var args = _normalizeArguments.apply( this, arguments );
1224                                 args.mode = "toggle";
1225                                 return this.effect.call( this, args );
1226                         }
1227                 };
1228         })( $.fn.toggle ),
1230         // helper functions
1231         cssUnit: function(key) {
1232                 var style = this.css( key ),
1233                         val = [];
1235                 $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
1236                         if ( style.indexOf( unit ) > 0 ) {
1237                                 val = [ parseFloat( style ), unit ];
1238                         }
1239                 });
1240                 return val;
1241         }
1244 })();
1246 /******************************************************************************/
1247 /*********************************** EASING ***********************************/
1248 /******************************************************************************/
1250 (function() {
1252 // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
1254 var baseEasings = {};
1256 $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
1257         baseEasings[ name ] = function( p ) {
1258                 return Math.pow( p, i + 2 );
1259         };
1262 $.extend( baseEasings, {
1263         Sine: function( p ) {
1264                 return 1 - Math.cos( p * Math.PI / 2 );
1265         },
1266         Circ: function( p ) {
1267                 return 1 - Math.sqrt( 1 - p * p );
1268         },
1269         Elastic: function( p ) {
1270                 return p === 0 || p === 1 ? p :
1271                         -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
1272         },
1273         Back: function( p ) {
1274                 return p * p * ( 3 * p - 2 );
1275         },
1276         Bounce: function( p ) {
1277                 var pow2,
1278                         bounce = 4;
1280                 while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
1281                 return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
1282         }
1285 $.each( baseEasings, function( name, easeIn ) {
1286         $.easing[ "easeIn" + name ] = easeIn;
1287         $.easing[ "easeOut" + name ] = function( p ) {
1288                 return 1 - easeIn( 1 - p );
1289         };
1290         $.easing[ "easeInOut" + name ] = function( p ) {
1291                 return p < 0.5 ?
1292                         easeIn( p * 2 ) / 2 :
1293                         1 - easeIn( p * -2 + 2 ) / 2;
1294         };
1297 })();
1299 return $.effects;
1301 }));