1 //<script type="text/javascript">
3 * Slideshow - based on a prototype one..
8 Roo.onReady( function()
10 // use a dom selector to define slides..
11 var slides = Roo.DomQuery.select('.category-slide');
13 oMySlides = new Roo.ux.Slideshow({
20 * @class Roo.ux.Slideshow
23 Roo.ux.Slideshow = function(cfg )
27 this.numOfImages = this.slides.length;
28 if ( !this.numOfImages ) {
32 this.playButton = Roo.get(this.playButton);
33 this.pauseButton = Roo.get(this.pauseButton);
34 this.counter = Roo.get(this.counter);
35 this.caption = Roo.get(this.caption);
36 if ( this.autostart ) {
37 this.startSlideShow();
41 Roo.apply(Roo.ux.Slideshow.prototype, {
49 * @config id/dom element counter to show the
53 * @config id/dom element of the caption.
57 * @config id/dom element for play button
61 * @config id/dom element of the pause button
68 swapImage: function (x,y) {
69 if (this.slides[x] ) {
70 this.slides[x].animate(
71 { opacity : { from : 0.0, to : 1.0 }},
74 this.slides[x].show();
76 if (this.slides[y] ) {
77 this.slides[y].animate(
78 { opacity : { from : 1.0, to : 0.0 }},
81 this.slides[y].show();
86 // the onload event handler that starts the fading.
87 startSlideShow: function () {
90 this.playButton && this.playButton.hide();
91 this.pauseButton && this.pauseButton.show();
99 var imageShow, imageHide;
101 imageShow = this.iImageId+1;
102 imageHide = this.iImageId;
104 if (imageShow == this.numOfImages) {
105 this.swapImage(0,imageHide);
109 this.swapImage(imageShow,imageHide);
113 this.textIn = this.iImageId+1 + ' of ' + this.numOfImages;
114 this.updatecounter();
116 this.play.defer(this.wait, this);
122 this.running = false;
123 this.playButton && this.playButton.appear({ duration: 0});
124 this.pauseButton && this.pauseButton.hide();
127 goNext: function () {
128 clearInterval(this.play);
129 $(this.playButton).appear({ duration: 0});
130 $(this.pauseButton).hide();
132 var imageShow, imageHide;
134 imageShow = this.iImageId+1;
135 imageHide = this.iImageId;
137 if (imageShow == this.numOfImages) {
138 this.swapImage(0,imageHide);
141 this.swapImage(imageShow,imageHide);
145 this.updatecounter();
148 goPrevious: function () {
149 clearInterval(this.play);
150 $(this.playButton).appear({ duration: 0});
151 $(this.pauseButton).hide();
153 var imageShow, imageHide;
155 imageShow = this.iImageId-1;
156 imageHide = this.iImageId;
158 if (this.iImageId == 0) {
159 this.swapImage(this.numOfImages-1,imageHide);
160 this.iImageId = this.numOfImages-1;
162 //alert(NumOfImages-1 + ' and ' + imageHide + ' i=' + i)
165 this.swapImage(imageShow,imageHide);
168 //alert(imageShow + ' and ' + imageHide)
171 this.updatecounter();
174 updatecounter: function () {
178 var textIn = this.iImageId+1 + ' of ' + this.numOfImages;
179 this.counter.update( textIn );
180 var oNewCaption = this.slides[this.iImageId]).select('.image-caption', true)
181 if ( this.caption && oNewCaption.length ) {
182 this.caption.update( oNewCaption[0].innerHTML;