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', true);
13 oMySlides = new Roo.ux.Slideshow({
20 * @class Roo.ux.Slideshow
22 Roo.namespace('Roo.ux');
24 Roo.ux.Slideshow = function(cfg )
29 this.numOfImages = this.slides.length;
30 if ( !this.numOfImages ) {
31 // alert('No slides?');
34 if (this.slides.length == 1) {
38 this.playButton = Roo.get(this.playButton);
39 this.pauseButton = Roo.get(this.pauseButton);
40 this.counter = Roo.get(this.counter);
41 this.caption = Roo.get(this.caption);
42 if ( this.autostart ) {
43 this.startSlideShow();
47 Roo.apply(Roo.ux.Slideshow.prototype, {
54 * @cfg {Array} of slides
58 * @cfg id/dom element counter to show the
62 * @cfg id/dom element of the caption.
66 * @cfg id/dom element for play button
70 * @cfg id/dom element of the pause button
77 swapImage: function (x,y) {
78 if (this.slides[x] ) {
79 this.slides[x].animate(
80 { opacity : { from : 0.0, to : 1.0 }},
83 this.slides[x].show();
85 if (this.slides[y] ) {
86 this.slides[y].animate(
87 { opacity : { from : 1.0, to : 0.0 }},
90 this.slides[y].show();
95 // the onload event handler that starts the fading.
96 startSlideShow: function () {
99 this.playButton && this.playButton.hide();
100 this.pauseButton && this.pauseButton.show();
102 this.updatecounter();
108 var imageShow, imageHide;
110 imageShow = this.iImageId+1;
111 imageHide = this.iImageId;
113 if (imageShow == this.numOfImages) {
114 this.swapImage(0,imageHide);
118 this.swapImage(imageShow,imageHide);
122 this.textIn = this.iImageId+1 + ' of ' + this.numOfImages;
123 this.updatecounter();
124 if (this.images.length == 1) {
128 this.play.defer(this.wait, this);
134 this.running = false;
135 this.playButton && this.playButton.show();
136 this.pauseButton && this.pauseButton.hide();
139 goNext: function () {
140 clearInterval(this.play);
141 $(this.playButton).appear({ duration: 0});
142 $(this.pauseButton).hide();
144 var imageShow, imageHide;
146 imageShow = this.iImageId+1;
147 imageHide = this.iImageId;
149 if (imageShow == this.numOfImages) {
150 this.swapImage(0,imageHide);
153 this.swapImage(imageShow,imageHide);
157 this.updatecounter();
160 goPrevious: function () {
161 clearInterval(this.play);
162 $(this.playButton).appear({ duration: 0});
163 $(this.pauseButton).hide();
165 var imageShow, imageHide;
167 imageShow = this.iImageId-1;
168 imageHide = this.iImageId;
170 if (this.iImageId == 0) {
171 this.swapImage(this.numOfImages-1,imageHide);
172 this.iImageId = this.numOfImages-1;
174 //alert(NumOfImages-1 + ' and ' + imageHide + ' i=' + i)
177 this.swapImage(imageShow,imageHide);
180 //alert(imageShow + ' and ' + imageHide)
183 this.updatecounter();
186 updatecounter: function () {
190 var textIn = this.iImageId+1 + ' of ' + this.numOfImages;
191 this.counter.update( textIn );
192 var oNewCaption = this.slides[this.iImageId].select('.image-caption', true);
193 if ( this.caption && oNewCaption.length ) {
194 this.caption.update( oNewCaption[0].innerHTML);