View source
<?php
function theme_views_slideshow_div_js($rows, $options, $id) {
$hover = 'hover';
if ($options['hover'] == 'hoverIntent') {
if (module_exists('jq')) {
$hover = jq_add('hoverIntent') ? 'hoverIntent' : 'hover';
}
else {
if (module_exists('hoverintent')) {
$hover = hoverintent_add() ? 'hoverIntent' : 'hover';
}
}
}
$num_divs = sizeof($rows);
$fade = $options['fade'] ? 'true' : 'false';
$js = <<<JS
// Set the timer data for a view slideshow.
\$(document).ready(function() {
// These are the divs containing the elements to be displayed in the main div in rotation or mouseover.
slideshow_data["{<span class="php-variable">$id</span>}"] = new views_slideshow_data({<span class="php-variable">$num_divs</span>}, {<span class="php-variable">$options</span>[<span class="php-string">'timer_delay'</span>]}, {<span class="php-variable">$options</span>[<span class="php-string">'sort'</span>]}, {<span class="php-variable">$fade</span>}, "{<span class="php-variable">$options</span>[<span class="php-string">'fade_speed'</span>]}", {<span class="php-variable">$options</span>[<span class="php-string">'fade_value'</span>]});
// This turns on the timer.
views_slideshow_timer("{<span class="php-variable">$id</span>}", true);
// This sets up the mouseover & mouseout to pause on the main element.
\$("#views_slideshow_main_{<span class="php-variable">$id</span>}").{<span class="php-variable">$hover</span>}(
function() {
views_slideshow_pause("{<span class="php-variable">$id</span>}");
},
function() {
views_slideshow_resume("{<span class="php-variable">$id</span>}");
});
});
JS;
return $js;
}
function theme_views_slideshow_main_section($id, $hidden_elements) {
$output = "\n\n" . '<div id="views_slideshow_main_' . $id . '" class="views_slideshow_main">' . "\n ";
$output .= $hidden_elements;
$output .= '</div><!--close views_slideshow_main_' . $id . "-->\n\n";
return $output;
}
function theme_views_slideshow_no_display_section($view, $rows, $id, $mode, $teaser = TRUE) {
$output = '<div id="views_slideshow_teaser_section_' . $id . '" class="views_slideshow_teaser_section">' . "\n";
if ($mode == VIEWS_SLIDESHOW_MODE_THUMBNAIL_HOVER) {
foreach ($view->result as $count => $node) {
$output .= theme('views_slideshow_no_display_teaser', node_view(node_load($node->nid), $teaser, FALSE, FALSE), $id, $count);
}
}
else {
if (module_exists('jq')) {
$js = jq_add('cycle');
}
if (!$js) {
drupal_add_js(drupal_get_path('module', 'views_slideshow') . '/js/jquery.cycle.all.min.js', 'module');
}
foreach ($rows as $count => $item) {
$output .= theme('views_slideshow_no_display_teaser', $item, $id, $count);
}
}
$output .= "</div><!--close views_slideshow_no_display-->\n\n";
return $output;
}
function theme_views_slideshow_no_display_teaser($item, $id, $count) {
$hidden = $count ? 'class="views_slideshow_hidden"' : '';
$output = ' <div id="views_slideshow_div_' . $id . '_' . $count . '" ' . $hidden . '>' . "\n ";
$output .= $item . "\n";
$output .= ' </div><!--close views_slideshow_div_' . $id . '_' . $count . '-->' . "\n\n";
return $output;
}
function theme_views_slideshow_breakout_teasers($items, $id) {
$output = '<div id="views_slideshow_breakout_teasers_' . $id . '" class="views_slideshow_breakout_teasers">' . "\n";
$js = "\$(document).ready(function() {\n";
foreach ($items as $count => $item) {
$output .= theme('views_slideshow_breakout_teaser', $item, $id, $count);
$js .= theme('views_slideshow_breakout_teaser_js', $id, $count);
}
$js .= "})\n";
drupal_add_js($js, 'inline');
$output .= "</div><!--close views_slideshow_breakout_teasers-->\n\n";
return $output;
}
function theme_views_slideshow_breakout_teaser_js($id, $count) {
$hover = module_invoke('jq', 'add', 'hoverIntent') ? 'hoverIntent' : 'hover';
$js = '
$("#views_slideshow_div_breakout_teaser_' . $id . '_' . $count . '").' . $hover . '(
function() {
views_slideshow_switch("' . $id . '", ' . $count . ');
views_slideshow_pause("' . $id . '");
},
function() {
views_slideshow_resume("' . $id . '");
});
';
return $js;
}
function theme_views_slideshow_breakout_teaser($item, $id, $count) {
$class = $count ? '' : ' views_slideshow_active_teaser';
$output = ' <div id="views_slideshow_div_breakout_teaser_' . $id . '_' . $count . '" class="views_slideshow_div_breakout_teaser' . $class . '">' . "\n ";
$output .= $item . "\n";
$output .= ' </div><!--close views_slideshow_div_breakout_teaser_' . $id . '_' . $count . '-->' . "\n\n";
return $output;
}