Return correct values and types
[mediawiki.git] / resources / jquery.effects / jquery.effects.pulsate.js
blobd730beedf5bc50f61ddedca392da267ee46bd6f8
1 /*!
2  * jQuery UI Effects Pulsate 1.8.24
3  *
4  * Copyright 2012, 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 ) {
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;
24                 if (!isVisible) {
25                         elem.css('opacity', 0).show();
26                         animateTo = 1;
27                 }
29                 if ((mode == 'hide' && isVisible) || (mode == 'show' && !isVisible)) {
30                         times--;
31                 }
33                 for (var i = 0; i < times; i++) {
34                         elem.animate({ opacity: animateTo }, duration, o.options.easing);
35                         animateTo = (animateTo + 1) % 2;
36                 }
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                 });
45                 elem
46                         .queue('fx', function() { elem.dequeue(); })
47                         .dequeue();
48         });
51 })(jQuery);