UPDATE 4.4.0.0
[phpmyadmin.git] / js / jquery / src / jquery-ui / effect-pulsate.js
blob18d7c33a306f16b630851699f23f4c8e681b66b7
1 /*!
2  * jQuery UI Effects Pulsate 1.11.2
3  * http://jqueryui.com
4  *
5  * Copyright 2014 jQuery Foundation and other contributors
6  * Released under the MIT license.
7  * http://jquery.org/license
8  *
9  * http://api.jqueryui.com/pulsate-effect/
10  */
11 (function( factory ) {
12         if ( typeof define === "function" && define.amd ) {
14                 // AMD. Register as an anonymous module.
15                 define([
16                         "jquery",
17                         "./effect"
18                 ], factory );
19         } else {
21                 // Browser globals
22                 factory( jQuery );
23         }
24 }(function( $ ) {
26 return $.effects.effect.pulsate = function( o, done ) {
27         var elem = $( this ),
28                 mode = $.effects.setMode( elem, o.mode || "show" ),
29                 show = mode === "show",
30                 hide = mode === "hide",
31                 showhide = ( show || mode === "hide" ),
33                 // showing or hiding leaves of the "last" animation
34                 anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
35                 duration = o.duration / anims,
36                 animateTo = 0,
37                 queue = elem.queue(),
38                 queuelen = queue.length,
39                 i;
41         if ( show || !elem.is(":visible")) {
42                 elem.css( "opacity", 0 ).show();
43                 animateTo = 1;
44         }
46         // anims - 1 opacity "toggles"
47         for ( i = 1; i < anims; i++ ) {
48                 elem.animate({
49                         opacity: animateTo
50                 }, duration, o.easing );
51                 animateTo = 1 - animateTo;
52         }
54         elem.animate({
55                 opacity: animateTo
56         }, duration, o.easing);
58         elem.queue(function() {
59                 if ( hide ) {
60                         elem.hide();
61                 }
62                 done();
63         });
65         // We just queued up "anims" animations, we need to put them next in the queue
66         if ( queuelen > 1 ) {
67                 queue.splice.apply( queue,
68                         [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
69         }
70         elem.dequeue();
73 }));