Roo.onReady( function()
{
// use a dom selector to define slides..
- var slides = Roo.DomQuery.select('.category-slide');
+ var slides = Roo.DomQuery.select('.category-slide', true);
oMySlides = new Roo.ux.Slideshow({
slides : slides,
*
* @class Roo.ux.Slideshow
*/
+Roo.namespace('Roo.ux');
Roo.ux.Slideshow = function(cfg )
{
Roo.apply(this, cfg);
- if ( this.slides ) {
- this.numOfImages = this.slides.length;
- if ( !this.numOfImages ) {
- alert('No slides?');
- }
+ if ( !this.slides || !this.slides.length) {
+ return;
+ }
+ if (this.slides.length == 1) {
+ this.slides[0].setVisibilityMode(Roo.Element.DISPLAY);
+ this.slides[0].show();
+ return;
+
}
+
this.playButton = Roo.get(this.playButton);
this.pauseButton = Roo.get(this.pauseButton);
this.counter = Roo.get(this.counter);
Roo.apply(Roo.ux.Slideshow.prototype, {
- wait : 4000
- start : 0
- duration : 0.5,
+ wait : 4000,
+ start : 0,
+ duration : 1,
autostart : true ,
/**
* @cfg {Array} of slides
*/
pauseButton : false,
iImageId : 0,
- running : false;
+ running : false,
// The Fade Function
swapImage: function (x,y) {
this.pauseButton && this.pauseButton.show();
this.updatecounter();
- this.play();
+ this.slides[0].setStyle({ opacity : 1.0 });
+ this.slides[0].show();
+ this.play.defer(this.wait, this);
},
play: function () {
imageShow = this.iImageId+1;
imageHide = this.iImageId;
- if (imageShow == this.numOfImages) {
+ if (imageShow+1 > this.slides.length) {
this.swapImage(0,imageHide);
this.iImageId = 0;
this.iImageId++;
}
- this.textIn = this.iImageId+1 + ' of ' + this.numOfImages;
+ this.textIn = this.iImageId+1 + ' of ' + this.slides.length;
this.updatecounter();
+
if (this.running) {
this.play.defer(this.wait, this);
}
stop: function () {
this.running = false;
- this.playButton && this.playButton.appear({ duration: 0});
+ this.playButton && this.playButton.show();
this.pauseButton && this.pauseButton.hide();
},
-
+ /*
goNext: function () {
clearInterval(this.play);
$(this.playButton).appear({ duration: 0});
this.updatecounter();
},
-
+ */
updatecounter: function () {
if (!this.counter) {
return;
}
- var textIn = this.iImageId+1 + ' of ' + this.numOfImages;
+ var textIn = this.iImageId+1 + ' of ' + this.slides.length;
this.counter.update( textIn );
- var oNewCaption = this.slides[this.iImageId]).select('.image-caption', true)
+ var oNewCaption = this.slides[this.iImageId].select('.image-caption', true);
if ( this.caption && oNewCaption.length ) {
- this.caption.update( oNewCaption[0].innerHTML;
+ this.caption.update( oNewCaption[0].innerHTML);
}
}
-}
+});
\ No newline at end of file