commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / bower_components / jquery-ui / ui / effect-shake.js
1 /*!
2 * jQuery UI Effects Shake 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/shake-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.shake = function( o, done ) {
27
28 var el = $( this ),
29 props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
30 mode = $.effects.setMode( el, o.mode || "effect" ),
31 direction = o.direction || "left",
32 distance = o.distance || 20,
33 times = o.times || 3,
34 anims = times * 2 + 1,
35 speed = Math.round( o.duration / anims ),
36 ref = (direction === "up" || direction === "down") ? "top" : "left",
37 positiveMotion = (direction === "up" || direction === "left"),
38 animation = {},
39 animation1 = {},
40 animation2 = {},
41 i,
42
43 // we will need to re-assemble the queue to stack our animations in place
44 queue = el.queue(),
45 queuelen = queue.length;
46
47 $.effects.save( el, props );
48 el.show();
49 $.effects.createWrapper( el );
50
51 // Animation
52 animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
53 animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
54 animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
55
56 // Animate
57 el.animate( animation, speed, o.easing );
58
59 // Shakes
60 for ( i = 1; i < times; i++ ) {
61 el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
62 }
63 el
64 .animate( animation1, speed, o.easing )
65 .animate( animation, speed / 2, o.easing )
66 .queue(function() {
67 if ( mode === "hide" ) {
68 el.hide();
69 }
70 $.effects.restore( el, props );
71 $.effects.removeWrapper( el );
72 done();
73 });
74
75 // inject all the animations we just queued to be first in line (after "inprogress")
76 if ( queuelen > 1) {
77 queue.splice.apply( queue,
78 [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
79 }
80 el.dequeue();
81
82 };
83
84 }));