1
|
/*
|
2
|
Copyright (c) 2004-2008, 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["dojo.fx"]){
|
9
|
dojo._hasResource["dojo.fx"]=true;
|
10
|
dojo.provide("dojo.fx");
|
11
|
dojo.provide("dojo.fx.Toggler");
|
12
|
(function(){
|
13
|
var _1={_fire:function(_2,_3){
|
14
|
if(this[_2]){
|
15
|
this[_2].apply(this,_3||[]);
|
16
|
}
|
17
|
return this;
|
18
|
}};
|
19
|
var _4=function(_5){
|
20
|
this._index=-1;
|
21
|
this._animations=_5||[];
|
22
|
this._current=this._onAnimateCtx=this._onEndCtx=null;
|
23
|
this.duration=0;
|
24
|
dojo.forEach(this._animations,function(a){
|
25
|
this.duration+=a.duration;
|
26
|
if(a.delay){
|
27
|
this.duration+=a.delay;
|
28
|
}
|
29
|
},this);
|
30
|
};
|
31
|
dojo.extend(_4,{_onAnimate:function(){
|
32
|
this._fire("onAnimate",arguments);
|
33
|
},_onEnd:function(){
|
34
|
dojo.disconnect(this._onAnimateCtx);
|
35
|
dojo.disconnect(this._onEndCtx);
|
36
|
this._onAnimateCtx=this._onEndCtx=null;
|
37
|
if(this._index+1==this._animations.length){
|
38
|
this._fire("onEnd");
|
39
|
}else{
|
40
|
this._current=this._animations[++this._index];
|
41
|
this._onAnimateCtx=dojo.connect(this._current,"onAnimate",this,"_onAnimate");
|
42
|
this._onEndCtx=dojo.connect(this._current,"onEnd",this,"_onEnd");
|
43
|
this._current.play(0,true);
|
44
|
}
|
45
|
},play:function(_7,_8){
|
46
|
if(!this._current){
|
47
|
this._current=this._animations[this._index=0];
|
48
|
}
|
49
|
if(!_8&&this._current.status()=="playing"){
|
50
|
return this;
|
51
|
}
|
52
|
var _9=dojo.connect(this._current,"beforeBegin",this,function(){
|
53
|
this._fire("beforeBegin");
|
54
|
}),_a=dojo.connect(this._current,"onBegin",this,function(_b){
|
55
|
this._fire("onBegin",arguments);
|
56
|
}),_c=dojo.connect(this._current,"onPlay",this,function(_d){
|
57
|
this._fire("onPlay",arguments);
|
58
|
dojo.disconnect(_9);
|
59
|
dojo.disconnect(_a);
|
60
|
dojo.disconnect(_c);
|
61
|
});
|
62
|
if(this._onAnimateCtx){
|
63
|
dojo.disconnect(this._onAnimateCtx);
|
64
|
}
|
65
|
this._onAnimateCtx=dojo.connect(this._current,"onAnimate",this,"_onAnimate");
|
66
|
if(this._onEndCtx){
|
67
|
dojo.disconnect(this._onEndCtx);
|
68
|
}
|
69
|
this._onEndCtx=dojo.connect(this._current,"onEnd",this,"_onEnd");
|
70
|
this._current.play.apply(this._current,arguments);
|
71
|
return this;
|
72
|
},pause:function(){
|
73
|
if(this._current){
|
74
|
var e=dojo.connect(this._current,"onPause",this,function(_f){
|
75
|
this._fire("onPause",arguments);
|
76
|
dojo.disconnect(e);
|
77
|
});
|
78
|
this._current.pause();
|
79
|
}
|
80
|
return this;
|
81
|
},gotoPercent:function(_10,_11){
|
82
|
this.pause();
|
83
|
var _12=this.duration*_10;
|
84
|
this._current=null;
|
85
|
dojo.some(this._animations,function(a){
|
86
|
if(a.duration<=_12){
|
87
|
this._current=a;
|
88
|
return true;
|
89
|
}
|
90
|
_12-=a.duration;
|
91
|
return false;
|
92
|
});
|
93
|
if(this._current){
|
94
|
this._current.gotoPercent(_12/this._current.duration,_11);
|
95
|
}
|
96
|
return this;
|
97
|
},stop:function(_14){
|
98
|
if(this._current){
|
99
|
if(_14){
|
100
|
for(;this._index+1<this._animations.length;++this._index){
|
101
|
this._animations[this._index].stop(true);
|
102
|
}
|
103
|
this._current=this._animations[this._index];
|
104
|
}
|
105
|
var e=dojo.connect(this._current,"onStop",this,function(arg){
|
106
|
this._fire("onStop",arguments);
|
107
|
dojo.disconnect(e);
|
108
|
});
|
109
|
this._current.stop();
|
110
|
}
|
111
|
return this;
|
112
|
},status:function(){
|
113
|
return this._current?this._current.status():"stopped";
|
114
|
},destroy:function(){
|
115
|
if(this._onAnimateCtx){
|
116
|
dojo.disconnect(this._onAnimateCtx);
|
117
|
}
|
118
|
if(this._onEndCtx){
|
119
|
dojo.disconnect(this._onEndCtx);
|
120
|
}
|
121
|
}});
|
122
|
dojo.extend(_4,_1);
|
123
|
dojo.fx.chain=function(_17){
|
124
|
return new _4(_17);
|
125
|
};
|
126
|
var _18=function(_19){
|
127
|
this._animations=_19||[];
|
128
|
this._connects=[];
|
129
|
this._finished=0;
|
130
|
this.duration=0;
|
131
|
dojo.forEach(_19,function(a){
|
132
|
var _1b=a.duration;
|
133
|
if(a.delay){
|
134
|
_1b+=a.delay;
|
135
|
}
|
136
|
if(this.duration<_1b){
|
137
|
this.duration=_1b;
|
138
|
}
|
139
|
this._connects.push(dojo.connect(a,"onEnd",this,"_onEnd"));
|
140
|
},this);
|
141
|
this._pseudoAnimation=new dojo._Animation({curve:[0,1],duration:this.duration});
|
142
|
dojo.forEach(["beforeBegin","onBegin","onPlay","onAnimate","onPause","onStop"],function(evt){
|
143
|
this._connects.push(dojo.connect(this._pseudoAnimation,evt,dojo.hitch(this,"_fire",evt)));
|
144
|
},this);
|
145
|
};
|
146
|
dojo.extend(_18,{_doAction:function(_1d,_1e){
|
147
|
dojo.forEach(this._animations,function(a){
|
148
|
a[_1d].apply(a,_1e);
|
149
|
});
|
150
|
return this;
|
151
|
},_onEnd:function(){
|
152
|
if(++this._finished==this._animations.length){
|
153
|
this._fire("onEnd");
|
154
|
}
|
155
|
},_call:function(_20,_21){
|
156
|
var t=this._pseudoAnimation;
|
157
|
t[_20].apply(t,_21);
|
158
|
},play:function(_23,_24){
|
159
|
this._finished=0;
|
160
|
this._doAction("play",arguments);
|
161
|
this._call("play",arguments);
|
162
|
return this;
|
163
|
},pause:function(){
|
164
|
this._doAction("pause",arguments);
|
165
|
this._call("pause",arguments);
|
166
|
return this;
|
167
|
},gotoPercent:function(_25,_26){
|
168
|
var ms=this.duration*_25;
|
169
|
dojo.forEach(this._animations,function(a){
|
170
|
a.gotoPercent(a.duration<ms?1:(ms/a.duration),_26);
|
171
|
});
|
172
|
this._call("gotoPercent",arguments);
|
173
|
return this;
|
174
|
},stop:function(_29){
|
175
|
this._doAction("stop",arguments);
|
176
|
this._call("stop",arguments);
|
177
|
return this;
|
178
|
},status:function(){
|
179
|
return this._pseudoAnimation.status();
|
180
|
},destroy:function(){
|
181
|
dojo.forEach(this._connects,dojo.disconnect);
|
182
|
}});
|
183
|
dojo.extend(_18,_1);
|
184
|
dojo.fx.combine=function(_2a){
|
185
|
return new _18(_2a);
|
186
|
};
|
187
|
})();
|
188
|
dojo.declare("dojo.fx.Toggler",null,{constructor:function(_2b){
|
189
|
var _t=this;
|
190
|
dojo.mixin(_t,_2b);
|
191
|
_t.node=_2b.node;
|
192
|
_t._showArgs=dojo.mixin({},_2b);
|
193
|
_t._showArgs.node=_t.node;
|
194
|
_t._showArgs.duration=_t.showDuration;
|
195
|
_t.showAnim=_t.showFunc(_t._showArgs);
|
196
|
_t._hideArgs=dojo.mixin({},_2b);
|
197
|
_t._hideArgs.node=_t.node;
|
198
|
_t._hideArgs.duration=_t.hideDuration;
|
199
|
_t.hideAnim=_t.hideFunc(_t._hideArgs);
|
200
|
dojo.connect(_t.showAnim,"beforeBegin",dojo.hitch(_t.hideAnim,"stop",true));
|
201
|
dojo.connect(_t.hideAnim,"beforeBegin",dojo.hitch(_t.showAnim,"stop",true));
|
202
|
},node:null,showFunc:dojo.fadeIn,hideFunc:dojo.fadeOut,showDuration:200,hideDuration:200,show:function(_2d){
|
203
|
return this.showAnim.play(_2d||0);
|
204
|
},hide:function(_2e){
|
205
|
return this.hideAnim.play(_2e||0);
|
206
|
}});
|
207
|
dojo.fx.wipeIn=function(_2f){
|
208
|
_2f.node=dojo.byId(_2f.node);
|
209
|
var _30=_2f.node,s=_30.style,o;
|
210
|
var _33=dojo.animateProperty(dojo.mixin({properties:{height:{start:function(){
|
211
|
o=s.overflow;
|
212
|
s.overflow="hidden";
|
213
|
if(s.visibility=="hidden"||s.display=="none"){
|
214
|
s.height="1px";
|
215
|
s.display="";
|
216
|
s.visibility="";
|
217
|
return 1;
|
218
|
}else{
|
219
|
var _34=dojo.style(_30,"height");
|
220
|
return Math.max(_34,1);
|
221
|
}
|
222
|
},end:function(){
|
223
|
return _30.scrollHeight;
|
224
|
}}}},_2f));
|
225
|
dojo.connect(_33,"onEnd",function(){
|
226
|
s.height="auto";
|
227
|
s.overflow=o;
|
228
|
});
|
229
|
return _33;
|
230
|
};
|
231
|
dojo.fx.wipeOut=function(_35){
|
232
|
var _36=_35.node=dojo.byId(_35.node);
|
233
|
var s=_36.style;
|
234
|
var o;
|
235
|
var _39=dojo.animateProperty(dojo.mixin({properties:{height:{end:1}}},_35));
|
236
|
dojo.connect(_39,"beforeBegin",function(){
|
237
|
o=s.overflow;
|
238
|
s.overflow="hidden";
|
239
|
s.display="";
|
240
|
});
|
241
|
dojo.connect(_39,"onEnd",function(){
|
242
|
s.overflow=o;
|
243
|
s.height="auto";
|
244
|
s.display="none";
|
245
|
});
|
246
|
return _39;
|
247
|
};
|
248
|
dojo.fx.slideTo=function(_3a){
|
249
|
var _3b=(_3a.node=dojo.byId(_3a.node));
|
250
|
var top=null;
|
251
|
var _3d=null;
|
252
|
var _3e=(function(n){
|
253
|
return function(){
|
254
|
var cs=dojo.getComputedStyle(n);
|
255
|
var pos=cs.position;
|
256
|
top=(pos=="absolute"?n.offsetTop:parseInt(cs.top)||0);
|
257
|
_3d=(pos=="absolute"?n.offsetLeft:parseInt(cs.left)||0);
|
258
|
if(pos!="absolute"&&pos!="relative"){
|
259
|
var ret=dojo.coords(n,true);
|
260
|
top=ret.y;
|
261
|
_3d=ret.x;
|
262
|
n.style.position="absolute";
|
263
|
n.style.top=top+"px";
|
264
|
n.style.left=_3d+"px";
|
265
|
}
|
266
|
};
|
267
|
})(_3b);
|
268
|
_3e();
|
269
|
var _43=dojo.animateProperty(dojo.mixin({properties:{top:{end:_3a.top||0},left:{end:_3a.left||0}}},_3a));
|
270
|
dojo.connect(_43,"beforeBegin",_43,_3e);
|
271
|
return _43;
|
272
|
};
|
273
|
}
|