You are here

function views_slideshow_jcarousel_pager_views_slideshow_widget_pager_form_options in Views Slideshow JCarousel 7.2

Same name and namespace in other branches
  1. 6 views_slideshow_jcarousel.module \views_slideshow_jcarousel_pager_views_slideshow_widget_pager_form_options()
  2. 7 views_slideshow_jcarousel.module \views_slideshow_jcarousel_pager_views_slideshow_widget_pager_form_options()

File

./views_slideshow_jcarousel.module, line 301

Code

function views_slideshow_jcarousel_pager_views_slideshow_widget_pager_form_options(&$form, &$form_state, &$view, $defaults, $dependency) {

  // Check for the library, prompt as necessary
  if (!($jq_path = _views_slideshow_jcarousel_library_path())) {
    drupal_set_message(t('The jCarousel library was not found. Please extract the jCarousel package to sites/all/libraries/' . JCAROUSEL_LIBRARY_NAME . ', so that the javascript files are located at sites/all/libraries/' . JCAROUSEL_LIBRARY_NAME . '/dist. You can download the jCarousel package at !url', array(
      '!url' => l('http://sorgalla.com/jcarousel/', 'http://sorgalla.com/jcarousel/', array(
        'attributes' => array(
          'target' => '_blank',
        ),
      )),
    )));

    //    $form['views_slideshow_jcarousel_not_found'] = array(
    //      '#markup' => '<div class="messages error">' . t('The jCarousel library was not found. Please extract the jCarousel package to sites/all/libraries/'.JCAROUSEL_LIBRARY_NAME.', so that the javascript files are located at sites/all/libraries/'.JCAROUSEL_LIBRARY_NAME.'/dist. You can download the jCarousel package at !url', array('!url' => l('http://sorgalla.com/jcarousel/', 'http://sorgalla.com/jcarousel/',  array('attributes' => array('target' => '_blank'))))) . '</div>',
    //    );
  }

  // Settings for fields pager.
  $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['views_slideshow_jcarousel']['pager_fields'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Pager fields'),
    '#options' => $options,
    '#default_value' => $defaults['views_slideshow_jcarousel']['pager_fields'],
    '#description' => t("Choose the fields that will appear in the pager."),
    '#states' => array(
      'visible' => array(
        ':input[name="style_options[widgets][top][views_slideshow_pager][enable]"]' => array(
          'checked' => true,
        ),
      ),
    ),
  );

  // Add field to see if they would like the carousel to activate the pager item
  // on slide change.
  $form['views_slideshow_jcarousel']['pager_move_on_change'] = array(
    '#type' => 'checkbox',
    '#title' => t('Move To Active Pager Item On Slide Change'),
    '#default_value' => $defaults['views_slideshow_jcarousel']['pager_move_on_change'],
    '#description' => t('When the slide changes move the carousel to the active pager item.'),
  );
  $form['views_slideshow_jcarousel']['pager_update_on_prev_next'] = array(
    '#type' => 'checkbox',
    '#title' => t('Make Previous/Next Buttons Update the Current Slide'),
    '#default_value' => $defaults['views_slideshow_jcarousel']['pager_update_on_prev_next'],
    '#description' => t('Cycle the slideshow forward or backwards when the pager previous/next buttons are clicked'),
  );

  // skins are now implemented as ctools renderer plugins
  $carousel_skins = ctools_get_plugins("views_slideshow_jcarousel", "skins");
  foreach ($carousel_skins as $key => $skin) {
    $skins[$key] = $skin['name'];
  }

  // Set the skin.
  $form['views_slideshow_jcarousel']['pager_skin'] = array(
    '#type' => 'select',
    '#title' => t('jCarousel Skin'),
    '#options' => $skins,
    '#default_value' => $defaults['views_slideshow_jcarousel']['pager_skin'],
    '#description' => t('Choose the skin for your carousel.  You can add more by placing your skin in the jcarousel library directory.'),
  );

  // Set orientation of the pager.
  $form['views_slideshow_jcarousel']['pager_orientation'] = array(
    '#type' => 'select',
    '#title' => t('Orientation of the Pager'),
    '#options' => array(
      FALSE => 'Horizontal',
      TRUE => 'Vertical',
    ),
    '#default_value' => $defaults['views_slideshow_jcarousel']['pager_orientation'],
    '#description' => t('Should the pager be horizontal or vertical.'),
  );

  // Set the number of visible items.
  $form['views_slideshow_jcarousel']['pager_visible'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of Visible Pager Items'),
    '#default_value' => $defaults['views_slideshow_jcarousel']['pager_visible'],
    '#description' => t('Set the number of pager items that are visible at a single time.'),
    '#size' => 10,
  );

  // Set the number of items to scroll by.
  $form['views_slideshow_jcarousel']['pager_scroll'] = array(
    '#type' => 'textfield',
    '#title' => t('Scroll'),
    '#default_value' => $defaults['views_slideshow_jcarousel']['pager_scroll'],
    '#description' => t('The number of items to scroll by.'),
    '#size' => 10,
  );

  // animation speed
  $form['views_slideshow_jcarousel']['pager_animation'] = array(
    '#type' => 'textfield',
    '#title' => t('Speed of the transition'),
    '#default_value' => $defaults['views_slideshow_jcarousel']['pager_animation'],
    '#description' => t('Options are fast, slow or a number in milliseconds.'),
    '#size' => '10',
  );

  // Wrap the carousel
  $form['views_slideshow_jcarousel']['pager_wrap'] = array(
    '#type' => 'select',
    '#title' => t('Wrapping'),
    '#options' => array(
      NULL => 'Disabled',
      'circular' => 'Circular',
      'first' => 'First',
      'last' => 'Last',
      'both' => 'Both',
    ),
    '#default_value' => $defaults['views_slideshow_jcarousel_pager_wrap'],
    '#description' => t('Wrap the carousel.'),
  );
}