You are here

views_slideshow_xtra.module in Views Slideshow Xtra 6.3

This module creates a Views Slideshow widget for overlaying HTML elements on a slideshow.

File

views_slideshow_xtra.module
View source
<?php

/**
 * @file
 * This module creates a Views Slideshow widget for overlaying
 * HTML elements on a slideshow.
 */

/**
 * Implements hook_theme().
 */
function views_slideshow_xtra_theme($existing, $type, $theme, $path) {
  return array(
    'views_slideshow_xtra_widget_render' => array(
      'arguments' => array(
        'vss_id' => NULL,
        'view' => NULL,
        'settings' => array(),
        'location' => NULL,
        'rows' => array(),
      ),
      'file' => 'theme/views_slideshow_xtra.theme.inc',
    ),
    'views_slideshow_xtra_text' => array(
      'arguments' => array(
        'vss_id' => NULL,
        'view' => NULL,
        'vsx' => '',
        'slide_count' => 0,
        'field_item_count' => 0,
      ),
      'template' => 'theme/views-slideshow-xtra-text',
    ),
    'views_slideshow_xtra_link' => array(
      'arguments' => array(
        'vss_id' => NULL,
        'view' => NULL,
        'vsx' => '',
        'slide_count' => 0,
        'field_item_count' => 0,
      ),
      'template' => 'theme/views-slideshow-xtra-link',
    ),
    'views_slideshow_xtra_image' => array(
      'arguments' => array(
        'vss_id' => NULL,
        'view' => NULL,
        'vsx' => '',
        'slide_count' => 0,
        'field_item_count' => 0,
      ),
      'template' => 'theme/views-slideshow-xtra-image',
    ),
  );
}

/**
 * Implements hook_views_slideshow_widget_info().
 */
function views_slideshow_xtra_views_slideshow_widget_info() {
  return array(
    'views_slideshow_xtra' => array(
      'name' => t('Views Slideshow Xtra'),
      'accepts' => array(
        'transitionBegin' => array(
          'required' => TRUE,
        ),
      ),
      'calls' => array(),
    ),
  );
}

/**
 * Implements hook_views_slideshow_option_definition().
 */
function views_slideshow_xtra_views_slideshow_option_definition() {
  $locations = array(
    'top',
    'bottom',
  );

  // Defaults for the pager widget.
  foreach ($locations as $location) {
    $options['widgets']['contains'][$location]['contains']['views_slideshow_xtra']['contains']['fields'] = array(
      'default' => array(),
    );
    $options['widgets']['contains'][$location]['contains']['views_slideshow_xtra']['contains']['display_delay'] = array(
      'default' => 850,
    );
    $options['widgets']['contains'][$location]['contains']['views_slideshow_xtra']['contains']['display_delay_fade'] = array(
      'default' => 0,
    );
    $options['widgets']['contains'][$location]['contains']['views_slideshow_xtra']['contains']['pause_after_mouse_move'] = array(
      'default' => 2000,
    );
  }
  return $options;
}

/**
 * Implements hook_views_slideshow_widget_form_options().
 */
function views_slideshow_xtra_views_slideshow_widget_form_options(&$form, &$form_state, &$view, $defaults, $dependency) {
  $options = array();

  // Get each field and it's name.
  foreach ($view->display->handler
    ->get_handlers('field') as $field => $handler) {
    $options[$field] = $handler
      ->ui_name();
  }

  // Add ability to choose which fields to show in the pager.
  $form['fields'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Fields'),
    '#options' => $options,
    '#default_value' => $defaults['fields'],
    '#description' => t("Choose the field(s) to use as your views slideshow xtra fields."),
    '#prefix' => '<div id="' . $dependency . '-fields-wrapper">',
    '#suffix' => '</div>',
    '#process' => array(
      'expand_checkboxes',
      'views_process_dependency',
    ),
    '#dependency' => array(
      $dependency . '-enable' => array(
        1,
      ),
    ),
  );

  // Text display delay.
  $form['display_delay'] = array(
    '#type' => 'textfield',
    '#title' => t('Text Display Delay'),
    '#default_value' => $defaults['display_delay'],
    '#description' => t("How long, in milliseconds, to delay before displaying the text."),
    '#process' => array(
      'views_process_dependency',
    ),
    '#dependency' => array(
      $dependency . '-enable' => array(
        1,
      ),
    ),
  );

  // Text display fade transition.
  $form['display_delay_fade'] = array(
    '#type' => 'checkbox',
    '#title' => t('Fade in the text'),
    '#default_value' => $defaults['display_delay_fade'],
    '#process' => array(
      'views_process_dependency',
    ),
    '#dependency' => array(
      $dependency . '-enable' => array(
        1,
      ),
    ),
  );

  // Pause after mouse movement.
  $form['pause_after_mouse_move'] = array(
    '#type' => 'textfield',
    '#title' => t('Pause After Mouse Movement'),
    '#default_value' => $defaults['pause_after_mouse_move'],
    '#description' => t("Temporarily pause slide transition to allow the user time to click a slide overlay link if the mouse is in motion."),
    '#process' => array(
      'views_process_dependency',
    ),
    '#dependency' => array(
      $dependency . '-enable' => array(
        1,
      ),
    ),
  );
}

/**
 * Need to have preprocess functions here because drupal doesn't cache them
 * correctly in the theme.inc file.
 *
 * If you would like to override the preprocess functions make sure to look at
 * the associated function in theme.inc.
 */

// Trying to make sure the theme.inc get's loaded.
include_once 'theme/views_slideshow_xtra.theme.inc';
function template_preprocess_views_slideshow_xtra_text(&$vars) {
  _views_slideshow_xtra_preprocess_text($vars);
}
function template_preprocess_views_slideshow_xtra_link(&$vars) {
  _views_slideshow_xtra_preprocess_link($vars);
}
function template_preprocess_views_slideshow_xtra_image(&$vars) {
  _views_slideshow_xtra_preprocess_image($vars);
}