You are here

function theme_views_slideshow_div_js in Views Slideshow 5

Same name and namespace in other branches
  1. 6 views_slideshow.theme.inc \theme_views_slideshow_div_js()

this inline js sets up the timer for this slideshow

1 theme call to theme_views_slideshow_div_js()
theme_views_slideshow_slideshow in ./views_slideshow.module
Display the slideshow items in a div w/ jquery

File

./views_slideshow.module, line 341

Code

function theme_views_slideshow_div_js($view, $nodes, $type, $items, $div) {
  $divs = '"' . implode('", "', array_keys($items)) . '"';
  $num_divs = sizeof($items);
  $timer_delay = isset($view->slideshow['timer_delay']) ? $view->slideshow['timer_delay'] : variable_get('views_slideshow_default_timer_delay', VIEWS_SLIDESHOW_DEFAULT_TIMER_DELAY);
  $sort = isset($view->slideshow['sort_order']) ? $view->slideshow['sort_order'] : variable_get('views_slideshow_default_sort_order', VIEWS_SLIDESHOW_DEFAULT_SORT_ORDER);
  $fade = isset($view->slideshow['fade']) ? $view->slideshow['fade'] : variable_get('views_slideshow_default_fade', VIEWS_SLIDESHOW_DEFAULT_FADE);
  $fade = $fade ? 'true' : 'false';
  $fade_speed = isset($view->slideshow['fade_speed']) ? $view->slideshow['fade_speed'] : variable_get('views_slideshow_default_fade_speed', VIEWS_SLIDESHOW_DEFAULT_FADE_SPEED);
  $fade_value = isset($view->slideshow['fade_value']) ? $view->slideshow['fade_value'] : variable_get('views_slideshow_default_fade_value', VIEWS_SLIDESHOW_DEFAULT_FADE_VALUE);
  $hover = module_invoke('jq', 'add', 'hoverIntent') ? 'hoverIntent' : 'hover';
  $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["' . $div . '"] = new views_slideshow_data(' . $num_divs . ', ' . $timer_delay . ', ' . $sort . ', ' . $fade . ', "' . $fade_speed . '", ' . $fade_value . ');

  // this turns on the timer
  views_slideshow_timer("' . $div . '", true);

  // this sets up the mouseover & mouseout to pause on the main element
  $("#views_slideshow_main_' . $div . '").' . $hover . '(
    function() {
      views_slideshow_pause("' . $div . '");
    },
    function() {
      views_slideshow_resume("' . $div . '");
    });
});
';
  return $js;
}