[18953] | 1 | /*! |
---|
[28780] | 2 | * jQuery UI Effects Pulsate 1.10.4 |
---|
[18953] | 3 | * http://jqueryui.com |
---|
| 4 | * |
---|
[28780] | 5 | * Copyright 2014 jQuery Foundation and other contributors |
---|
[18953] | 6 | * Released under the MIT license. |
---|
| 7 | * http://jquery.org/license |
---|
| 8 | * |
---|
| 9 | * http://api.jqueryui.com/pulsate-effect/ |
---|
| 10 | * |
---|
| 11 | * Depends: |
---|
| 12 | * jquery.ui.effect.js |
---|
| 13 | */ |
---|
| 14 | (function( $, undefined ) { |
---|
| 15 | |
---|
| 16 | $.effects.effect.pulsate = function( o, done ) { |
---|
| 17 | var elem = $( this ), |
---|
| 18 | mode = $.effects.setMode( elem, o.mode || "show" ), |
---|
| 19 | show = mode === "show", |
---|
| 20 | hide = mode === "hide", |
---|
| 21 | showhide = ( show || mode === "hide" ), |
---|
| 22 | |
---|
| 23 | // showing or hiding leaves of the "last" animation |
---|
| 24 | anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ), |
---|
| 25 | duration = o.duration / anims, |
---|
| 26 | animateTo = 0, |
---|
| 27 | queue = elem.queue(), |
---|
| 28 | queuelen = queue.length, |
---|
| 29 | i; |
---|
| 30 | |
---|
| 31 | if ( show || !elem.is(":visible")) { |
---|
| 32 | elem.css( "opacity", 0 ).show(); |
---|
| 33 | animateTo = 1; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | // anims - 1 opacity "toggles" |
---|
| 37 | for ( i = 1; i < anims; i++ ) { |
---|
| 38 | elem.animate({ |
---|
| 39 | opacity: animateTo |
---|
| 40 | }, duration, o.easing ); |
---|
| 41 | animateTo = 1 - animateTo; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | elem.animate({ |
---|
| 45 | opacity: animateTo |
---|
| 46 | }, duration, o.easing); |
---|
| 47 | |
---|
| 48 | elem.queue(function() { |
---|
| 49 | if ( hide ) { |
---|
| 50 | elem.hide(); |
---|
| 51 | } |
---|
| 52 | done(); |
---|
| 53 | }); |
---|
| 54 | |
---|
| 55 | // We just queued up "anims" animations, we need to put them next in the queue |
---|
| 56 | if ( queuelen > 1 ) { |
---|
| 57 | queue.splice.apply( queue, |
---|
| 58 | [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); |
---|
| 59 | } |
---|
| 60 | elem.dequeue(); |
---|
| 61 | }; |
---|
| 62 | |
---|
| 63 | })(jQuery); |
---|