]> git.wh0rd.org - tt-rss.git/blob - lib/dojo/_base/fx.js
add dijit/dojo stuff; initial ui mockup
[tt-rss.git] / lib / dojo / _base / 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._base.fx"]){
9 dojo._hasResource["dojo._base.fx"]=true;
10 dojo.provide("dojo._base.fx");
11 dojo.require("dojo._base.Color");
12 dojo.require("dojo._base.connect");
13 dojo.require("dojo._base.lang");
14 dojo.require("dojo._base.html");
15 (function(){
16 var d=dojo;
17 var _1=d._mixin;
18 dojo._Line=function(_2,_3){
19 this.start=_2;
20 this.end=_3;
21 };
22 dojo._Line.prototype.getValue=function(n){
23 return ((this.end-this.start)*n)+this.start;
24 };
25 dojo.Animation=function(_4){
26 _1(this,_4);
27 if(d.isArray(this.curve)){
28 this.curve=new d._Line(this.curve[0],this.curve[1]);
29 }
30 };
31 d._Animation=d.Animation;
32 d.extend(dojo.Animation,{duration:350,repeat:0,rate:20,_percent:0,_startRepeatCount:0,_getStep:function(){
33 var _5=this._percent,_6=this.easing;
34 return _6?_6(_5):_5;
35 },_fire:function(_7,_8){
36 var a=_8||[];
37 if(this[_7]){
38 if(d.config.debugAtAllCosts){
39 this[_7].apply(this,a);
40 }else{
41 try{
42 this[_7].apply(this,a);
43 }
44 catch(e){
45 console.error("exception in animation handler for:",_7);
46 console.error(e);
47 }
48 }
49 }
50 return this;
51 },play:function(_9,_a){
52 var _b=this;
53 if(_b._delayTimer){
54 _b._clearTimer();
55 }
56 if(_a){
57 _b._stopTimer();
58 _b._active=_b._paused=false;
59 _b._percent=0;
60 }else{
61 if(_b._active&&!_b._paused){
62 return _b;
63 }
64 }
65 _b._fire("beforeBegin",[_b.node]);
66 var de=_9||_b.delay,_c=dojo.hitch(_b,"_play",_a);
67 if(de>0){
68 _b._delayTimer=setTimeout(_c,de);
69 return _b;
70 }
71 _c();
72 return _b;
73 },_play:function(_d){
74 var _e=this;
75 if(_e._delayTimer){
76 _e._clearTimer();
77 }
78 _e._startTime=new Date().valueOf();
79 if(_e._paused){
80 _e._startTime-=_e.duration*_e._percent;
81 }
82 _e._active=true;
83 _e._paused=false;
84 var _f=_e.curve.getValue(_e._getStep());
85 if(!_e._percent){
86 if(!_e._startRepeatCount){
87 _e._startRepeatCount=_e.repeat;
88 }
89 _e._fire("onBegin",[_f]);
90 }
91 _e._fire("onPlay",[_f]);
92 _e._cycle();
93 return _e;
94 },pause:function(){
95 var _10=this;
96 if(_10._delayTimer){
97 _10._clearTimer();
98 }
99 _10._stopTimer();
100 if(!_10._active){
101 return _10;
102 }
103 _10._paused=true;
104 _10._fire("onPause",[_10.curve.getValue(_10._getStep())]);
105 return _10;
106 },gotoPercent:function(_11,_12){
107 var _13=this;
108 _13._stopTimer();
109 _13._active=_13._paused=true;
110 _13._percent=_11;
111 if(_12){
112 _13.play();
113 }
114 return _13;
115 },stop:function(_14){
116 var _15=this;
117 if(_15._delayTimer){
118 _15._clearTimer();
119 }
120 if(!_15._timer){
121 return _15;
122 }
123 _15._stopTimer();
124 if(_14){
125 _15._percent=1;
126 }
127 _15._fire("onStop",[_15.curve.getValue(_15._getStep())]);
128 _15._active=_15._paused=false;
129 return _15;
130 },status:function(){
131 if(this._active){
132 return this._paused?"paused":"playing";
133 }
134 return "stopped";
135 },_cycle:function(){
136 var _16=this;
137 if(_16._active){
138 var _17=new Date().valueOf();
139 var _18=(_17-_16._startTime)/(_16.duration);
140 if(_18>=1){
141 _18=1;
142 }
143 _16._percent=_18;
144 if(_16.easing){
145 _18=_16.easing(_18);
146 }
147 _16._fire("onAnimate",[_16.curve.getValue(_18)]);
148 if(_16._percent<1){
149 _16._startTimer();
150 }else{
151 _16._active=false;
152 if(_16.repeat>0){
153 _16.repeat--;
154 _16.play(null,true);
155 }else{
156 if(_16.repeat==-1){
157 _16.play(null,true);
158 }else{
159 if(_16._startRepeatCount){
160 _16.repeat=_16._startRepeatCount;
161 _16._startRepeatCount=0;
162 }
163 }
164 }
165 _16._percent=0;
166 _16._fire("onEnd",[_16.node]);
167 !_16.repeat&&_16._stopTimer();
168 }
169 }
170 return _16;
171 },_clearTimer:function(){
172 clearTimeout(this._delayTimer);
173 delete this._delayTimer;
174 }});
175 var ctr=0,_19=null,_1a={run:function(){
176 }};
177 d.extend(d.Animation,{_startTimer:function(){
178 if(!this._timer){
179 this._timer=d.connect(_1a,"run",this,"_cycle");
180 ctr++;
181 }
182 if(!_19){
183 _19=setInterval(d.hitch(_1a,"run"),this.rate);
184 }
185 },_stopTimer:function(){
186 if(this._timer){
187 d.disconnect(this._timer);
188 this._timer=null;
189 ctr--;
190 }
191 if(ctr<=0){
192 clearInterval(_19);
193 _19=null;
194 ctr=0;
195 }
196 }});
197 var _1b=d.isIE?function(_1c){
198 var ns=_1c.style;
199 if(!ns.width.length&&d.style(_1c,"width")=="auto"){
200 ns.width="auto";
201 }
202 }:function(){
203 };
204 dojo._fade=function(_1d){
205 _1d.node=d.byId(_1d.node);
206 var _1e=_1({properties:{}},_1d),_1f=(_1e.properties.opacity={});
207 _1f.start=!("start" in _1e)?function(){
208 return +d.style(_1e.node,"opacity")||0;
209 }:_1e.start;
210 _1f.end=_1e.end;
211 var _20=d.animateProperty(_1e);
212 d.connect(_20,"beforeBegin",d.partial(_1b,_1e.node));
213 return _20;
214 };
215 dojo.fadeIn=function(_21){
216 return d._fade(_1({end:1},_21));
217 };
218 dojo.fadeOut=function(_22){
219 return d._fade(_1({end:0},_22));
220 };
221 dojo._defaultEasing=function(n){
222 return 0.5+((Math.sin((n+1.5)*Math.PI))/2);
223 };
224 var _23=function(_24){
225 this._properties=_24;
226 for(var p in _24){
227 var _25=_24[p];
228 if(_25.start instanceof d.Color){
229 _25.tempColor=new d.Color();
230 }
231 }
232 };
233 _23.prototype.getValue=function(r){
234 var ret={};
235 for(var p in this._properties){
236 var _26=this._properties[p],_27=_26.start;
237 if(_27 instanceof d.Color){
238 ret[p]=d.blendColors(_27,_26.end,r,_26.tempColor).toCss();
239 }else{
240 if(!d.isArray(_27)){
241 ret[p]=((_26.end-_27)*r)+_27+(p!="opacity"?_26.units||"px":0);
242 }
243 }
244 }
245 return ret;
246 };
247 dojo.animateProperty=function(_28){
248 var n=_28.node=d.byId(_28.node);
249 if(!_28.easing){
250 _28.easing=d._defaultEasing;
251 }
252 var _29=new d.Animation(_28);
253 d.connect(_29,"beforeBegin",_29,function(){
254 var pm={};
255 for(var p in this.properties){
256 if(p=="width"||p=="height"){
257 this.node.display="block";
258 }
259 var _2a=this.properties[p];
260 if(d.isFunction(_2a)){
261 _2a=_2a(n);
262 }
263 _2a=pm[p]=_1({},(d.isObject(_2a)?_2a:{end:_2a}));
264 if(d.isFunction(_2a.start)){
265 _2a.start=_2a.start(n);
266 }
267 if(d.isFunction(_2a.end)){
268 _2a.end=_2a.end(n);
269 }
270 var _2b=(p.toLowerCase().indexOf("color")>=0);
271 function _2c(_2d,p){
272 var v={height:_2d.offsetHeight,width:_2d.offsetWidth}[p];
273 if(v!==undefined){
274 return v;
275 }
276 v=d.style(_2d,p);
277 return (p=="opacity")?+v:(_2b?v:parseFloat(v));
278 };
279 if(!("end" in _2a)){
280 _2a.end=_2c(n,p);
281 }else{
282 if(!("start" in _2a)){
283 _2a.start=_2c(n,p);
284 }
285 }
286 if(_2b){
287 _2a.start=new d.Color(_2a.start);
288 _2a.end=new d.Color(_2a.end);
289 }else{
290 _2a.start=(p=="opacity")?+_2a.start:parseFloat(_2a.start);
291 }
292 }
293 this.curve=new _23(pm);
294 });
295 d.connect(_29,"onAnimate",d.hitch(d,"style",_29.node));
296 return _29;
297 };
298 dojo.anim=function(_2e,_2f,_30,_31,_32,_33){
299 return d.animateProperty({node:_2e,duration:_30||d.Animation.prototype.duration,properties:_2f,easing:_31,onEnd:_32}).play(_33||0);
300 };
301 })();
302 }