/[drupal]/contributions/modules/views_slideshow/views_slideshow.js
ViewVC logotype

Contents of /contributions/modules/views_slideshow/views_slideshow.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Wed Oct 1 16:31:16 2008 UTC (13 months, 4 weeks ago) by aaron
Branch: MAIN
CVS Tags: DRUPAL-5--1-0-BETA1, HEAD
Branch point for: DRUPAL-5
Changes since 1.4: +0 -0 lines
File MIME type: text/javascript
roll back to d5 version
1 // $Id: views_slideshow.js,v 1.3 2008/03/22 18:51:00 aaron Exp $
2
3 // store the timer and current div data
4 slideshow_data = new Array();
5
6 // this stores all our static data
7 function views_slideshow_data(num_divs, timer_delay, sort_order, fade, fade_speed, fade_value) {
8 // this._divs = divs;
9 this._num_divs = num_divs;
10 this._timer_delay = timer_delay;
11 this._sort_order = sort_order;
12 this._fade = fade;
13 this._fade_speed = fade_speed;
14 this._fade_value = fade_value;
15 this._current_div = 0;
16 this._pause = false;
17 }
18
19 // set the timer on or off
20 function views_slideshow_timer(slideshow_main, slideshow_status) {
21 // stop the current timer
22 clearTimeout(slideshow_data[slideshow_main]._timer_id);
23
24 // start a new timer, if slideshow_status is true, unless we're currently paused
25 if (slideshow_status && !slideshow_data[slideshow_main]._pause) {
26 // our timer will call views_slideshow_switch, which fades out the current slide
27 slideshow_data[slideshow_main]._timer_id = setTimeout("views_slideshow_switch('" + slideshow_main + "', views_slideshow_next_div('" + slideshow_main + "'))", slideshow_data[slideshow_main]._timer_delay);
28 }
29 }
30
31 function views_slideshow_pause(slideshow_main) {
32 slideshow_data[slideshow_main]._pause = true;
33 views_slideshow_timer(slideshow_main, false);
34 }
35
36 function views_slideshow_resume(slideshow_main) {
37 slideshow_data[slideshow_main]._pause = false;
38 views_slideshow_timer(slideshow_main, true);
39 }
40
41 // fade out to the new div indicated
42 function views_slideshow_switch(slideshow_main, new_div) {
43 // get the id for the main element
44 _main_div = "#views_slideshow_main_" + slideshow_main;
45
46 // turn off our timer
47 views_slideshow_timer(slideshow_main, false);
48
49 // check to see if we fade or not
50 if (slideshow_data[slideshow_main]._fade) {
51 // fade out -- at the end, switch to the next slide in the slideshow
52 $(_main_div).fadeTo(slideshow_data[slideshow_main]._fade_speed, slideshow_data[slideshow_main]._fade_value, function() { views_slideshow_set_div(slideshow_main, new_div); });
53 }
54 else {
55 // if we don't have a fade, then just switch without fading
56 views_slideshow_set_div(slideshow_main, new_div);
57 }
58 }
59
60 // set the main div html to the new node
61 function views_slideshow_set_div(slideshow_main, new_div_number) {
62 // this is the id of the main div to change
63 _main_div = "#views_slideshow_main_" + slideshow_main;
64
65 // if the new div is greater than length, wrap to the first.
66 // if it's less than zero, wrap to the last
67 if (new_div_number >= slideshow_data[slideshow_main]._num_divs) {
68 new_div_number = 0;
69 }
70 else if (new_div_number < 0) {
71 new_div_number = slideshow_data[slideshow_main]._num_divs - 1;
72 }
73
74 // _old_breakout = "#views_slideshow_div_breakout_teaser_" + slideshow_main + "_" + slideshow_data[slideshow_main]._current_div;
75 // _new_breakout = "#views_slideshow_div_breakout_teaser_" + slideshow_main + "_" + new_div_number;
76 _old_breakout = "#views_slideshow_div_" + slideshow_main + "_" + slideshow_data[slideshow_main]._current_div;
77 _new_breakout = "#views_slideshow_div_" + slideshow_main + "_" + new_div_number;
78
79
80 // get the div with the html we need
81 _new_div = "#views_slideshow_div_" + slideshow_main + "_" + new_div_number;
82
83 // set the html of the new div
84 // $(_main_div).html($(_new_div).html());
85 // $(_old_breakout).removeClass('views_slideshow_active_teaser');
86 // $(_new_breakout).addClass('views_slideshow_active_teaser');
87
88 $(_old_breakout).hide();
89 $(_new_breakout).show();
90
91 _old_breakout = "#views_slideshow_div_breakout_teaser_" + slideshow_main + "_" + slideshow_data[slideshow_main]._current_div;
92 _new_breakout = "#views_slideshow_div_breakout_teaser_" + slideshow_main + "_" + new_div_number;
93 $(_old_breakout).removeClass('views_slideshow_active_teaser');
94 $(_new_breakout).addClass('views_slideshow_active_teaser');
95
96 // set the current_div number to the new node
97 slideshow_data[slideshow_main]._current_div = new_div_number;
98
99 // check to see if we fade or not
100 if (slideshow_data[slideshow_main]._fade) {
101 // fade in -- at the end, turn on our timer
102 $(_main_div).fadeTo(slideshow_data[slideshow_main]._fade_speed, 1, function() { views_slideshow_timer(slideshow_main, true); });
103 }
104 else {
105 // if we don't have a fade, then just turn on our timer without fading
106 views_slideshow_timer(slideshow_main, true);
107 }
108 }
109
110 // get the next node div in our sequence
111 function views_slideshow_next_div(slideshow_main) {
112 if (slideshow_data[slideshow_main]._sort_order) {
113 // select the next div, in forward or reverse order
114 new_div_number = slideshow_data[slideshow_main]._current_div + slideshow_data[slideshow_main]._sort_order;
115 }
116 else {
117 // select a random div, but make sure we don't repeat ourselves, unless there's only one div
118 do {
119 new_div_number = Math.floor(Math.random() * slideshow_data[slideshow_main]._num_divs);
120 } while (slideshow_data[slideshow_main]._num_divs > 1 && (new_div_number == slideshow_data[slideshow_main]._num_divs - 1));
121 }
122 return new_div_number;
123 }
124

  ViewVC Help
Powered by ViewVC 1.1.2