root / trunk / web / dojo / dojox / timing / Sequence.js @ 10
History | View | Annotate | Download (1.66 KB)
| 1 | 9 | andrej.cim | /*
|
|---|---|---|---|
| 2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
| 3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
| 4 | see: http://dojotoolkit.org/license for details
|
||
| 5 | */
|
||
| 6 | |||
| 7 | |||
| 8 | if(!dojo._hasResource["dojox.timing.Sequence"]){ |
||
| 9 | dojo._hasResource["dojox.timing.Sequence"]=true; |
||
| 10 | dojo.provide("dojox.timing.Sequence");
|
||
| 11 | dojo.experimental("dojox.timing.Sequence");
|
||
| 12 | dojo.declare("dojox.timing.Sequence",null,{_goOnPause:0,_running:false,constructor:function(){ |
||
| 13 | this._defsResolved=[];
|
||
| 14 | },go:function(_1,_2){ |
||
| 15 | this._running=true; |
||
| 16 | dojo.forEach(_1,function(_3){
|
||
| 17 | if(_3.repeat>1){ |
||
| 18 | var _4=_3.repeat;
|
||
| 19 | for(var j=0;j<_4;j++){ |
||
| 20 | _3.repeat=1;
|
||
| 21 | this._defsResolved.push(_3);
|
||
| 22 | } |
||
| 23 | }else{
|
||
| 24 | this._defsResolved.push(_3);
|
||
| 25 | } |
||
| 26 | },this);
|
||
| 27 | var _5=_1[_1.length-1]; |
||
| 28 | if(_2){
|
||
| 29 | this._defsResolved.push({func:_2}); |
||
| 30 | } |
||
| 31 | this._defsResolved.push({func:[this.stop,this]}); |
||
| 32 | this._curId=0; |
||
| 33 | this._go();
|
||
| 34 | },_go:function(){ |
||
| 35 | if(!this._running){ |
||
| 36 | return;
|
||
| 37 | } |
||
| 38 | var _6=this._defsResolved[this._curId]; |
||
| 39 | this._curId+=1; |
||
| 40 | function _7(_8){ |
||
| 41 | var _9=null; |
||
| 42 | if(dojo.isArray(_8)){
|
||
| 43 | if(_8.length>2){ |
||
| 44 | _9=_8[0].apply(_8[1],_8.slice(2)); |
||
| 45 | }else{
|
||
| 46 | _9=_8[0].apply(_8[1]); |
||
| 47 | } |
||
| 48 | }else{
|
||
| 49 | _9=_8(); |
||
| 50 | } |
||
| 51 | return _9;
|
||
| 52 | }; |
||
| 53 | if(this._curId>=this._defsResolved.length){ |
||
| 54 | _7(_6.func); |
||
| 55 | return;
|
||
| 56 | } |
||
| 57 | if(_6.pauseAfter){
|
||
| 58 | if(_7(_6.func)!==false){ |
||
| 59 | setTimeout(dojo.hitch(this,"_go"),_6.pauseAfter); |
||
| 60 | }else{
|
||
| 61 | this._goOnPause=_6.pauseAfter;
|
||
| 62 | } |
||
| 63 | }else{
|
||
| 64 | if(_6.pauseBefore){
|
||
| 65 | var x=dojo.hitch(this,function(){ |
||
| 66 | if(_7(_6.func)!==false){ |
||
| 67 | this._go();
|
||
| 68 | } |
||
| 69 | }); |
||
| 70 | setTimeout(x,_6.pauseBefore); |
||
| 71 | }else{
|
||
| 72 | if(_7(_6.func)!==false){ |
||
| 73 | this._go();
|
||
| 74 | } |
||
| 75 | } |
||
| 76 | } |
||
| 77 | },goOn:function(){ |
||
| 78 | if(this._goOnPause){ |
||
| 79 | setTimeout(dojo.hitch(this,"_go"),this._goOnPause); |
||
| 80 | this._goOnPause=0; |
||
| 81 | }else{
|
||
| 82 | this._go();
|
||
| 83 | } |
||
| 84 | },stop:function(){ |
||
| 85 | this._running=false; |
||
| 86 | }}); |
||
| 87 | } |