]> git.wh0rd.org - tt-rss.git/blob - lib/dojo/fx.js
add dijit/dojo stuff; initial ui mockup
[tt-rss.git] / lib / dojo / fx.js
1 /*
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["dojo.fx"]){
9 dojo._hasResource["dojo.fx"]=true;
10 dojo.provide("dojo.fx");
11 dojo.require("dojo.fx.Toggler");
12 (function(){
13 var d=dojo,_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 d.forEach(this._animations,function(a){
25 this.duration+=a.duration;
26 if(a.delay){
27 this.duration+=a.delay;
28 }
29 },this);
30 };
31 d.extend(_4,{_onAnimate:function(){
32 this._fire("onAnimate",arguments);
33 },_onEnd:function(){
34 d.disconnect(this._onAnimateCtx);
35 d.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=d.connect(this._current,"onAnimate",this,"_onAnimate");
42 this._onEndCtx=d.connect(this._current,"onEnd",this,"_onEnd");
43 this._current.play(0,true);
44 }
45 },play:function(_6,_7){
46 if(!this._current){
47 this._current=this._animations[this._index=0];
48 }
49 if(!_7&&this._current.status()=="playing"){
50 return this;
51 }
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);
58 d.disconnect(_8);
59 d.disconnect(_9);
60 d.disconnect(_b);
61 });
62 if(this._onAnimateCtx){
63 d.disconnect(this._onAnimateCtx);
64 }
65 this._onAnimateCtx=d.connect(this._current,"onAnimate",this,"_onAnimate");
66 if(this._onEndCtx){
67 d.disconnect(this._onEndCtx);
68 }
69 this._onEndCtx=d.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=d.connect(this._current,"onPause",this,function(_d){
75 this._fire("onPause",arguments);
76 d.disconnect(e);
77 });
78 this._current.pause();
79 }
80 return this;
81 },gotoPercent:function(_e,_f){
82 this.pause();
83 var _10=this.duration*_e;
84 this._current=null;
85 d.some(this._animations,function(a){
86 if(a.duration<=_10){
87 this._current=a;
88 return true;
89 }
90 _10-=a.duration;
91 return false;
92 });
93 if(this._current){
94 this._current.gotoPercent(_10/this._current.duration,_f);
95 }
96 return this;
97 },stop:function(_11){
98 if(this._current){
99 if(_11){
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=d.connect(this._current,"onStop",this,function(arg){
106 this._fire("onStop",arguments);
107 d.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 d.disconnect(this._onAnimateCtx);
117 }
118 if(this._onEndCtx){
119 d.disconnect(this._onEndCtx);
120 }
121 }});
122 d.extend(_4,_1);
123 dojo.fx.chain=function(_12){
124 return new _4(_12);
125 };
126 var _13=function(_14){
127 this._animations=_14||[];
128 this._connects=[];
129 this._finished=0;
130 this.duration=0;
131 d.forEach(_14,function(a){
132 var _15=a.duration;
133 if(a.delay){
134 _15+=a.delay;
135 }
136 if(this.duration<_15){
137 this.duration=_15;
138 }
139 this._connects.push(d.connect(a,"onEnd",this,"_onEnd"));
140 },this);
141 this._pseudoAnimation=new d.Animation({curve:[0,1],duration:this.duration});
142 var _16=this;
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);
146 }));
147 });
148 };
149 d.extend(_13,{_doAction:function(_17,_18){
150 d.forEach(this._animations,function(a){
151 a[_17].apply(a,_18);
152 });
153 return this;
154 },_onEnd:function(){
155 if(++this._finished>this._animations.length){
156 this._fire("onEnd");
157 }
158 },_call:function(_19,_1a){
159 var t=this._pseudoAnimation;
160 t[_19].apply(t,_1a);
161 },play:function(_1b,_1c){
162 this._finished=0;
163 this._doAction("play",arguments);
164 this._call("play",arguments);
165 return this;
166 },pause:function(){
167 this._doAction("pause",arguments);
168 this._call("pause",arguments);
169 return this;
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);
174 });
175 this._call("gotoPercent",arguments);
176 return this;
177 },stop:function(_1f){
178 this._doAction("stop",arguments);
179 this._call("stop",arguments);
180 return this;
181 },status:function(){
182 return this._pseudoAnimation.status();
183 },destroy:function(){
184 d.forEach(this._connects,dojo.disconnect);
185 }});
186 d.extend(_13,_1);
187 dojo.fx.combine=function(_20){
188 return new _13(_20);
189 };
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(){
193 o=s.overflow;
194 s.overflow="hidden";
195 if(s.visibility=="hidden"||s.display=="none"){
196 s.height="1px";
197 s.display="";
198 s.visibility="";
199 return 1;
200 }else{
201 var _24=d.style(_22,"height");
202 return Math.max(_24,1);
203 }
204 },end:function(){
205 return _22.scrollHeight;
206 }}}},_21));
207 d.connect(_23,"onEnd",function(){
208 s.height="auto";
209 s.overflow=o;
210 });
211 return _23;
212 };
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(){
217 o=s.overflow;
218 s.overflow="hidden";
219 s.display="";
220 });
221 d.connect(_27,"onEnd",function(){
222 s.overflow=o;
223 s.height="auto";
224 s.display="none";
225 });
226 return _27;
227 };
228 dojo.fx.slideTo=function(_28){
229 var _29=_28.node=d.byId(_28.node),top=null,_2a=null;
230 var _2b=(function(n){
231 return function(){
232 var cs=d.getComputedStyle(n);
233 var pos=cs.position;
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);
238 top=ret.y;
239 _2a=ret.x;
240 n.style.position="absolute";
241 n.style.top=top+"px";
242 n.style.left=_2a+"px";
243 }
244 };
245 })(_29);
246 _2b();
247 var _2c=d.animateProperty(d.mixin({properties:{top:_28.top||0,left:_28.left||0}},_28));
248 d.connect(_2c,"beforeBegin",_2c,_2b);
249 return _2c;
250 };
251 })();
252 }