Project

General

Profile

1
/*
2
 * jQuery UI Effects Pulsate 1.8.6
3
 *
4
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
5
 * Dual licensed under the MIT or GPL Version 2 licenses.
6
 * http://jquery.org/license
7
 *
8
 * http://docs.jquery.com/UI/Effects/Pulsate
9
 *
10
 * Depends:
11
 *	jquery.effects.core.js
12
 */
13
(function( $, undefined ) {
14

    
15
$.effects.pulsate = function(o) {
16
	return this.queue(function() {
17
		var elem = $(this),
18
			mode = $.effects.setMode(elem, o.options.mode || 'show');
19
			times = ((o.options.times || 5) * 2) - 1;
20
			duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2,
21
			isVisible = elem.is(':visible'),
22
			animateTo = 0;
23

    
24
		if (!isVisible) {
25
			elem.css('opacity', 0).show();
26
			animateTo = 1;
27
		}
28

    
29
		if ((mode == 'hide' && isVisible) || (mode == 'show' && !isVisible)) {
30
			times--;
31
		}
32

    
33
		for (var i = 0; i < times; i++) {
34
			elem.animate({ opacity: animateTo }, duration, o.options.easing);
35
			animateTo = (animateTo + 1) % 2;
36
		}
37

    
38
		elem.animate({ opacity: animateTo }, duration, o.options.easing, function() {
39
			if (animateTo == 0) {
40
				elem.hide();
41
			}
42
			(o.callback && o.callback.apply(this, arguments));
43
		});
44

    
45
		elem
46
			.queue('fx', function() { elem.dequeue(); })
47
			.dequeue();
48
	});
49
};
50

    
51
})(jQuery);
(11-11/32)