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) {
35 this.slides[0].setVisibilityMode(Roo.Element.DISPLAY);
36 this.slides[0].show();
41 this.playButton = Roo.get(this.playButton);
42 this.pauseButton = Roo.get(this.pauseButton);
43 this.counter = Roo.get(this.counter);
44 this.caption = Roo.get(this.caption);
45 if ( this.autostart ) {
46 this.startSlideShow();
50 Roo.apply(Roo.ux.Slideshow.prototype, {
57 * @cfg {Array} of slides
61 * @cfg id/dom element counter to show the
65 * @cfg id/dom element of the caption.
69 * @cfg id/dom element for play button
73 * @cfg id/dom element of the pause button
80 swapImage: function (x,y) {
81 if (this.slides[x] ) {
82 this.slides[x].animate(
83 { opacity : { from : 0.0, to : 1.0 }},
86 this.slides[x].show();
88 if (this.slides[y] ) {
89 this.slides[y].animate(
90 { opacity : { from : 1.0, to : 0.0 }},
93 this.slides[y].show();
98 // the onload event handler that starts the fading.
99 startSlideShow: function () {
102 this.playButton && this.playButton.hide();
103 this.pauseButton && this.pauseButton.show();
105 this.updatecounter();
106 this.slides[0].setStyle({ opacity : 1.0 });
107 this.slides[0].show();
108 this.play.defer(this.wait, this);
113 var imageShow, imageHide;
115 imageShow = this.iImageId+1;
116 imageHide = this.iImageId;
118 if (imageShow+1 > this.slides.length) {
119 this.swapImage(0,imageHide);
123 this.swapImage(imageShow,imageHide);
127 this.textIn = this.iImageId+1 + ' of ' + this.numOfImages;
128 this.updatecounter();
131 this.play.defer(this.wait, this);
137 this.running = false;
138 this.playButton && this.playButton.show();
139 this.pauseButton && this.pauseButton.hide();
142 goNext: function () {
143 clearInterval(this.play);
144 $(this.playButton).appear({ duration: 0});
145 $(this.pauseButton).hide();
147 var imageShow, imageHide;
149 imageShow = this.iImageId+1;
150 imageHide = this.iImageId;
152 if (imageShow == this.numOfImages) {
153 this.swapImage(0,imageHide);
156 this.swapImage(imageShow,imageHide);
160 this.updatecounter();
163 goPrevious: function () {
164 clearInterval(this.play);
165 $(this.playButton).appear({ duration: 0});
166 $(this.pauseButton).hide();
168 var imageShow, imageHide;
170 imageShow = this.iImageId-1;
171 imageHide = this.iImageId;
173 if (this.iImageId == 0) {
174 this.swapImage(this.numOfImages-1,imageHide);
175 this.iImageId = this.numOfImages-1;
177 //alert(NumOfImages-1 + ' and ' + imageHide + ' i=' + i)
180 this.swapImage(imageShow,imageHide);
183 //alert(imageShow + ' and ' + imageHide)
186 this.updatecounter();
189 updatecounter: function () {
193 var textIn = this.iImageId+1 + ' of ' + this.numOfImages;
194 this.counter.update( textIn );
195 var oNewCaption = this.slides[this.iImageId].select('.image-caption', true);
196 if ( this.caption && oNewCaption.length ) {
197 this.caption.update( oNewCaption[0].innerHTML);