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 $(this.slides[x]) && $(this.slides[x]).appear({ duration: this.duration });
66 $(this.slides[y]) && $(this.slides[y]).fade({duration: this.duration });
69 // the onload event handler that starts the fading.
70 startSlideShow: function () {
72 window.setInterval(function () {
73 _t.play() },this.wait);
74 this.playButton && this.playButton.hide();
75 this.pauseButton && this.pauseButton.appear({ duration: 0});
83 var imageShow, imageHide;
85 imageShow = this.iImageId+1;
86 imageHide = this.iImageId;
88 if (imageShow == this.numOfImages) {
89 this.swapImage(0,imageHide);
92 this.swapImage(imageShow,imageHide);
96 this.textIn = this.iImageId+1 + ' of ' + this.numOfImages;
101 clearInterval(this.play);
102 this.playButton && this.playButton.appear({ duration: 0});
103 this.pauseButton && this.pauseButton.hide();
106 goNext: function () {
107 clearInterval(this.play);
108 $(this.playButton).appear({ duration: 0});
109 $(this.pauseButton).hide();
111 var imageShow, imageHide;
113 imageShow = this.iImageId+1;
114 imageHide = this.iImageId;
116 if (imageShow == this.numOfImages) {
117 this.swapImage(0,imageHide);
120 this.swapImage(imageShow,imageHide);
124 this.updatecounter();
127 goPrevious: function () {
128 clearInterval(this.play);
129 $(this.playButton).appear({ duration: 0});
130 $(this.pauseButton).hide();
132 var imageShow, imageHide;
134 imageShow = this.iImageId-1;
135 imageHide = this.iImageId;
137 if (this.iImageId == 0) {
138 this.swapImage(this.numOfImages-1,imageHide);
139 this.iImageId = this.numOfImages-1;
141 //alert(NumOfImages-1 + ' and ' + imageHide + ' i=' + i)
144 this.swapImage(imageShow,imageHide);
147 //alert(imageShow + ' and ' + imageHide)
150 this.updatecounter();
153 updatecounter: function () {
155 var textIn = this.iImageId+1 + ' of ' + this.numOfImages;
156 $(this.counter) && ( $(this.counter).innerHTML = textIn );
157 if ( $(this.caption) && ( oNewCaption = $(this.slides[this.iImageId]).down('.image-caption') ) ) {
158 $(this.caption).innerHTML = oNewCaption.innerHTML;