2008-06-06 20:08:52 +00:00
|
|
|
/*
|
2008-09-04 22:03:30 +00:00
|
|
|
* jQuery UI Effects Pulsate @VERSION
|
2008-06-06 20:08:52 +00:00
|
|
|
*
|
2011-01-17 14:13:18 +00:00
|
|
|
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
2010-07-09 13:01:04 +00:00
|
|
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
|
|
* http://jquery.org/license
|
2008-11-20 04:10:34 +00:00
|
|
|
*
|
2008-06-06 20:08:52 +00:00
|
|
|
* http://docs.jquery.com/UI/Effects/Pulsate
|
|
|
|
*
|
|
|
|
* Depends:
|
2009-09-17 10:39:12 +00:00
|
|
|
* jquery.effects.core.js
|
2008-06-06 20:08:52 +00:00
|
|
|
*/
|
2010-07-13 13:57:58 +00:00
|
|
|
(function( $, undefined ) {
|
2008-06-04 02:34:33 +00:00
|
|
|
|
2011-03-15 13:00:45 +00:00
|
|
|
$.effects.effect.pulsate = function( o ) {
|
2011-05-01 08:44:33 +00:00
|
|
|
return this.queue( function( next ) {
|
2011-03-06 23:45:43 +00:00
|
|
|
var elem = $( this ),
|
2011-05-03 12:22:34 +00:00
|
|
|
mode = $.effects.setMode( elem, o.mode || "effect" ),
|
|
|
|
show = mode === "show" || elem.is( ":hidden" ),
|
2011-05-01 08:44:33 +00:00
|
|
|
showhide = ( show || mode === "hide" ),
|
2011-03-27 11:30:40 +00:00
|
|
|
|
2011-05-03 15:48:00 +00:00
|
|
|
// showing or hiding adds an extra "half" animation
|
|
|
|
anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
|
2011-05-01 08:44:33 +00:00
|
|
|
duration = o.duration / anims,
|
2011-03-06 23:45:43 +00:00
|
|
|
animateTo = 0,
|
2011-03-27 11:30:40 +00:00
|
|
|
queue = elem.queue(),
|
2011-05-01 08:44:33 +00:00
|
|
|
queuelen = queue.length,
|
|
|
|
i;
|
2009-11-16 02:49:36 +00:00
|
|
|
|
2011-03-27 11:30:40 +00:00
|
|
|
if ( show ) {
|
2011-05-01 08:44:33 +00:00
|
|
|
elem.css( "opacity", 0 ).show();
|
2009-11-16 02:49:36 +00:00
|
|
|
animateTo = 1;
|
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2011-05-03 12:22:34 +00:00
|
|
|
// anims - 1 opacity "toggles"
|
|
|
|
for ( i = 1; i < anims; i++ ) {
|
2011-05-01 08:44:33 +00:00
|
|
|
elem.animate({
|
|
|
|
opacity: animateTo
|
2011-03-06 23:45:43 +00:00
|
|
|
}, duration, o.easing );
|
2011-03-27 11:30:40 +00:00
|
|
|
animateTo = 1 - animateTo;
|
2008-06-06 19:47:31 +00:00
|
|
|
}
|
2008-11-18 02:55:25 +00:00
|
|
|
|
2011-05-01 08:44:33 +00:00
|
|
|
elem.animate({
|
|
|
|
opacity: animateTo
|
2011-03-06 23:45:43 +00:00
|
|
|
}, duration, o.easing, function() {
|
2011-05-01 08:44:33 +00:00
|
|
|
if ( animateTo === 0 ) {
|
2009-11-16 02:49:36 +00:00
|
|
|
elem.hide();
|
|
|
|
}
|
2011-05-01 08:44:33 +00:00
|
|
|
if ( o.complete ) {
|
|
|
|
o.complete.apply( this );
|
|
|
|
}
|
2011-03-27 11:30:40 +00:00
|
|
|
});
|
|
|
|
|
2011-05-01 08:44:33 +00:00
|
|
|
// We just queued up "anims" animations, we need to put them next in the queue
|
2011-03-27 11:30:40 +00:00
|
|
|
if ( queuelen > 1) {
|
|
|
|
queue.splice.apply( queue,
|
2011-05-01 08:44:33 +00:00
|
|
|
[ 1, 0 ].concat( queue.splice( queuelen, anims ) ) );
|
2011-03-27 11:30:40 +00:00
|
|
|
}
|
2011-05-01 08:44:33 +00:00
|
|
|
next();
|
2009-11-16 02:49:36 +00:00
|
|
|
});
|
2008-06-06 19:47:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
})(jQuery);
|