~jstys-z/helioviewer.org/client5

« back to all changes in this revision

Viewing changes to lib/jquery/jquery.ui-1.7.1/development-bundle/ui/effects.shake.js

  • Committer: V. Keith Hughitt
  • Date: 2009-03-26 19:20:57 UTC
  • Revision ID: hughitt1@kore-20090326192057-u0x8rf8sf5lmmnwh
nightly build 03-26-2009: Using alpha-channel JPEG 2000 dataset

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * jQuery UI Effects Shake 1.7.1
 
3
 *
 
4
 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
 
5
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 
6
 * and GPL (GPL-LICENSE.txt) licenses.
 
7
 *
 
8
 * http://docs.jquery.com/UI/Effects/Shake
 
9
 *
 
10
 * Depends:
 
11
 *      effects.core.js
 
12
 */
 
13
(function($) {
 
14
 
 
15
$.effects.shake = function(o) {
 
16
 
 
17
        return this.queue(function() {
 
18
 
 
19
                // Create element
 
20
                var el = $(this), props = ['position','top','left'];
 
21
 
 
22
                // Set options
 
23
                var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
 
24
                var direction = o.options.direction || 'left'; // Default direction
 
25
                var distance = o.options.distance || 20; // Default distance
 
26
                var times = o.options.times || 3; // Default # of times
 
27
                var speed = o.duration || o.options.duration || 140; // Default speed per shake
 
28
 
 
29
                // Adjust
 
30
                $.effects.save(el, props); el.show(); // Save & Show
 
31
                $.effects.createWrapper(el); // Create Wrapper
 
32
                var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
 
33
                var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
 
34
 
 
35
                // Animation
 
36
                var animation = {}, animation1 = {}, animation2 = {};
 
37
                animation[ref] = (motion == 'pos' ? '-=' : '+=')  + distance;
 
38
                animation1[ref] = (motion == 'pos' ? '+=' : '-=')  + distance * 2;
 
39
                animation2[ref] = (motion == 'pos' ? '-=' : '+=')  + distance * 2;
 
40
 
 
41
                // Animate
 
42
                el.animate(animation, speed, o.options.easing);
 
43
                for (var i = 1; i < times; i++) { // Shakes
 
44
                        el.animate(animation1, speed, o.options.easing).animate(animation2, speed, o.options.easing);
 
45
                };
 
46
                el.animate(animation1, speed, o.options.easing).
 
47
                animate(animation, speed / 2, o.options.easing, function(){ // Last shake
 
48
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
 
49
                        if(o.callback) o.callback.apply(this, arguments); // Callback
 
50
                });
 
51
                el.queue('fx', function() { el.dequeue(); });
 
52
                el.dequeue();
 
53
        });
 
54
 
 
55
};
 
56
 
 
57
})(jQuery);