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