commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / bower_components / jquery-ui / ui / effect-bounce.js
1 /*!
2 * jQuery UI Effects Bounce 1.11.4
3 * http://jqueryui.com
4 *
5 * Copyright jQuery Foundation and other contributors
6 * Released under the MIT license.
7 * http://jquery.org/license
8 *
9 * http://api.jqueryui.com/bounce-effect/
10 */
11 (function( factory ) {
12 if ( typeof define === "function" && define.amd ) {
13
14 // AMD. Register as an anonymous module.
15 define([
16 "jquery",
17 "./effect"
18 ], factory );
19 } else {
20
21 // Browser globals
22 factory( jQuery );
23 }
24 }(function( $ ) {
25
26 return $.effects.effect.bounce = function( o, done ) {
27 var el = $( this ),
28 props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
29
30 // defaults:
31 mode = $.effects.setMode( el, o.mode || "effect" ),
32 hide = mode === "hide",
33 show = mode === "show",
34 direction = o.direction || "up",
35 distance = o.distance,
36 times = o.times || 5,
37
38 // number of internal animations
39 anims = times * 2 + ( show || hide ? 1 : 0 ),
40 speed = o.duration / anims,
41 easing = o.easing,
42
43 // utility:
44 ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
45 motion = ( direction === "up" || direction === "left" ),
46 i,
47 upAnim,
48 downAnim,
49
50 // we will need to re-assemble the queue to stack our animations in place
51 queue = el.queue(),
52 queuelen = queue.length;
53
54 // Avoid touching opacity to prevent clearType and PNG issues in IE
55 if ( show || hide ) {
56 props.push( "opacity" );
57 }
58
59 $.effects.save( el, props );
60 el.show();
61 $.effects.createWrapper( el ); // Create Wrapper
62
63 // default distance for the BIGGEST bounce is the outer Distance / 3
64 if ( !distance ) {
65 distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
66 }
67
68 if ( show ) {
69 downAnim = { opacity: 1 };
70 downAnim[ ref ] = 0;
71
72 // if we are showing, force opacity 0 and set the initial position
73 // then do the "first" animation
74 el.css( "opacity", 0 )
75 .css( ref, motion ? -distance * 2 : distance * 2 )
76 .animate( downAnim, speed, easing );
77 }
78
79 // start at the smallest distance if we are hiding
80 if ( hide ) {
81 distance = distance / Math.pow( 2, times - 1 );
82 }
83
84 downAnim = {};
85 downAnim[ ref ] = 0;
86 // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
87 for ( i = 0; i < times; i++ ) {
88 upAnim = {};
89 upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
90
91 el.animate( upAnim, speed, easing )
92 .animate( downAnim, speed, easing );
93
94 distance = hide ? distance * 2 : distance / 2;
95 }
96
97 // Last Bounce when Hiding
98 if ( hide ) {
99 upAnim = { opacity: 0 };
100 upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
101
102 el.animate( upAnim, speed, easing );
103 }
104
105 el.queue(function() {
106 if ( hide ) {
107 el.hide();
108 }
109 $.effects.restore( el, props );
110 $.effects.removeWrapper( el );
111 done();
112 });
113
114 // inject all the animations we just queued to be first in line (after "inprogress")
115 if ( queuelen > 1) {
116 queue.splice.apply( queue,
117 [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
118 }
119 el.dequeue();
120
121 };
122
123 }));