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);
87 this.playButton && this.playButton.hide();
88 this.pauseButton && this.pauseButton.appear({ duration: 0});
96 var imageShow, imageHide;
98 imageShow = this.iImageId+1;
99 imageHide = this.iImageId;
101 if (imageShow == this.numOfImages) {
102 this.swapImage(0,imageHide);
105 this.swapImage(imageShow,imageHide);
109 this.textIn = this.iImageId+1 + ' of ' + this.numOfImages;
110 this.updatecounter();
114 clearInterval(this.play);
115 this.playButton && this.playButton.appear({ duration: 0});
116 this.pauseButton && this.pauseButton.hide();
119 goNext: function () {
120 clearInterval(this.play);
121 $(this.playButton).appear({ duration: 0});
122 $(this.pauseButton).hide();
124 var imageShow, imageHide;
126 imageShow = this.iImageId+1;
127 imageHide = this.iImageId;
129 if (imageShow == this.numOfImages) {
130 this.swapImage(0,imageHide);
133 this.swapImage(imageShow,imageHide);
137 this.updatecounter();
140 goPrevious: function () {
141 clearInterval(this.play);
142 $(this.playButton).appear({ duration: 0});
143 $(this.pauseButton).hide();
145 var imageShow, imageHide;
147 imageShow = this.iImageId-1;
148 imageHide = this.iImageId;
150 if (this.iImageId == 0) {
151 this.swapImage(this.numOfImages-1,imageHide);
152 this.iImageId = this.numOfImages-1;
154 //alert(NumOfImages-1 + ' and ' + imageHide + ' i=' + i)
157 this.swapImage(imageShow,imageHide);
160 //alert(imageShow + ' and ' + imageHide)
163 this.updatecounter();
166 updatecounter: function () {
168 var textIn = this.iImageId+1 + ' of ' + this.numOfImages;
169 $(this.counter) && ( $(this.counter).innerHTML = textIn );
170 if ( $(this.caption) && ( oNewCaption = $(this.slides[this.iImageId]).down('.image-caption') ) ) {
171 $(this.caption).innerHTML = oNewCaption.innerHTML;