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) {
40 this.playButton = Roo.get(this.playButton);
41 this.pauseButton = Roo.get(this.pauseButton);
42 this.counter = Roo.get(this.counter);
43 this.caption = Roo.get(this.caption);
44 if ( this.autostart ) {
45 this.startSlideShow();
49 Roo.apply(Roo.ux.Slideshow.prototype, {
56 * @cfg {Array} of slides
60 * @cfg id/dom element counter to show the
64 * @cfg id/dom element of the caption.
68 * @cfg id/dom element for play button
72 * @cfg id/dom element of the pause button
79 swapImage: function (x,y) {
80 if (this.slides[x] ) {
81 this.slides[x].animate(
82 { opacity : { from : 0.0, to : 1.0 }},
85 this.slides[x].show();
87 if (this.slides[y] ) {
88 this.slides[y].animate(
89 { opacity : { from : 1.0, to : 0.0 }},
92 this.slides[y].show();
97 // the onload event handler that starts the fading.
98 startSlideShow: function () {
101 this.playButton && this.playButton.hide();
102 this.pauseButton && this.pauseButton.show();
104 this.updatecounter();
110 var imageShow, imageHide;
112 imageShow = this.iImageId+1;
113 imageHide = this.iImageId;
115 if (imageShow == this.numOfImages) {
116 this.swapImage(0,imageHide);
120 this.swapImage(imageShow,imageHide);
124 this.textIn = this.iImageId+1 + ' of ' + this.numOfImages;
125 this.updatecounter();
126 if (this.images.length == 1) {
130 this.play.defer(this.wait, this);
136 this.running = false;
137 this.playButton && this.playButton.show();
138 this.pauseButton && this.pauseButton.hide();
141 goNext: function () {
142 clearInterval(this.play);
143 $(this.playButton).appear({ duration: 0});
144 $(this.pauseButton).hide();
146 var imageShow, imageHide;
148 imageShow = this.iImageId+1;
149 imageHide = this.iImageId;
151 if (imageShow == this.numOfImages) {
152 this.swapImage(0,imageHide);
155 this.swapImage(imageShow,imageHide);
159 this.updatecounter();
162 goPrevious: function () {
163 clearInterval(this.play);
164 $(this.playButton).appear({ duration: 0});
165 $(this.pauseButton).hide();
167 var imageShow, imageHide;
169 imageShow = this.iImageId-1;
170 imageHide = this.iImageId;
172 if (this.iImageId == 0) {
173 this.swapImage(this.numOfImages-1,imageHide);
174 this.iImageId = this.numOfImages-1;
176 //alert(NumOfImages-1 + ' and ' + imageHide + ' i=' + i)
179 this.swapImage(imageShow,imageHide);
182 //alert(imageShow + ' and ' + imageHide)
185 this.updatecounter();
188 updatecounter: function () {
192 var textIn = this.iImageId+1 + ' of ' + this.numOfImages;
193 this.counter.update( textIn );
194 var oNewCaption = this.slides[this.iImageId].select('.image-caption', true);
195 if ( this.caption && oNewCaption.length ) {
196 this.caption.update( oNewCaption[0].innerHTML);