1 /** |
|
2 * Interface Elements for jQuery |
|
3 * FX - pulsate |
|
4 * |
|
5 * http://interface.eyecon.ro |
|
6 * |
|
7 * Copyright (c) 2006 Stefan Petre |
|
8 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
9 * and GPL (GPL-LICENSE.txt) licenses. |
|
10 * |
|
11 * |
|
12 */ |
|
13 |
|
14 /** |
|
15 * @name Bounce |
|
16 * @description makes the element to pulsate |
|
17 * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast'] |
|
18 * @param Integer times how many times to pulsate |
|
19 * @param Function callback (optional) A function to be executed whenever the animation completes. |
|
20 * @type jQuery |
|
21 * @cat Plugins/Interface |
|
22 * @author Stefan Petre |
|
23 */ |
|
24 jQuery.fn.Pulsate = function(speed, times, callback) { |
|
25 return this.queue('interfaceFX',function(){ |
|
26 if (!jQuery.fxCheckTag(this)) { |
|
27 jQuery.dequeue(this, 'interfaceFX'); |
|
28 return false; |
|
29 } |
|
30 var fx = new jQuery.fx.Pulsate(this, speed, times, callback); |
|
31 fx.pulse(); |
|
32 }); |
|
33 }; |
|
34 |
|
35 jQuery.fx.Pulsate = function (el, speed, times, callback) |
|
36 { |
|
37 var z = this; |
|
38 z.times = times; |
|
39 z.cnt = 1; |
|
40 z.el = el; |
|
41 z.speed = speed; |
|
42 z.callback = callback; |
|
43 jQuery(z.el).show(); |
|
44 z.pulse = function() |
|
45 { |
|
46 z.cnt ++; |
|
47 z.e = new jQuery.fx( |
|
48 z.el, |
|
49 jQuery.speed( |
|
50 z.speed, |
|
51 function(){ |
|
52 z.ef = new jQuery.fx( |
|
53 z.el, |
|
54 jQuery.speed( |
|
55 z.speed, |
|
56 function() |
|
57 { |
|
58 if (z.cnt <= z.times) |
|
59 z.pulse(); |
|
60 else { |
|
61 jQuery.dequeue(z.el, 'interfaceFX'); |
|
62 if (z.callback && z.callback.constructor == Function) { |
|
63 z.callback.apply(z.el); |
|
64 } |
|
65 } |
|
66 } |
|
67 ), |
|
68 'opacity' |
|
69 ); |
|
70 z.ef.custom(0,1); |
|
71 } |
|
72 ), |
|
73 'opacity' |
|
74 ); |
|
75 z.e.custom(1,0); |
|
76 }; |
|
77 }; |
|