From 9bb7c08b0c1beb668d512d9c6c58ff8910c113f0 Mon Sep 17 00:00:00 2001 From: Maxim Date: Sat, 25 Jun 2011 01:49:34 +0300 Subject: [PATCH 1/2] Switch class names on jumper buttons when clicked prev/nex/last/first --- carousel.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/carousel.js b/carousel.js index b9d14a6..0c1fed1 100644 --- a/carousel.js +++ b/carousel.js @@ -102,11 +102,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 +398,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 +}); From 36ff888adb9b7c0cdbd6fd5c0bd542d6ae84ce91 Mon Sep 17 00:00:00 2001 From: Maxim Date: Sat, 25 Jun 2011 03:01:44 +0300 Subject: [PATCH 2/2] can use 'last' as initial --- carousel.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/carousel.js b/carousel.js index 0c1fed1..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;