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 if ( this.autostart ) {
36 this.startSlideShow();
40 Roo.apply(Roo.ux.Slideshow.prototype, {
48 * @config id/dom element counter to show the
53 * @config id/dom element for play button
57 * @config id/dom element of the pause button
64 swapImage: function (x,y) {
65 if (this.slides[x] ) {
66 this.slides[x].animate(
67 { opacity : { from : 0.0, to : 1.0 }},
70 this.slides[x].show();
72 if (this.slides[y] ) {
73 this.slides[y].animate(
74 { opacity : { from : 1.0, to : 0.0 }},
77 this.slides[y].show();
82 // the onload event handler that starts the fading.
83 startSlideShow: function () {
85 window.setInterval(function () {
86 _t.play() }, this.wait);
88 this.playButton && this.playButton.hide();
89 this.pauseButton && this.pauseButton.show();
97 var imageShow, imageHide;
99 imageShow = this.iImageId+1;
100 imageHide = this.iImageId;
102 if (imageShow == this.numOfImages) {
103 this.swapImage(0,imageHide);
106 this.swapImage(imageShow,imageHide);
110 this.textIn = this.iImageId+1 + ' of ' + this.numOfImages;
111 this.updatecounter();
115 clearInterval(this.play);
116 this.playButton && this.playButton.appear({ duration: 0});
117 this.pauseButton && this.pauseButton.hide();
120 goNext: function () {
121 clearInterval(this.play);
122 $(this.playButton).appear({ duration: 0});
123 $(this.pauseButton).hide();
125 var imageShow, imageHide;
127 imageShow = this.iImageId+1;
128 imageHide = this.iImageId;
130 if (imageShow == this.numOfImages) {
131 this.swapImage(0,imageHide);
134 this.swapImage(imageShow,imageHide);
138 this.updatecounter();
141 goPrevious: 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 (this.iImageId == 0) {
152 this.swapImage(this.numOfImages-1,imageHide);
153 this.iImageId = this.numOfImages-1;
155 //alert(NumOfImages-1 + ' and ' + imageHide + ' i=' + i)
158 this.swapImage(imageShow,imageHide);
161 //alert(imageShow + ' and ' + imageHide)
164 this.updatecounter();
167 updatecounter: function () {
169 var textIn = this.iImageId+1 + ' of ' + this.numOfImages;
170 $(this.counter) && ( $(this.counter).innerHTML = textIn );
171 if ( $(this.caption) && ( oNewCaption = $(this.slides[this.iImageId]).down('.image-caption') ) ) {
172 $(this.caption).innerHTML = oNewCaption.innerHTML;