loukmanebabakhalil / prototype-carousel

Automatically exported from code.google.com/p/prototype-carousel
0 stars 0 forks source link

Start with certain slide #40

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
First of all thank you for this great script.

Is it possible to start with another slide than the first one? 

I would like to use it for a html form wich is seperated to different slides.

If you hit a submit button on a certain slide the page should reload and go to 
this slide again.

Hope you know what I mean. 

Greatings

LapisInfernfalis

Original issue reported on code.google.com by spasemac...@googlemail.com on 24 Jul 2011 at 5:30

GoogleCodeExporter commented 8 years ago
Yes! Thanks for the great script. But i would like to have something similiar 
as suggested by LaposInfernafalis. It would be great if you could pass a 
variable dynamically that indicates what slide to start with.
G

Original comment by sventro...@gmail.com on 14 Sep 2011 at 5:49

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I have found a workaround for this problem.

I have tabs like this:
<a href="javascript:" rel="tab-1" class="carousel-jumper" id="slide1">Slide 
1</a>
<a href="javascript:" rel="tab-2" class="carousel-jumper carousel-selected" 
id="slide2">Slide 2</a>
<a href="javascript:" rel="tab-3" class="carousel-jumper" id="slide3">Slide 
3</a>

From line 68 on, I have replaced the "if (this.options.initial) {"-condition in 
carousel.js with the following code:

var tab = 'tab-1';
if(document.getElementById("slide1").className == 'carousel-jumper 
carousel-selected') { tab = document.getElementById("slide1").rel };
if(document.getElementById("slide2").className == 'carousel-jumper 
carousel-selected') { tab = document.getElementById("slide2").rel };
if(document.getElementById("slide3").className == 'carousel-jumper 
carousel-selected') { tab = document.getElementById("slide3").rel };
this.options.duration = 0;
this.moveTo(tab);
this.options.duration = 1;

Hope that helps!
-Christian Gersch

Original comment by use...@christian-gersch.de on 23 Sep 2011 at 3:42

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Thanks Christian! I'm totally not into Prototype but wouldn't it be much easier 
to do something like this in prototype:

Get the element of the ID of the Slide that has the classname 
'carousel-selected' and then set the variable tab to this Element? so you don't 
need to create an if statement for all your slides.

Maybe we could use getElementByClassName or just an .hasClassname 
carousel-selected...

Original comment by sventro...@gmail.com on 26 Sep 2011 at 12:44