You are here

function _lightgallery_build_option_set in Lightgallery 7

Builds compatible JS options set from views options form.

Parameters

type $options:

2 calls to _lightgallery_build_option_set()
template_preprocess_lightgallery_view in ./lightgallery.module
Display a view as a Lightgallery style.
theme_lightgallery_image_formatter in includes/lightgallery.theme.inc
Returns HTML for an Lightgallery image field formatter.

File

./lightgallery.module, line 188

Code

function _lightgallery_build_option_set($options) {
  $option_set = array(
    'mode' => !empty($options['mode']) ? $options['mode'] : 'lg-slide',
    'preload' => !empty($options['preload']) ? $options['preload'] : 1,
    'loop' => !empty($options['loop']) ? TRUE : FALSE,
    'closable' => !empty($options['closable']) ? TRUE : FALSE,
    'escKey' => !empty($options['esc_key']) ? TRUE : FALSE,
    'keyPress' => !empty($options['key_press']) ? TRUE : FALSE,
    'contols' => !empty($options['contols']) ? TRUE : FALSE,
    'mousewheel' => !empty($options['mouse_wheel']) ? TRUE : FALSE,
    'download' => !empty($options['download']) ? TRUE : FALSE,
    'counter' => !empty($options['counter']) ? TRUE : FALSE,
    'enableDrag' => !empty($options['drag']) ? TRUE : FALSE,
    'enableTouch' => !empty($options['touch']) ? TRUE : FALSE,
    'thumbnail' => !empty($options['thumbnails']) ? TRUE : FALSE,
    'autoplay' => !empty($options['autoplay']) ? TRUE : FALSE,
    'fullScreen' => !empty($options['full_screen']) ? TRUE : FALSE,
    'pager' => !empty($options['pager']) ? TRUE : FALSE,
    'zoom' => !empty($options['zoom']) ? TRUE : FALSE,
    'hash' => !empty($options['hash']) ? TRUE : FALSE,
    'selector' => !empty($options['selector']) ? $options['selector'] : FALSE,
  );
  if ($option_set['thumbnail']) {

    // Add extra thumb options.
    $option_set['animateThumb'] = !empty($options['animate_thumb']) ? TRUE : FALSE;
    $option_set['currentPagerPosition'] = !empty($options['current_pager_position']) ? $options['current_pager_position'] : 'middle';
    $option_set['thumbWidth'] = !empty($options['thumb_width']) ? $options['thumb_width'] : 100;
    $option_set['thumbContHeight'] = !empty($options['thumb_cont_height']) ? $options['thumb_cont_height'] : 100;
  }
  if ($option_set['autoplay']) {

    // Add extra autoplay options.
    $option_set['pause'] = !empty($options['pause']) ? $options['pause'] : 5000;
    $option_set['progressBar'] = !empty($options['progress_bar']) ? TRUE : FALSE;
    $option_set['autoplayControls'] = !empty($options['autoplay_controls']) ? TRUE : FALSE;
  }
  if ($option_set['zoom']) {

    // Add extra autoplay options.
    $option_set['scale'] = !empty($options['scale']) ? $options['scale'] : 1;
  }
  if ($option_set['hash']) {

    // Add extra autoplay options.
    $option_set['galleryId'] = !empty($options['gallery_id']) ? $options['gallery_id'] : 1;
  }
  if ($option_set['selector']) {
    $option_set['selector'] = !empty($options['selector']) ? $options['selector'] : FALSE;
  }
  return $option_set;
}