diff options
author | Felix Nagel <info@felixnagel.com> | 2012-07-12 23:57:55 +0200 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2012-07-12 23:57:55 +0200 |
commit | 5092d0296a010280ee9d004f2fe06afbf1c45db5 (patch) | |
tree | ac6b97b4551b4aebf8d90cc35add82fc7088e0a3 /ui/jquery.ui.effect-pulsate.js | |
parent | 39532f0a8e70e21e33aab03f08136f662d03a4a1 (diff) | |
parent | e054e28836e616ed03561d5a8195bbea525866d1 (diff) | |
download | jquery-ui-5092d0296a010280ee9d004f2fe06afbf1c45db5.tar.gz jquery-ui-5092d0296a010280ee9d004f2fe06afbf1c45db5.zip |
Merge branch 'master' into selectmenu
Diffstat (limited to 'ui/jquery.ui.effect-pulsate.js')
-rw-r--r-- | ui/jquery.ui.effect-pulsate.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/ui/jquery.ui.effect-pulsate.js b/ui/jquery.ui.effect-pulsate.js new file mode 100644 index 000000000..543f6310d --- /dev/null +++ b/ui/jquery.ui.effect-pulsate.js @@ -0,0 +1,63 @@ +/*! + * jQuery UI Effects Pulsate @VERSION + * http://jqueryui.com + * + * Copyright 2012 jQuery Foundation and other contributors + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Effects/Pulsate + * + * Depends: + * jquery.ui.effect.js + */ +(function( $, undefined ) { + +$.effects.effect.pulsate = function( o, done ) { + var elem = $( this ), + mode = $.effects.setMode( elem, o.mode || "show" ), + show = mode === "show", + hide = mode === "hide", + showhide = ( show || mode === "hide" ), + + // showing or hiding leaves of the "last" animation + anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ), + duration = o.duration / anims, + animateTo = 0, + queue = elem.queue(), + queuelen = queue.length, + i; + + if ( show || !elem.is(":visible")) { + elem.css( "opacity", 0 ).show(); + animateTo = 1; + } + + // anims - 1 opacity "toggles" + for ( i = 1; i < anims; i++ ) { + elem.animate({ + opacity: animateTo + }, duration, o.easing ); + animateTo = 1 - animateTo; + } + + elem.animate({ + opacity: animateTo + }, duration, o.easing); + + elem.queue(function() { + if ( hide ) { + elem.hide(); + } + done(); + }); + + // We just queued up "anims" animations, we need to put them next in the queue + if ( queuelen > 1 ) { + queue.splice.apply( queue, + [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); + } + elem.dequeue(); +}; + +})(jQuery); |