Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / widget / Roller.js @ 13

History | View | Annotate | Download (2.33 KB)

1 9 andrej.cim
/*
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["dojox.widget.Roller"]){
9
dojo._hasResource["dojox.widget.Roller"]=true;
10
dojo.provide("dojox.widget.Roller");
11
dojo.require("dijit._Widget");
12
dojo.declare("dojox.widget.Roller",dijit._Widget,{delay:2000,autoStart:true,itemSelector:"> li",durationIn:400,durationOut:275,_idx:-1,postCreate:function(){
13
if(!this["items"]){
14
this.items=[];
15
}
16
dojo.addClass(this.domNode,"dojoxRoller");
17
dojo.query(this.itemSelector,this.domNode).forEach(function(_1,i){
18
this.items.push(_1.innerHTML);
19
if(i==0){
20
this._roller=_1;
21
this._idx=0;
22
}else{
23
dojo.destroy(_1);
24
}
25
},this);
26
if(!this._roller){
27
this._roller=dojo.create("li",null,this.domNode);
28
}
29
this.makeAnims();
30
if(this.autoStart){
31
this.start();
32
}
33
},makeAnims:function(){
34
var n=this.domNode;
35
dojo.mixin(this,{_anim:{"in":dojo.fadeIn({node:n,duration:this.durationIn}),"out":dojo.fadeOut({node:n,duration:this.durationOut})}});
36
this._setupConnects();
37
},_setupConnects:function(){
38
var _2=this._anim;
39
this.connect(_2["out"],"onEnd",function(){
40
this._set(this._idx+1);
41
_2["in"].play(15);
42
});
43
this.connect(_2["in"],"onEnd",function(){
44
this._timeout=setTimeout(dojo.hitch(this,"_run"),this.delay);
45
});
46
},start:function(){
47
if(!this.rolling){
48
this.rolling=true;
49
this._run();
50
}
51
},_run:function(){
52
this._anim["out"].gotoPercent(0,true);
53
},stop:function(){
54
this.rolling=false;
55
var m=this._anim,t=this._timeout;
56
if(t){
57
clearTimeout(t);
58
}
59
m["in"].stop();
60
m["out"].stop();
61
},_set:function(i){
62
var l=this.items.length-1;
63
if(i<0){
64
i=l;
65
}
66
if(i>l){
67
i=0;
68
}
69
this._roller.innerHTML=this.items[i]||"error!";
70
this._idx=i;
71
}});
72
dojo.declare("dojox.widget.RollerSlide",dojox.widget.Roller,{durationOut:175,makeAnims:function(){
73
var n=this.domNode,_3="position",_4={top:{end:0,start:25},opacity:1};
74
dojo.style(n,_3,"relative");
75
dojo.style(this._roller,_3,"absolute");
76
dojo.mixin(this,{_anim:{"in":dojo.animateProperty({node:n,duration:this.durationIn,properties:_4}),"out":dojo.fadeOut({node:n,duration:this.durationOut})}});
77
this._setupConnects();
78
}});
79
dojo.declare("dojox.widget._RollerHover",null,{postCreate:function(){
80
this.inherited(arguments);
81
this.connect(this.domNode,"onmouseenter","stop");
82
this.connect(this.domNode,"onmouseleave","start");
83
}});
84
}