]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/fx.js
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
8 if(!dojo
._hasResource
["dojo.fx"]){
9 dojo
._hasResource
["dojo.fx"]=true;
10 dojo
.provide("dojo.fx");
11 dojo
.require("dojo.fx.Toggler");
13 var d
=dojo
,_1
={_fire:function(_2
,_3
){
15 this[_2
].apply(this,_3
||[]);
21 this._animations
=_5
||[];
22 this._current
=this._onAnimateCtx
=this._onEndCtx
=null;
24 d
.forEach(this._animations
,function(a
){
25 this.duration
+=a
.duration
;
27 this.duration
+=a
.delay
;
31 d
.extend(_4
,{_onAnimate:function(){
32 this._fire("onAnimate",arguments
);
34 d
.disconnect(this._onAnimateCtx
);
35 d
.disconnect(this._onEndCtx
);
36 this._onAnimateCtx
=this._onEndCtx
=null;
37 if(this._index
+1==this._animations
.length
){
40 this._current
=this._animations
[++this._index
];
41 this._onAnimateCtx
=d
.connect(this._current
,"onAnimate",this,"_onAnimate");
42 this._onEndCtx
=d
.connect(this._current
,"onEnd",this,"_onEnd");
43 this._current
.play(0,true);
45 },play:function(_6
,_7
){
47 this._current
=this._animations
[this._index
=0];
49 if(!_7
&&this._current
.status()=="playing"){
52 var _8
=d
.connect(this._current
,"beforeBegin",this,function(){
53 this._fire("beforeBegin");
54 }),_9
=d
.connect(this._current
,"onBegin",this,function(_a
){
55 this._fire("onBegin",arguments
);
56 }),_b
=d
.connect(this._current
,"onPlay",this,function(_c
){
57 this._fire("onPlay",arguments
);
62 if(this._onAnimateCtx
){
63 d
.disconnect(this._onAnimateCtx
);
65 this._onAnimateCtx
=d
.connect(this._current
,"onAnimate",this,"_onAnimate");
67 d
.disconnect(this._onEndCtx
);
69 this._onEndCtx
=d
.connect(this._current
,"onEnd",this,"_onEnd");
70 this._current
.play
.apply(this._current
,arguments
);
74 var e
=d
.connect(this._current
,"onPause",this,function(_d
){
75 this._fire("onPause",arguments
);
78 this._current
.pause();
81 },gotoPercent:function(_e
,_f
){
83 var _10
=this.duration
*_e
;
85 d
.some(this._animations
,function(a
){
94 this._current
.gotoPercent(_10
/this._current
.duration
,_f
);
100 for(;this._index
+1<this._animations
.length
;++this._index
){
101 this._animations
[this._index
].stop(true);
103 this._current
=this._animations
[this._index
];
105 var e
=d
.connect(this._current
,"onStop",this,function(arg
){
106 this._fire("onStop",arguments
);
109 this._current
.stop();
113 return this._current
?this._current
.status():"stopped";
114 },destroy:function(){
115 if(this._onAnimateCtx
){
116 d
.disconnect(this._onAnimateCtx
);
119 d
.disconnect(this._onEndCtx
);
123 dojo
.fx
.chain=function(_12
){
126 var _13=function(_14
){
127 this._animations
=_14
||[];
131 d
.forEach(_14
,function(a
){
136 if(this.duration
<_15
){
139 this._connects
.push(d
.connect(a
,"onEnd",this,"_onEnd"));
141 this._pseudoAnimation
=new d
.Animation({curve
:[0,1],duration
:this.duration
});
143 d
.forEach(["beforeBegin","onBegin","onPlay","onAnimate","onPause","onStop","onEnd"],function(evt
){
144 _16
._connects
.push(d
.connect(_16
._pseudoAnimation
,evt
,function(){
145 _16
._fire(evt
,arguments
);
149 d
.extend(_13
,{_doAction:function(_17
,_18
){
150 d
.forEach(this._animations
,function(a
){
155 if(++this._finished
>this._animations
.length
){
158 },_call:function(_19
,_1a
){
159 var t
=this._pseudoAnimation
;
161 },play:function(_1b
,_1c
){
163 this._doAction("play",arguments
);
164 this._call("play",arguments
);
167 this._doAction("pause",arguments
);
168 this._call("pause",arguments
);
170 },gotoPercent:function(_1d
,_1e
){
171 var ms
=this.duration
*_1d
;
172 d
.forEach(this._animations
,function(a
){
173 a
.gotoPercent(a
.duration
<ms
?1:(ms
/a
.duration
),_1e
);
175 this._call("gotoPercent",arguments
);
177 },stop:function(_1f
){
178 this._doAction("stop",arguments
);
179 this._call("stop",arguments
);
182 return this._pseudoAnimation
.status();
183 },destroy:function(){
184 d
.forEach(this._connects
,dojo
.disconnect
);
187 dojo
.fx
.combine=function(_20
){
190 dojo
.fx
.wipeIn=function(_21
){
191 var _22
=_21
.node
=d
.byId(_21
.node
),s
=_22
.style
,o
;
192 var _23
=d
.animateProperty(d
.mixin({properties
:{height
:{start:function(){
195 if(s
.visibility
=="hidden"||s
.display
=="none"){
201 var _24
=d
.style(_22
,"height");
202 return Math
.max(_24
,1);
205 return _22
.scrollHeight
;
207 d
.connect(_23
,"onEnd",function(){
213 dojo
.fx
.wipeOut=function(_25
){
214 var _26
=_25
.node
=d
.byId(_25
.node
),s
=_26
.style
,o
;
215 var _27
=d
.animateProperty(d
.mixin({properties
:{height
:{end
:1}}},_25
));
216 d
.connect(_27
,"beforeBegin",function(){
221 d
.connect(_27
,"onEnd",function(){
228 dojo
.fx
.slideTo=function(_28
){
229 var _29
=_28
.node
=d
.byId(_28
.node
),top
=null,_2a
=null;
230 var _2b
=(function(n
){
232 var cs
=d
.getComputedStyle(n
);
234 top
=(pos
=="absolute"?n
.offsetTop
:parseInt(cs
.top
)||0);
235 _2a
=(pos
=="absolute"?n
.offsetLeft
:parseInt(cs
.left
)||0);
236 if(pos
!="absolute"&&pos
!="relative"){
237 var ret
=d
.position(n
,true);
240 n
.style
.position
="absolute";
241 n
.style
.top
=top
+"px";
242 n
.style
.left
=_2a
+"px";
247 var _2c
=d
.animateProperty(d
.mixin({properties
:{top
:_28
.top
||0,left
:_28
.left
||0}},_28
));
248 d
.connect(_2c
,"beforeBegin",_2c
,_2b
);