diff --git a/carousel.js b/carousel.js index b9d14a6..30681a7 100644 --- a/carousel.js +++ b/carousel.js @@ -68,7 +68,11 @@ Carousel = Class.create(Abstract, { this.start(); } if (this.options.initial) { - var initialIndex = this.slides.indexOf($(this.options.initial)); + if (this.options.initial == 'last') { + var initialIndex = this.slides.length - 1; + } else { + var initialIndex = this.slides.indexOf($(this.options.initial)); + } if (initialIndex > (this.options.visibleSlides - 1) && this.options.visibleSlides > 1) { if (initialIndex > this.slides.length - (this.options.visibleSlides + 1)) { initialIndex = this.slides.length - this.options.visibleSlides; @@ -102,11 +106,29 @@ Carousel = Class.create(Abstract, { event.stop(); }, + toggleJumpers: function (slide) { + + buttons = $$('.'+this.options.jumperClassName) + + selectedClassName = this.options.selectedClassName; + + buttons.each(function (button) { + if (button.rel == slide.id) { + button.addClassName(selectedClassName); + } else { + button.removeClassName(selectedClassName); + } + }); + + }, + moveTo: function (element) { if (this.options.beforeMove && (typeof this.options.beforeMove == 'function')) { this.options.beforeMove(); } + this.toggleJumpers(element); + this.previous = this.current ? this.current : this.slides[0]; this.current = $(element); @@ -380,4 +402,4 @@ Object.extend(Object.extend(Effect.SmoothScroll.prototype, Effect.Base.prototype this.element.scrollLeft = this.options.x * position + this.originalLeft; this.element.scrollTop = this.options.y * position + this.originalTop; } -}); \ No newline at end of file +});