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 () {
89 window.setInterval(function () {
90 _t.play() }, this.wait);
92 this.playButton && this.playButton.hide();
93 this.pauseButton && this.pauseButton.show();
101 var imageShow, imageHide;
103 imageShow = this.iImageId+1;
104 imageHide = this.iImageId;
106 if (imageShow == this.numOfImages) {
107 this.swapImage(0,imageHide);
110 this.swapImage(imageShow,imageHide);
114 this.textIn = this.iImageId+1 + ' of ' + this.numOfImages;
115 this.updatecounter();
119 clearInterval(this.play);
120 this.playButton && this.playButton.appear({ duration: 0});
121 this.pauseButton && this.pauseButton.hide();
124 goNext: function () {
125 clearInterval(this.play);
126 $(this.playButton).appear({ duration: 0});
127 $(this.pauseButton).hide();
129 var imageShow, imageHide;
131 imageShow = this.iImageId+1;
132 imageHide = this.iImageId;
134 if (imageShow == this.numOfImages) {
135 this.swapImage(0,imageHide);
138 this.swapImage(imageShow,imageHide);
142 this.updatecounter();
145 goPrevious: function () {
146 clearInterval(this.play);
147 $(this.playButton).appear({ duration: 0});
148 $(this.pauseButton).hide();
150 var imageShow, imageHide;
152 imageShow = this.iImageId-1;
153 imageHide = this.iImageId;
155 if (this.iImageId == 0) {
156 this.swapImage(this.numOfImages-1,imageHide);
157 this.iImageId = this.numOfImages-1;
159 //alert(NumOfImages-1 + ' and ' + imageHide + ' i=' + i)
162 this.swapImage(imageShow,imageHide);
165 //alert(imageShow + ' and ' + imageHide)
168 this.updatecounter();
171 updatecounter: function () {
175 var textIn = this.iImageId+1 + ' of ' + this.numOfImages;
176 this.counter.update( textIn );
177 var oNewCaption = this.slides[this.iImageId]).select('.image-caption', true)
178 if ( this.caption && oNewCaption.length ) {
179 this.caption.update( oNewCaption[0].innerHTML;