77 this.items = params.items;
78 this.mode = params.mode ||
'horizontal';
79 this.modes = {horizontal:[
'left',
'width'], vertical:[
'top',
'height']};
80 this.size = params.size || 240;
81 this.box = params.box.setStyle(this.modes[this.mode][1],(this.size*this.items.length)+
'px');
82 this.button_event = params.button_event ||
'click';
83 this.handle_event = params.handle_event ||
'click';
84 this.onButtons = params.onButtons ||
null;
85 this.onWalk = params.onWalk ||
null;
86 this.currentIndex =
null;
87 this.previousIndex =
null;
88 this.nextIndex =
null;
89 this.interval = params.interval || 5000;
90 this.autoPlay = params.autoPlay ||
false;
92 this.handles = params.handles ||
null;
94 this.addHandleButtons(this.handles);
104 if(params.addButtons){
105 for(var action in params.addButtons){
106 this.addActionButtons(action,
$type(params.addButtons[action])==
'array' ? params.addButtons[action] : [params.addButtons[action]]);
109 this.fx =
new Fx.Tween(this.box,
$extend((params.fxOptions||{
duration:500,wait:
false}),{
property:this.modes[this.mode][0]}));
110 this.walk((params.startItem||0),
true,
true);
113 addHandleButtons:
function(handles){
114 for(var
i=0;
i<handles.length;
i++){
115 handles[
i].addEvent(this.handle_event,this.walk.bind(
this,[
i,
true]));
119 addActionButtons:
function(action,buttons){
120 for(var
i=0;
i<buttons.length;
i++){
122 case 'previous': buttons[
i].addEvent(this.button_event,this.previous.bind(
this,[
true]));
break;
123 case 'next': buttons[
i].addEvent(this.button_event,this.
next.bind(
this,[
true]));
break;
124 case 'play': buttons[
i].addEvent(this.button_event,this.play.bind(
this,[
this.interval,
'next',
false]));
break;
125 case 'playback': buttons[
i].addEvent(this.button_event,this.play.bind(
this,[
this.interval,
'previous',
false]));
break;
126 case 'stop': buttons[
i].addEvent(this.button_event,this.
stop.bind(
this));
break;
127 case 'playpause': buttons[
i].addEvent(this.button_event,this.playpause.bind(
this,[
this.interval,
'next']));
break;
129 this.buttons[action].push(buttons[
i]);
134 for (var commands in this.buttons) {
135 for (var button in commands) {
136 button.removeEvents();
141 previous:
function(manual){
142 this.walk((this.currentIndex>0 ? this.currentIndex-1 : this.items.length-1),
false);
145 next:
function(manual){
146 this.walk((this.currentIndex<this.items.length-1 ?
this.currentIndex+1 : 0),
false);
149 play:
function(interval,direction,wait){
150 this.isPlaying =
true;
153 this[direction](
false);
155 this._play =
this[direction].periodical(interval,
this,[
false]);
158 playpause:
function(interval,direction) {
159 if (this.isPlaying) {
161 this.isPlaying =
false;
163 this._play =
this[direction].periodical(interval,
this,[
false]);
164 this.isPlaying =
true;
167 if (this.onButtons) {
168 this.onButtons(
"playpause", this.isPlaying);
176 gotoSlide:
function(index) {
178 this.walk(index,
true,
true);
181 walk:
function(item,manual,noFx){
182 if(item!=this.currentIndex){
183 this.currentIndex=item;
184 if (this.currentIndex < 0)
185 this.currentIndex = 0;
187 this.previousIndex = this.currentIndex + (this.currentIndex>0 ? -1 : this.items.length-1);
188 this.nextIndex = this.currentIndex + (this.currentIndex<this.items.length-1 ? 1 : 1-this.items.length);
193 this.fx.cancel().set((this.size*-this.currentIndex)+
'px');
195 this.fx.start(0-this.items[this.currentIndex].el.offsetLeft);
197 if(manual && this.autoPlay){
198 this.play(this.interval,
'next',
true);
201 this.onWalk((this.items[this.currentIndex] ||
null), (this.handles && this.handles[this.currentIndex] ? this.handles[this.currentIndex] :
null));
function stop(ch, cx, status, data)
_getSelectedPageStyle s i