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