| 1 |
/* |
| 2 |
* jQuery UI Effects Pulsate 1.7.2 |
| 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/Pulsate |
| 9 |
* |
| 10 |
* Depends: |
| 11 |
* effects.core.js |
| 12 |
*/ |
| 13 |
(function($) { |
| 14 |
|
| 15 |
$.effects.pulsate = function(o) { |
| 16 |
|
| 17 |
return this.queue(function() { |
| 18 |
|
| 19 |
// Create element |
| 20 |
var el = $(this); |
| 21 |
|
| 22 |
// Set options |
| 23 |
var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode |
| 24 |
var times = o.options.times || 5; // Default # of times |
| 25 |
var duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2; |
| 26 |
|
| 27 |
// Adjust |
| 28 |
if (mode == 'hide') times--; |
| 29 |
if (el.is(':hidden')) { // Show fadeIn |
| 30 |
el.css('opacity', 0); |
| 31 |
el.show(); // Show |
| 32 |
el.animate({opacity: 1}, duration, o.options.easing); |
| 33 |
times = times-2; |
| 34 |
} |
| 35 |
|
| 36 |
// Animate |
| 37 |
for (var i = 0; i < times; i++) { // Pulsate |
| 38 |
el.animate({opacity: 0}, duration, o.options.easing).animate({opacity: 1}, duration, o.options.easing); |
| 39 |
}; |
| 40 |
if (mode == 'hide') { // Last Pulse |
| 41 |
el.animate({opacity: 0}, duration, o.options.easing, function(){ |
| 42 |
el.hide(); // Hide |
| 43 |
if(o.callback) o.callback.apply(this, arguments); // Callback |
| 44 |
}); |
| 45 |
} else { |
| 46 |
el.animate({opacity: 0}, duration, o.options.easing).animate({opacity: 1}, duration, o.options.easing, function(){ |
| 47 |
if(o.callback) o.callback.apply(this, arguments); // Callback |
| 48 |
}); |
| 49 |
}; |
| 50 |
el.queue('fx', function() { el.dequeue(); }); |
| 51 |
el.dequeue(); |
| 52 |
}); |
| 53 |
|
| 54 |
}; |
| 55 |
|
| 56 |
})(jQuery); |
| 57 |
|