Posted by naught101 on July 10, 2009 at 5:49am
| Project: | Views Slideshow |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | naught101 |
| Status: | closed (fixed) |
| Issue tags: | splash page |
Issue Summary
It would be good to be able to set different behaviours at the end of slideshow loops:
* only run through once, and stop permanently at the last slide.
* set a different wait time for the last slide (ie. longer).
* re-direct to a different link.
These features would be especially useful for creating front-page splash-screen-like slideshows: create a custom sequence of nodes, and end on the front page, or re-direct to the front page, or quickly loop through some images, and end on a node where the user can choose where to go, then if the page is idle for too long, re-start the loop.
Comments
#1
I'm keen to have a go at this. I'm not averse to some php hacking. I'm not very familiar with javascript, but I can give it a go. I'm not sure where to start, really, and would like some pointers. If Views_Slideshow people want this feature, I'd be happy to provide a patch.
I'm thinking of storing 3 variables:
1. views_slideshow_last_behaviour - normal/stop/wait/wait then redirect.
2. views_slideshow_last_wait - wait time in milliseconds.
3. views_slideshow_last_url - url to redirect to.
I guess the logic in the javascript would then run:
If not last slide:go to next slide
else:
if behaviour == stop:
break
elif behaviour == wait and redirect && url not empty:
wait for wait length
redirect to url
elif behaviour == wait:
wait for wait length
go to next slide
else (assume behaviour == normal):
go to next slide
#2
It would be good if you could set the number of cycles that the slideshow should display. This would be very useful when displayed on the homepage of a website where you want it only to cycle once.
If you are up to it do make a patch and if it works well hopefully it will get integrated into the next version!
#3
hozt: When you say "number of cycles", would the be any situation where you would use a specific number of cycles other than 1? I mean, I can't think of a reason for looping twice, or three times. I think "loop" and "don't loop" (and maybe then do something else) would be the only required options.
#4
Have a go at this beast. It works for me. Haven't tried many variations on the URL yet, and it'd be good to somehow use the baseURL for sites in a subdirectory, but I'm not sure how to do that.
patch is based on 6.x-1.x-beta2
#5
This worked a treat for me, just what I was looking for! Thanks good work naught101.
This should be incorporated in to the next release.
#6
Note, that I think there's a minor error: the Wait time is currently set to loop time+wait time, when it should just be wait time (I think). In otherwords,if you use "wait", the last slide waits for (2*looptime)+waittime.
remove "slideshow_data[slideshow_main]._timer_delay + " from the first else if to fix.
#7
Naught101: Can you reroll this using 6.x-2.x-dev. Also change the spellings to American English spellings. So behaviour would be behavior, etc.
#8
Bumping version
#9
Any chance of a patch for 2.x?
This is a great addition...
#10
hrm... wtf happened to js/views_slideshow.js ? this might take a bit..
#11
Ok, I'm getting there slowly... just looking at http://malsup.com/jquery/cycle/options.html , I see that there's already an auto-stop option in the cycle plugin, however there's no options for a delay on the last slide (only on the first), and there's no option for a redirect after the last slide.
I'm wondering if this should now become a feature request for the jQuery Cycle Plugin? I can imagine there might be a few situations outside of drupal where these features might be useful. Or does it make sense to get this working in drupal, and then push it back up into the Cycle plugin?
#12
http://github.com/malsup/cycle/issues/#issue/5
Will wait and see...
#13
Huh.. ok, this is basically already implemented in the Cycle plugin, using the
timeoutFnfunction to create a manual set of timeouts for the slideshow, and then using custom javascript in theendfunction withautostopto redirect the browser elsewhere.I'll see what I can do...
#14
Ok, done, and much easier this time. The code definitely needs review - I'm not sure whether the functions are in the right place in the js file, I'm not familiar with drupal JS coding style (if there is one).
should apply cleanly against the latest 2.x dev release
#15
Just a quick look. American english spellings still. behaviour -> behavior. Don't know when I can fully test. Thanks for keeping up.
#16
Since there hasn't been a new dev release since the patch, this should still work. Spelling changed to aAmerican.
#17
It's looking pretty good. I like this change a whole lot.
Here are some changes. Have a look here for drupals coding standards: http://drupal.org/coding-standards
+++ sites/all/modules/views_slideshow/contrib/views_slideshow_singleframe/views_slideshow.js 2009-12-18 19:44:03.000000000 +1100@@ -13,6 +13,21 @@ Drupal.behaviors.viewsSlideshowSingleFra
+ for (i=0; i < timeouts.length; ++i) {
+ if (i == timeouts.length - 1) {
+ timeouts[i] = parseInt(settings.timeout) + parseInt(settings.end_delay);
+ }
Here you can see you are only using one space to indent the timeouts below the if.
+++ sites/all/modules/views_slideshow/contrib/views_slideshow_singleframe/views_slideshow.js 2009-12-18 19:44:03.000000000 +1100@@ -121,6 +148,11 @@ Drupal.behaviors.viewsSlideshowSingleFra
+function addDelayOnLastSlide(currElement, nextElement, opts, isForward) {
+ var index = opts.currSlide;
+ return timeouts[index];
Here you have a 4 space indent.
+++ sites/all/modules/views_slideshow/contrib/views_slideshow_singleframe/views_slideshow_singleframe.views_slideshow.inc 2009-12-18 19:44:49.000000000 +1100@@ -26,6 +26,9 @@ function views_slideshow_singleframe_vie
+ 'end_behavior' => array('default' => 'normal'),
Let's change this to replay instead of normal
+++ sites/all/modules/views_slideshow/contrib/views_slideshow_singleframe/views_slideshow_singleframe.views_slideshow.inc 2009-12-18 19:44:49.000000000 +1100@@ -169,6 +172,31 @@ function views_slideshow_singleframe_vie
+ $options = array(
+ 'normal' => t('Normal'),
+ 'wait' => t('Wait'),
Let's change Normal here too, to Replay
+++ sites/all/modules/views_slideshow/contrib/views_slideshow_singleframe/views_slideshow_singleframe.views_slideshow.inc 2009-12-18 19:44:49.000000000 +1100@@ -169,6 +172,31 @@ function views_slideshow_singleframe_vie
+ '#description' => t('Behavior at end of loop. Normal loops back to the start, Wait waits for the time specified below, Stop stops the slideshow, Redirect waits and then sends the user to the specified URL.')
Let's change this line to:
Behavior when the slideshow finishes the first loop. <br /><strong>Replay:</strong> Starts the slideshow over from the beginning. <br /><strong>Wait:</strong> Wait for the specified timeout before starting the slideshow over. <br /> <strong>Stop:</strong> Stops the slideshow. <br /><strong>Redirect:</strong> Waits the specified timeout period then redirects the user to the specified URL.Powered by Dreditor.
#18
Ok, will re-do that stuff. Perhaps "Loop" would be better than "Replay"? That's the standard terminology in audio and video editing, and I've seen at least a few slideshow applications that use it...
#19
I asked on #drupal and people seemed to like replay. Loop seems technical to me and if possible I'd like to stay away from technical terms as much as possible. Thanks
#20
Ok, I'll disagree, but not dissent on that one :)
Your suggestions applied, and more indenting fixed
#21
subscribe.
#22
Patch fails here :
patch: **** malformed patch at line 102: + );New version attached.
#23
Does this also provide a way to hide the "next" and "previous" menu items in the pager when the slideshow is on the first and last slides? I assume this would happen if the cycle is set to stop at the last slide, etc. (re: nowrap: 0 and then hide the link / reappear when not on last slide, etc)
#24
I'm going to take this one a little slow. This first patch adds the ability to choose if the slideshow starts over on the last slide or stops. Please review and tell me if you have any problems.
#25
The patch in #24 is committed. I will open up a new issue for the other ones, but postpone it to a future release.
#26
Here is the new issue #773624: Add additional end of loop options
#27
Automatically closed -- issue fixed for 2 weeks with no activity.