1 //<script type="text/javascript">
3 * Slideshow - based on a prototype one..
8 Roo.ux.Slideshow = function(cfg ) {
11 this.numOfImages = this.slides.length;
12 if ( !this.numOfImages ) {
16 this.playButton = Roo.get(this.playButton);
17 this.pauseButton = Roo.get(this.pauseButton);
18 if ( this.autostart ) {
19 this.startSlideShow();
22 Roo.apply(Roo.ux.Slideshow.prototype, {
37 swapImage: function (x,y) {
38 $(this.slides[x]) && $(this.slides[x]).appear({ duration: this.duration });
39 $(this.slides[y]) && $(this.slides[y]).fade({duration: this.duration });
42 // the onload event handler that starts the fading.
43 startSlideShow: function () {
45 window.setInterval(function () {
46 _t.play() },this.wait);
47 this.playButton && this.playButton.hide();
48 this.pauseButton && this.pauseButton.appear({ duration: 0});
56 var imageShow, imageHide;
58 imageShow = this.iImageId+1;
59 imageHide = this.iImageId;
61 if (imageShow == this.numOfImages) {
62 this.swapImage(0,imageHide);
65 this.swapImage(imageShow,imageHide);
69 this.textIn = this.iImageId+1 + ' of ' + this.numOfImages;
74 clearInterval(this.play);
75 this.playButton && this.playButton.appear({ duration: 0});
76 this.pauseButton && this.pauseButton.hide();
80 clearInterval(this.play);
81 $(this.playButton).appear({ duration: 0});
82 $(this.pauseButton).hide();
84 var imageShow, imageHide;
86 imageShow = this.iImageId+1;
87 imageHide = this.iImageId;
89 if (imageShow == this.numOfImages) {
90 this.swapImage(0,imageHide);
93 this.swapImage(imageShow,imageHide);
100 goPrevious: function () {
101 clearInterval(this.play);
102 $(this.playButton).appear({ duration: 0});
103 $(this.pauseButton).hide();
105 var imageShow, imageHide;
107 imageShow = this.iImageId-1;
108 imageHide = this.iImageId;
110 if (this.iImageId == 0) {
111 this.swapImage(this.numOfImages-1,imageHide);
112 this.iImageId = this.numOfImages-1;
114 //alert(NumOfImages-1 + ' and ' + imageHide + ' i=' + i)
117 this.swapImage(imageShow,imageHide);
120 //alert(imageShow + ' and ' + imageHide)
123 this.updatecounter();
126 updatecounter: function () {
127 var textIn = this.iImageId+1 + ' of ' + this.numOfImages;
128 $(this.counter) && ( $(this.counter).innerHTML = textIn );
129 if ( $(this.caption) && ( oNewCaption = $(this.slides[this.iImageId]).down('.image-caption') ) ) {
130 $(this.caption).innerHTML = oNewCaption.innerHTML;
134 Event.observe(window, 'load', function(){
135 if ($$('.category-slide').length < 2) {
136 if (!$$('.category-slide').length) {
139 $$('.category-slide')[0].appear( { duration : 1 });
142 oMySlides = new iSlideShow({
143 autostart : true, // optional, boolean (default:true)
144 start : 0, // optional, slides[start] (default:0)
145 wait : 4000, // optional, milliseconds (default:4s)
146 slides : $$('.category-slide'),
147 counter : 'counter-div-id', // optional...
148 caption : 'caption-div-id', // optional...
149 playButton : 'PlayButton', // optional (default:playButton)
150 pauseButton : 'PauseButton', // optional (default:PauseButton)
152 $$('.category-slide')[0].appear( { duration : 1 });
153 // oMySlides.startSlideShow();