You are here

public function BxsliderThs::settingsForm in BxSlider 8

Returns a form to configure settings for the formatter.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form elements for the formatter settings.

Overrides Bxslider::settingsForm

File

src/Plugin/Field/FieldFormatter/BxsliderThs.php, line 95

Class

BxsliderThs
BxSlider thumbnail pager.

Namespace

Drupal\bxslider\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $elements = parent::settingsForm($form, $form_state);

  // Hide Pager options, because here is used Thumbnail image slider.
  $elements['slider']['pager']['#access'] = FALSE;
  $settings = $this
    ->getSettings();
  $image_styles = image_style_options(FALSE);
  $elements['thumbnail_slider'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Thumbnail slider'),
    '#weight' => 10,
  ];
  $elements['thumbnail_slider']['thumbnail_style'] = [
    '#title' => $this
      ->t('Image style'),
    '#type' => 'select',
    '#default_value' => $settings['thumbnail_slider']['thumbnail_style'],
    '#empty_option' => $this
      ->t('None (original image)'),
    '#options' => $image_styles,
  ];
  $elements['thumbnail_slider']['general'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('General'),
    '#weight' => 1,
    '#open' => FALSE,
  ];
  $elements['thumbnail_slider']['general']['mode'] = [
    '#title' => $this
      ->t('Mode'),
    '#type' => 'select',
    '#default_value' => $settings['thumbnail_slider']['general']['mode'],
    '#options' => [
      'horizontal' => 'horizontal',
      'fade' => 'fade',
    ],
  ];
  $elements['thumbnail_slider']['general']['speed'] = [
    '#title' => $this
      ->t('Speed'),
    '#type' => 'textfield',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['general']['speed'],
  ];
  $elements['thumbnail_slider']['general']['slideMargin'] = [
    '#title' => $this
      ->t('slideMargin'),
    '#type' => 'textfield',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['general']['slideMargin'],
  ];
  $elements['thumbnail_slider']['general']['startSlide'] = [
    '#title' => $this
      ->t('startSlide'),
    '#type' => 'textfield',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['general']['startSlide'],
  ];
  $elements['thumbnail_slider']['general']['randomStart'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('randomStart'),
    '#default_value' => $settings['thumbnail_slider']['general']['randomStart'],
  ];
  $elements['thumbnail_slider']['general']['infiniteLoop'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('infiniteLoop'),
    '#default_value' => $settings['thumbnail_slider']['general']['infiniteLoop'],
  ];
  $elements['thumbnail_slider']['general']['hideControlOnEnd'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('hideControlOnEnd'),
    '#default_value' => $settings['thumbnail_slider']['general']['hideControlOnEnd'],
  ];
  $elements['thumbnail_slider']['general']['easing'] = [
    '#title' => $this
      ->t('easing'),
    '#type' => 'textfield',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['general']['easing'],
  ];
  $elements['thumbnail_slider']['general']['captions'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('captions'),
    '#default_value' => $settings['thumbnail_slider']['general']['captions'],
  ];
  $elements['thumbnail_slider']['general']['ticker'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('ticker'),
    '#default_value' => $settings['thumbnail_slider']['general']['ticker'],
  ];
  $elements['thumbnail_slider']['general']['tickerHover'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('tickerHover'),
    '#default_value' => $settings['thumbnail_slider']['general']['tickerHover'],
  ];
  $elements['thumbnail_slider']['general']['adaptiveHeight'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('adaptiveHeight'),
    '#default_value' => $settings['thumbnail_slider']['general']['adaptiveHeight'],
  ];
  $elements['thumbnail_slider']['general']['adaptiveHeightSpeed'] = [
    '#title' => $this
      ->t('adaptiveHeightSpeed'),
    '#type' => 'textfield',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['general']['adaptiveHeightSpeed'],
  ];
  $elements['thumbnail_slider']['general']['responsive'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('responsive'),
    '#default_value' => $settings['thumbnail_slider']['general']['responsive'],
  ];
  $elements['thumbnail_slider']['general']['useCSS'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('useCSS'),
    '#default_value' => $settings['thumbnail_slider']['general']['useCSS'],
  ];
  $elements['thumbnail_slider']['general']['preloadImages'] = [
    '#title' => $this
      ->t('preloadImages'),
    '#type' => 'select',
    '#default_value' => $settings['thumbnail_slider']['general']['preloadImages'],
    '#options' => [
      'all' => 'all',
      'visible' => 'visible',
    ],
  ];
  $elements['slider']['general']['touchEnabled'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('touchEnabled'),
    '#default_value' => $settings['slider']['general']['touchEnabled'],
  ];
  $elements['thumbnail_slider']['general']['swipeThreshold'] = [
    '#title' => $this
      ->t('swipeThreshold'),
    '#type' => 'textfield',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['general']['swipeThreshold'],
  ];
  $elements['thumbnail_slider']['general']['oneToOneTouch'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('oneToOneTouch'),
    '#default_value' => $settings['thumbnail_slider']['general']['oneToOneTouch'],
  ];
  $elements['thumbnail_slider']['general']['preventDefaultSwipeX'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('preventDefaultSwipeX'),
    '#default_value' => $settings['thumbnail_slider']['general']['preventDefaultSwipeX'],
  ];
  $elements['thumbnail_slider']['general']['preventDefaultSwipeY'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('preventDefaultSwipeY'),
    '#default_value' => $settings['thumbnail_slider']['general']['preventDefaultSwipeY'],
  ];
  $elements['thumbnail_slider']['general']['wrapperClass'] = [
    '#title' => $this
      ->t('wrapperClass'),
    '#type' => 'textfield',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['general']['wrapperClass'],
  ];
  $elements['thumbnail_slider']['pager']['pager'] = [
    '#type' => 'hidden',
    '#default_value' => $settings['thumbnail_slider']['pager']['pager'],
  ];
  $elements['thumbnail_slider']['controls'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Controls'),
    '#weight' => 3,
    '#open' => FALSE,
  ];
  $elements['thumbnail_slider']['controls']['controls'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('controls'),
    '#default_value' => $settings['thumbnail_slider']['controls']['controls'],
  ];
  $elements['thumbnail_slider']['controls']['nextText'] = [
    '#title' => $this
      ->t('nextText'),
    '#type' => 'textfield',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['controls']['nextText'],
  ];
  $elements['thumbnail_slider']['controls']['prevText'] = [
    '#title' => $this
      ->t('prevText'),
    '#type' => 'textfield',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['controls']['prevText'],
  ];
  $elements['thumbnail_slider']['controls']['autoControls'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('autoControls'),
    '#default_value' => $settings['thumbnail_slider']['controls']['autoControls'],
  ];
  $elements['thumbnail_slider']['controls']['startText'] = [
    '#title' => $this
      ->t('startText'),
    '#type' => 'textfield',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['controls']['startText'],
  ];
  $elements['thumbnail_slider']['controls']['stopText'] = [
    '#title' => $this
      ->t('stopText'),
    '#type' => 'textfield',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['controls']['stopText'],
  ];
  $elements['thumbnail_slider']['controls']['autoControlsCombine'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Auto'),
    '#default_value' => $settings['thumbnail_slider']['controls']['autoControlsCombine'],
  ];
  $elements['thumbnail_slider']['auto'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Auto'),
    '#weight' => 4,
    '#open' => FALSE,
  ];
  $elements['thumbnail_slider']['auto']['auto'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Auto'),
    '#default_value' => $settings['thumbnail_slider']['auto']['auto'],
  ];
  $elements['thumbnail_slider']['auto']['pause'] = [
    '#title' => $this
      ->t('pause'),
    '#type' => 'textfield',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['auto']['pause'],
  ];
  $elements['thumbnail_slider']['auto']['autoStart'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('autoStart'),
    '#default_value' => $settings['thumbnail_slider']['auto']['autoStart'],
  ];
  $elements['thumbnail_slider']['auto']['autoDirection'] = [
    '#title' => $this
      ->t('autoDirection'),
    '#type' => 'select',
    '#default_value' => $settings['thumbnail_slider']['auto']['autoDirection'],
    '#options' => [
      'next' => 'next',
      'prev' => 'prev',
    ],
  ];
  $elements['thumbnail_slider']['auto']['autoHover'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('autoHover'),
    '#default_value' => $settings['thumbnail_slider']['auto']['autoHover'],
  ];
  $elements['thumbnail_slider']['auto']['autoDelay'] = [
    '#title' => $this
      ->t('autoDelay'),
    '#type' => 'textfield',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['auto']['autoDelay'],
  ];
  $elements['thumbnail_slider']['carousel'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Carousel'),
    '#weight' => 5,
    '#open' => FALSE,
  ];
  $elements['thumbnail_slider']['carousel']['minSlides'] = [
    '#title' => $this
      ->t('minSlides'),
    '#type' => 'number',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['carousel']['minSlides'],
  ];
  $elements['thumbnail_slider']['carousel']['maxSlides'] = [
    '#title' => $this
      ->t('maxSlides'),
    '#type' => 'number',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['carousel']['maxSlides'],
  ];
  $elements['thumbnail_slider']['carousel']['moveSlides'] = [
    '#title' => $this
      ->t('moveSlides'),
    '#type' => 'number',
    '#size' => 60,
    '#default_value' => $settings['thumbnail_slider']['carousel']['moveSlides'],
  ];
  return $elements;
}