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

Contents of /contributions/modules/views_slideshow/views_slideshow.module

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


Revision 1.12 - (show annotations) (download) (as text)
Wed Oct 1 16:31:16 2008 UTC (13 months, 3 weeks ago) by aaron
Branch: MAIN
CVS Tags: DRUPAL-5--1-0-BETA1, HEAD
Branch point for: DRUPAL-5
Changes since 1.11: +436 -38 lines
File MIME type: text/x-php
roll back to d5 version
1 <?php
2 // $Id: views_slideshow.module,v 1.10 2008/03/26 01:08:46 aaron Exp $
3
4 define('VIEWS_SLIDESHOW_MODE_SINGLE_FRAME', 'single_frame'); // this will rotate through all slideshows in a single div element
5 define('VIEWS_SLIDESHOW_MODE_THUMBNAIL_HOVER', 'thumbnail_hover'); // this will create thumbnails of all the node teasers, with a mouse-over triggering a larger div full node view
6 define('VIEWS_SLIDESHOW_MODE_JCAROUSEL', 'jcarousel'); // this uses the jcarousel jquery plugin, if the jcarousel module is installed
7 define('VIEWS_SLIDESHOW_DEFAULT_MODE', VIEWS_SLIDESHOW_MODE_SINGLE_FRAME);
8
9 define('VIEWS_SLIDESHOW_JCAROUSEL_SKIN_TANGO', 'tango'); // the tango skin is included, and is a css class used on the list
10 define('VIEWS_SLIDESHOW_JCAROUSEL_SKIN_DEFAULT', VIEWS_SLIDESHOW_JCAROUSEL_SKIN_TANGO);
11 define('VIEWS_SLIDESHOW_JCAROUSEL_VERTICAL_DEFAULT', FALSE);
12
13 define('VIEWS_SLIDESHOW_HOVER_BREAKOUT_TEASER', 'teaser'); // this will cause the breakout element of the 'thumbnail_hover' mode to display the larger element as a teaser. it is ignored by 'single_frame' mode.
14 define('VIEWS_SLIDESHOW_HOVER_BREAKOUT_FULL', 'full'); // this will cause the breakout element of the 'thumbnail_hover' mode to display the larger element as a full node. it is ignored by 'single_frame' mode.
15 define('VIEWS_SLIDESHOW_DEFAULT_HOVER_BREAKOUT', VIEWS_SLIDESHOW_HOVER_BREAKOUT_TEASER);
16
17 define('VIEWS_SLIDESHOW_DEFAULT_CONTROL_DISPLAY', FALSE);
18
19 define('VIEWS_SLIDESHOW_DEFAULT_TIMER_DELAY', 5000);
20
21 define('VIEWS_SLIDESHOW_SORT_FORWARD', 1);
22 define('VIEWS_SLIDESHOW_SORT_RANDOM', 0);
23 define('VIEWS_SLIDESHOW_SORT_REVERSE', -1);
24 define('VIEWS_SLIDESHOW_DEFAULT_SORT_ORDER', VIEWS_SLIDESHOW_SORT_FORWARD);
25
26 define('VIEWS_SLIDESHOW_FADE_SPEED_SLOW', 'slow');
27 define('VIEWS_SLIDESHOW_FADE_SPEED_NORMAL', 'normal');
28 define('VIEWS_SLIDESHOW_FADE_SPEED_FAST', 'fast');
29 define('VIEWS_SLIDESHOW_DEFAULT_FADE_SPEED', VIEWS_SLIDESHOW_FADE_SPEED_SLOW);
30
31 define('VIEWS_SLIDESHOW_DEFAULT_FADE_VALUE', 0.25);
32
33 define('VIEWS_SLIDESHOW_DEFAULT_FADE', TRUE);
34
35 define('VIEWS_SLIDESHOW_DEFAULT_TEASERS_LAST', TRUE); // when the mode is thumbnail hover, this determines whether to print the teasers first or second
36
37 /**
38 * Implement hook_menu
39 */
40 function views_slideshow_menu($may_cache) {
41 $items = array();
42 if ($may_cache) {
43 $items[] = array(
44 'path' => 'admin/build/views/views_slideshow',
45 'title' => t('Views slideshow configuration'),
46 'description' => t('Configure Views Slideshow: Set global options for slideshow views.'),
47 'callback' => 'drupal_get_form',
48 'callback arguments' => 'views_slideshow_settings',
49 'access' => user_access('administer site configuration'));
50 }
51 return $items;
52 }
53
54 /**
55 * Implement hook_settings
56 */
57 function views_slideshow_settings() {
58 if (!module_exists('hoverintent')) {
59 drupal_set_message(t('You may experience better performance with your slide shows if you install the !hoverintent module.', array('!hoverintent' => l(t('hoverIntent'), 'http://drupal.org/project/hoverintent'))));
60 }
61 $form = array();
62 $form['views_slideshow_default_mode'] = array(
63 '#type' => 'select',
64 '#title' => t('Global slideshow mode'),
65 '#default_value' => variable_get('views_slideshow_default_mode', VIEWS_SLIDESHOW_DEFAULT_MODE),
66 '#options' => array(VIEWS_SLIDESHOW_MODE_SINGLE_FRAME => t('single frame'), VIEWS_SLIDESHOW_MODE_THUMBNAIL_HOVER => t('thumbnail hover')),
67 '#description' => t('This will set the type of slideshow to display for views. When set as \'single frame\', a single element will be displayed, with node teasers fading and and out to the next node in order. When set as \'thumbnail hover\', all the teasers will be displayed in a list, followed by a larger element displaying the full node view -- the slideshow will either rotate through the elements using the timer, and/or with a mouse-over event.'),
68 );
69 if (module_exists('jcarousel')) {
70 $form['views_slideshow_default_mode']['#options'][VIEWS_SLIDESHOW_MODE_JCAROUSEL] = t('jcarousel');
71 $form['views_slideshow_default_mode']['#description'] .= t(' Jcarousel.');
72 $form['jcarousel'] = array(
73 '#type' => 'fieldset',
74 '#title' => t('jCarousel options'),
75 '#collapsible' => TRUE,
76 );
77 $form['jcarousel']['views_slideshow_jcarousel_skin'] = array(
78 '#type' => 'textfield',
79 '#title' => t('jCarousel skin'),
80 '#default_value' => variable_get('views_slideshow_jcarousel_skin', VIEWS_SLIDESHOW_JCAROUSEL_SKIN_DEFAULT),
81 '#description' => t('This is the skin to use when using jCarousel. If it is any other than the default of %tango, you\'ll need to create your own %skin file in a directory of that name in the %directory folder. It would need to designate a class of %class to apply to the created list, such as %sample-class in %skin in the %sample-dir folder.', array('%tango' => VIEWS_SLIDESHOW_JCAROUSEL_SKIN_DEFAULT, '%skin' => 'skin.css', '%directory' => drupal_get_path('module', 'jcarousel') ."/skins/[SKIN]", '%class' => '.jcarousel-skin-[SKIN]', '%sample-class' => '.jcarousel-skin-tango', '%sample-dir' => drupal_get_path('module', 'jcarousel') ."/skins/tango")),
82 );
83 $form['jcarousel']['views_slideshow_jcarousel_vertical'] = array(
84 '#type' => 'checkbox',
85 '#title' => t('jCarousel vertical slideshow'),
86 '#default_value' => variable_get('views_slideshow_jcarousel_vertical', VIEWS_SLIDESHOW_JCAROUSEL_VERTICAL_DEFAULT),
87 '#description' => t('If checked, a slideshow will be shown vertically, when using jCarousel.'),
88 );
89 }
90 else {
91 $form['jcarousel'] = array(
92 '#type' => 'item',
93 '#title' => t('jCarousel slideshow'),
94 '#description' => t('If you have the !jcarousel module installed, you will have more slideshow options available, such as buttons, vertical slideshows, and skins. All these options are available anyway, although may require some customization. The !jcarousel module simply offers more functionality out of the box.', array('!jcarousel' => l(t('jCarousel'), 'http://drupal.org/project/jcarousel'))),
95 );
96 }
97 // TODO: remove this when/if jcarousel support is added. also add instructions to developer
98 unset($form['jcarousel']);
99 $form['views_slideshow_default_hover_breakout'] = array(
100 '#type' => 'select',
101 '#title' => t('Global hover breakout'),
102 '#default_value' => variable_get('views_slideshow_default_hover_breakout', VIEWS_SLIDESHOW_DEFAULT_HOVER_BREAKOUT),
103 '#options' => array(VIEWS_SLIDESHOW_HOVER_BREAKOUT_TEASER => 'teaser', VIEWS_SLIDESHOW_HOVER_BREAKOUT_FULL => 'full node'),
104 '#description' => t('When using the \'thumbnail hover\' mode, a larger element will be created below a list of nodes, to display the node currently in focus (either by rotation or mouse-over). This option will select whether those nodes will be displayed as a teaser or full node in this element. It is ignored when in \'single frame\' mode.'),
105 );
106 $form['views_slideshow_default_teasers_last'] = array(
107 '#type' => 'checkbox',
108 '#title' => t('Global teaser placed last in hover breakout mode'),
109 '#default_value' => variable_get('views_slideshow_default_teasers_last', VIEWS_SLIDESHOW_DEFAULT_TEASERS_LAST),
110 '#description' => t('If checked, then when a slideshow is in the Hover Breakout mode, the teasers will be displayed after the main image. Otherwise, they will appear first.'),
111 );
112 $form['views_slideshow_default_timer_delay'] = array(
113 '#type' => 'textfield',
114 '#title' => t('Global slideshow timer delay'),
115 '#default_value' => variable_get('views_slideshow_default_timer_delay', VIEWS_SLIDESHOW_DEFAULT_TIMER_DELAY),
116 '#description' => t('Set this to the number of miliseconds you wish each slide to delay before showing the next slide of a view.'),
117 );
118 $form['views_slideshow_default_sort_order'] = array(
119 '#type' => 'select',
120 '#title' => t('Global slideshow sort order'),
121 '#default_value' => variable_get('views_slideshow_default_sort_order', VIEWS_SLIDESHOW_DEFAULT_SORT_ORDER),
122 '#options' => array(VIEWS_SLIDESHOW_SORT_REVERSE => t('reverse'), VIEWS_SLIDESHOW_SORT_RANDOM => t('random'), VIEWS_SLIDESHOW_SORT_FORWARD => t('forward')),
123 '#description' => t('This determines the order that selected nodes of a view will be displayed in the slideshow.'),
124 );
125 $form['views_slideshow_default_fade'] = array(
126 '#type' => 'select',
127 '#title' => t('Global slideshow fade'),
128 '#default_value' => variable_get('views_slideshow_default_fade', VIEWS_SLIDESHOW_DEFAULT_FADE),
129 '#options' => array('1' => t('true'), '0' => t('false')),
130 '#description' => t('If true, then slides will fade into the next slide of the view. Otherwise, they will transition instantly, and the following values will be ignored.'),
131 );
132 $form['views_slideshow_default_fade_speed'] = array(
133 '#type' => 'select',
134 '#title' => t('Global slideshow fade speed'),
135 '#default_value' => variable_get('views_slideshow_default_fade_speed', VIEWS_SLIDESHOW_DEFAULT_FADE_SPEED),
136 '#options' => array(VIEWS_SLIDESHOW_FADE_SPEED_SLOW => t('slow'), VIEWS_SLIDESHOW_FADE_SPEED_NORMAL => t('normal'), VIEWS_SLIDESHOW_FADE_SPEED_FAST => t('fast')),
137 '#description' => t('This determines how quickly a slide fades into the next slide.'),
138 );
139 $form['views_slideshow_default_fade_value'] = array(
140 '#type' => 'textfield',
141 '#title' => t('Global slideshow fade value'),
142 '#default_value' => variable_get('views_slideshow_default_fade_value', VIEWS_SLIDESHOW_DEFAULT_FADE_VALUE),
143 '#description' => t('Set this to a decimal between 0 and 1. Slides will fade to this opacity before fading into the next slide.'),
144 );
145 $form['helpfield'] = array(
146 '#type' => 'fieldset',
147 '#title' => t('Individual view slideshow configuration'),
148 '#collapsible' => true,
149 '#collapsed' => true,
150 );
151 $form['helpfield']['help'] = array(
152 '#type' => 'item',
153 '#value' => t('Currently, there is no way in the Views UI administration screens to set the previous options for a certain view.
154 Until Views 2.0 is released, if you wish to override a global setting for a particular view slideshow, you\'ll need to manually
155 set the value(s) in the Argument Handling Code of the Arguments section of the view.
156 For instance, you might specify $view->slideshow[\'sort_order\'] = VIEWS_SLIDESHOW_SORT_RANDOM for a random slideshow,
157 $view->slideshow[\'fade_value\'] = 0.5 to fade out nodes half-way, or $view->slideshow[\'timer_delay\'] = 2000 for a delay of two seconds.
158 Allowed values:
159 <ul>
160 <li>$view->slideshow[\'mode\']
161 <ul>
162 <li>VIEWS_SLIDESHOW_MODE_SINGLE_FRAME (\'' . VIEWS_SLIDESHOW_MODE_SINGLE_FRAME . '\'):
163 the slideshow will be displayed in single frame mode
164 <li>VIEWS_SLIDESHOW_MODE_THUMBNAIL_HOVER (\'' . VIEWS_SLIDESHOW_MODE_THUMBNAIL_HOVER . '\'):
165 the slideshow will be displayed in thumbnail hover mode
166 </ul>
167 <li>$view->slideshow[\'teasers_last\']
168 <ul>
169 <li>TRUE or FALSE; Only applies when the mode is VIEWS_SLIDESHOW_MODE_THUMBNAIL_HOVER.
170 If TRUE, then teasers will be displayed before the main image. Otherwise, they will appear later in the HTML.
171 </ul>
172 <li>$view->slideshow[\'timer_delay\']
173 <ul>
174 <li>This value should be between 0 and the number of miliseconds you wish to delay.
175 </ul>
176 <li>$view->slideshow[\'sort_order\']
177 <ul>
178 <li>VIEWS_SLIDESHOW_SORT_REVERSE (' . VIEWS_SLIDESHOW_SORT_REVERSE . '): reverse order
179 <li>VIEWS_SLIDESHOW_SORT_RANDOM (' . VIEWS_SLIDESHOW_SORT_RANDOM . '): random order
180 <li>VIEWS_SLIDESHOW_SORT_FORWARD (' . VIEWS_SLIDESHOW_SORT_FORWARD . '): forward order
181 </ul>
182 <li>$view->slideshow[\'fade\']
183 <ul>
184 <li>true or false: if false, the slideshow will change instantly, and the values for fade_speed and fade_value will be ignored.
185 </ul>
186 <li>$view->slideshow[\'fade_speed\']
187 <ul>
188 <li>VIEWS_SLIDESHOW_FADE_SPEED_SLOW (\'' . VIEWS_SLIDESHOW_FADE_SPEED_SLOW . '\')
189 <li>VIEWS_SLIDESHOW_FADE_SPEED_NORMAL (\'' . VIEWS_SLIDESHOW_FADE_SPEED_NORMAL . '\')
190 <li>VIEWS_SLIDESHOW_FADE_SPEED_FAST (\'' . VIEWS_SLIDESHOW_FADE_SPEED_FAST . '\')
191 </ul>
192 <li>$view->slideshow[\'fade_value\']
193 <ul>
194 <li>a decimal value between 0 and 1, to determine how much to fade a slide.
195 </ul>
196 </ul>'),
197 );
198 return system_settings_form($form);
199 }
200
201 /**
202 * Slideshow View style plugins. Implementation of hook_views_style_plugins()
203 */
204 function views_slideshow_views_style_plugins() {
205 return array(
206 'slideshow_list' => array(
207 'name' => t('Slideshow List'),
208 'theme' => 'views_slideshow_view_list',
209 'validate' => 'views_slideshow_plugin_validate_list',
210 'needs_fields' => true,
211 ),
212 'slideshow_teaser' => array(
213 'name' => t('Slideshow Teasers'),
214 'theme' => 'views_slideshow_view_teasers',
215 ),
216 'slideshow_node' => array(
217 'name' => t('Slideshow Full Nodes'),
218 'theme' => 'views_slideshow_view_nodes',
219 ),
220 );
221 }
222
223 /**
224 * Validate a view with type: slideshow list.
225 */
226 function views_slideshow_plugin_validate_list($type, $view, $form) {
227 // pass thru to list
228 return module_invoke('views_ui', 'plugin_validate_list', $type, $view, $form);
229 }
230
231 /**
232 * Display the nodes of a view as a list.
233 */
234 function theme_views_slideshow_view_list($view, $nodes, $type) {
235 $fields = _views_get_fields();
236 $items = array();
237
238 foreach ($nodes as $node) {
239 $item = '';
240 foreach ($view->field as $field) {
241 if ($fields[$field['id']]['visible'] !== FALSE) {
242 if ($field['label']) {
243 $item .= "<div class='view-label ". views_css_safe('view-label-'. $field['queryname']) ."'>" . $field['label'] . "</div>";
244 }
245 $item .= "<div class='view-field ". views_css_safe('view-data-'. $field['queryname']) ."'>" . views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view) . "</div>";
246 }
247 }
248 $items[] = "<div class='view-item ". views_css_safe('view-item-'. $view->name) ."'>$item</div>\n"; // l($node->title, "node/$node->nid");
249 }
250 return theme('views_slideshow_slideshow', $view, $nodes, $type, $items);
251 }
252
253 /**
254 * Display the nodes of a view as teasers.
255 */
256 function theme_views_slideshow_view_teasers($view, $nodes, $type) {
257 return theme('views_slideshow_view_nodes', $view, $nodes, $type, true);
258 }
259
260 /**
261 * Display the nodes of a view as plain nodes.
262 */
263 function theme_views_slideshow_view_nodes($view, $nodes, $type, $teasers = false, $links = true) {
264 $items = array();
265 foreach ($nodes as $n) {
266 $node = node_load($n->nid);
267 $items[] = node_view($node, $teasers, false, $links);
268 }
269 return theme('views_slideshow_slideshow', $view, $nodes, $type, $items);
270 }
271
272 /**
273 * Display the slideshow items in a div w/ jquery
274 */
275 function theme_views_slideshow_slideshow($view, $nodes, $type, $items) {
276 static $div = 0;
277 static $added_js = FALSE;
278
279 $output = '';
280 if (is_array($items) && !(empty($items))) {
281 $mode = isset($view->slideshow['mode']) ? $view->slideshow['mode'] : variable_get('views_slideshow_default_mode', VIEWS_SLIDESHOW_DEFAULT_MODE);
282
283 if ($mode == VIEWS_SLIDESHOW_MODE_JCAROUSEL) {
284 $skin = isset($view->slideshow['skin']) ? $view->slideshow['skin'] : variable_get('views_slideshow_jcarousel_skin', VIEWS_SLIDESHOW_JCAROUSEL_SKIN_DEFAULT);
285 jcarousel_add($skin);
286 }
287 // only add the js file the first time a slideshow is presented. if multiple slideshows are displayed, they all use the same js.
288 else if (!$added_js) {
289 $base = drupal_get_path('module', 'views_slideshow');
290 drupal_add_js($base . '/js/views_slideshow.js', 'module');
291 drupal_add_css($base . '/views_slideshow.css', 'module');
292 $added_js = TRUE;
293 }
294
295 $div++;
296 if ($mode == VIEWS_SLIDESHOW_MODE_JCAROUSEL) {
297 $js = theme('views_slideshow_jcarousel_js', $div);
298 }
299 else {
300 $js = theme('views_slideshow_div_js', $view, $nodes, $type, $items, $div);
301 }
302 drupal_add_js($js, 'inline');
303
304 $hover_breakout = isset($view->slideshow['hover_breakout']) ? $view->slideshow['hover_breakout'] : variable_get('views_slideshow_default_hover_breakout', VIEWS_SLIDESHOW_DEFAULT_HOVER_BREAKOUT);
305 $teaser = ($hover_breakout == VIEWS_SLIDESHOW_HOVER_BREAKOUT_TEASER ? TRUE : FALSE);
306
307 // if we're using the 'thumbnail hover' mode, then we need to display all the view thumbnails
308 if ($mode == VIEWS_SLIDESHOW_MODE_THUMBNAIL_HOVER) {
309 $view_teasers = theme('views_slideshow_breakout_teasers', $view, $nodes, $type, $items, $div);
310 $teasers_last = isset($view->slideshow['teasers_last']) ? $view->slideshow['teasers_last'] : variable_get('views_slideshow_default_teasers_last', VIEWS_SLIDESHOW_DEFAULT_TEASERS_LAST);
311 if (!$teasers_last) {
312 $output .= $view_teasers;
313 }
314 }
315
316 // these are hidden elements, used to cycle through the main div
317 if ($mode != VIEWS_SLIDESHOW_MODE_JCAROUSEL) {
318 $hidden_elements .= theme('views_slideshow_no_display_section', $view, $nodes, $type, $items, $div, $mode, $teaser);
319 }
320
321 if ($mode == VIEWS_SLIDESHOW_MODE_THUMBNAIL_HOVER) {
322 $output .= theme('views_slideshow_main_section', $view, $nodes, $type, $items, node_view(node_load($nodes[0]->nid), $teaser, FALSE, FALSE), $div, $hidden_elements);
323 }
324 else if ($mode == VIEWS_SLIDESHOW_MODE_JCAROUSEL) {
325 $output .= theme('views_slideshow_jcarousel', $items, $div, $skin);
326 }
327 else {
328 $output .= theme('views_slideshow_main_section', $view, $nodes, $type, $items, $items[0], $div, $hidden_elements);
329 }
330
331 if ($view_teasers && $teasers_last) {
332 $output .= $view_teasers;
333 }
334
335 }
336 return $output;
337 }
338
339 /**
340 * this inline js sets up the timer for this slideshow
341 */
342 function theme_views_slideshow_div_js($view, $nodes, $type, $items, $div) {
343 $divs = '"' . implode('", "', array_keys($items)) . '"';
344 $num_divs = sizeof($items);
345 $timer_delay = isset($view->slideshow['timer_delay']) ? $view->slideshow['timer_delay'] : variable_get('views_slideshow_default_timer_delay', VIEWS_SLIDESHOW_DEFAULT_TIMER_DELAY);
346 $sort = isset($view->slideshow['sort_order']) ? $view->slideshow['sort_order'] : variable_get('views_slideshow_default_sort_order', VIEWS_SLIDESHOW_DEFAULT_SORT_ORDER);
347 $fade = isset($view->slideshow['fade']) ? $view->slideshow['fade'] : variable_get('views_slideshow_default_fade', VIEWS_SLIDESHOW_DEFAULT_FADE);
348 $fade = $fade ? 'true' : 'false';
349 $fade_speed = isset($view->slideshow['fade_speed']) ? $view->slideshow['fade_speed'] : variable_get('views_slideshow_default_fade_speed', VIEWS_SLIDESHOW_DEFAULT_FADE_SPEED);
350 $fade_value = isset($view->slideshow['fade_value']) ? $view->slideshow['fade_value'] : variable_get('views_slideshow_default_fade_value', VIEWS_SLIDESHOW_DEFAULT_FADE_VALUE);
351 $hover = (module_invoke('jq', 'add', 'hoverIntent')) ? 'hoverIntent' : 'hover';
352 $js = '
353 // set the timer data for a view slideshow
354 $(document).ready(function() {
355 // these are the divs containing the elements to be displayed in the main div in rotation or mouseover
356 slideshow_data["' . $div . '"] = new views_slideshow_data(' . $num_divs . ', ' . $timer_delay . ', ' . $sort . ', ' . $fade . ', "' . $fade_speed . '", ' . $fade_value . ');
357
358 // this turns on the timer
359 views_slideshow_timer("' . $div . '", true);
360
361 // this sets up the mouseover & mouseout to pause on the main element
362 $("#views_slideshow_main_' . $div . '").' . $hover . '(
363 function() {
364 views_slideshow_pause("' . $div . '");
365 },
366 function() {
367 views_slideshow_resume("' . $div . '");
368 });
369 });
370 ';
371 return $js;
372 }
373
374 /**
375 * this displays the main element, where the current slide is shown
376 */
377 function theme_views_slideshow_main_section($view, $nodes, $type, $items, $item, $div, $hidden_elements) {
378 $output .= "\n\n" . '<div id="views_slideshow_main_' . $div . '" class="views_slideshow_main">' . "\n ";
379 // $output .= $item . "\n";
380 $output .= $hidden_elements;
381 $output .= '</div><!--close views_slideshow_main_' . $div . "-->\n\n";
382 return $output;
383 }
384
385 /**
386 * these are the slideshow elements themselves; not actually displayed, but used to give the html to the main element
387 */
388 function theme_views_slideshow_no_display_section($view, $nodes, $type, $items, $div, $mode, $teaser = TRUE) {
389 $output .= '<div id="views_slideshow_teaser_section_' . $div . '" class="views_slideshow_teaser_section">' . "\n";
390 if ($mode == VIEWS_SLIDESHOW_MODE_THUMBNAIL_HOVER) {
391 foreach ($nodes as $count => $node) {
392 $output .= theme('views_slideshow_no_display_teaser', node_view(node_load($node->nid), $teaser, FALSE, FALSE), $div, $count);
393 }
394 }
395 else {
396 foreach ($items as $count => $item) {
397 $output .= theme('views_slideshow_no_display_teaser', $item, $div, $count);
398 }
399 }
400 $output .= "</div><!--close views_slideshow_no_display-->\n\n";
401 return $output;
402 }
403
404 /**
405 * the html that will be placed into the element in its turn during its frame
406 */
407 function theme_views_slideshow_no_display_teaser($item, $div, $count) {
408 $hidden = $count ? 'class="views_slideshow_hidden"' : '';
409 $output .= ' <div id="views_slideshow_div_' . $div . '_' . $count . '" '. $hidden .'>' . "\n ";
410 $output .= $item . "\n";
411 $output .= ' </div><!--close views_slideshow_div_' . $div . '_' . $count . '-->' . "\n\n";
412 return $output;
413 }
414
415 /**
416 * these are teasers that may be pointed at with a mouse to change the element directly
417 */
418 function theme_views_slideshow_breakout_teasers($view, $nodes, $type, $items, $div) {
419 $output .= '<div id="views_slideshow_breakout_teasers_' . $div . '" class="views_slideshow_breakout_teasers">' . "\n";
420 $js = "$(document).ready(function() {\n";
421 foreach ($items as $count => $item) {
422 $output .= theme('views_slideshow_breakout_teaser', $item, $div, $count);
423 $js .= theme('views_slideshow_breakout_teaser_js', $div, $count);
424 }
425 $js .= "})\n";
426 drupal_add_js($js, 'inline');
427
428 $output .= "</div><!--close views_slideshow_breakout_teasers-->\n\n";
429
430 return $output;
431 }
432
433 /**
434 * the mouseover event code for each breakout teaser
435 */
436 function theme_views_slideshow_breakout_teaser_js($div, $count) {
437 // js to set the main div to this teaser's element
438 $hover = (module_invoke('jq', 'add', 'hoverIntent')) ? 'hoverIntent' : 'hover';
439
440 $js .= '
441 $("#views_slideshow_div_breakout_teaser_' . $div . '_' . $count . '").' . $hover . '(
442 function() {
443 views_slideshow_switch("' . $div . '", ' . $count . ');
444 views_slideshow_pause("' . $div . '");
445 },
446 function() {
447 views_slideshow_resume("' . $div . '");
448 });
449 ';
450 return $js;
451 }
452
453 /**
454 * an individual breakout teaser
455 */
456 function theme_views_slideshow_breakout_teaser($item, $div, $count) {
457 $class = $count ? '' : ' views_slideshow_active_teaser';
458 $output .= ' <div id="views_slideshow_div_breakout_teaser_' . $div . '_' . $count . '" class="views_slideshow_div_breakout_teaser' . $class . '">' . "\n ";
459 $output .= $item . "\n";
460 $output .= ' </div><!--close views_slideshow_div_breakout_teaser_' . $div . '_' . $count . '-->' . "\n\n";
461 return $output;
462 }
463
464 function theme_views_slideshow_jcarousel($items, $div = '', $skin = NULL) {
465 if (sizeof($items)) {
466 if (!isset($skin)) {
467 $skin = variable_get('views_slideshow_jcarousel_skin', VIEWS_SLIDESHOW_JCAROUSEL_SKIN_DEFAULT);
468 }
469 $output .= "\n" . '<ul id="views_slideshow_jcarousel_' . $div . '" class="jcarousel-skin-' . $skin . '">' . "\n";
470 $output .= ' <li>';
471 $output .= implode("</li>\n\n <li>", $items);
472 $output .= "</li></ul>\n";
473 }
474 return $output;
475 }
476
477 // TODO :add other jcarousel options...
478 function theme_views_slideshow_jcarousel_js($div) {
479 $js = "$(document).ready(function() {\n";
480 $js .= "$('#views_slideshow_jcarousel_$div').jcarousel();\n";
481 $js .= "})\n";
482 return $js;
483 }

  ViewVC Help
Powered by ViewVC 1.1.2