You are here

public function DrupalSlider::buildOptionsForm in Drupal Slider 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/style/DrupalSlider.php \Drupal\drupal_slider\Plugin\views\style\DrupalSlider::buildOptionsForm()

Function buildOptionsForm.

Overrides StylePluginBase::buildOptionsForm

File

src/Plugin/views/style/DrupalSlider.php, line 63

Class

DrupalSlider
Views_style_plugins for drupal_slider.

Namespace

Drupal\drupal_slider\Plugin\views\style

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $fields = $this
    ->getAvailableFields();
  if (empty($fields)) {
    drupal_set_message($this
      ->t('To configure Drupal Slider you have to add at least one field'), 'error');
    return $form;
  }
  $form['general'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('General Settings'),
    '#open' => TRUE,
  ];
  $form['general']['width'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Width'),
    '#description' => $this
      ->t('The width of the slider. Eg 200px or 50%.'),
    '#default_value' => $this->options['general']['width'],
  ];
  $form['general']['height'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Height'),
    '#default_value' => $this->options['general']['height'],
    '#description' => $this
      ->t('The height of the slider. Eg 200px. Dont use %.'),
  ];
  $form['general']['arrows'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Arrows'),
    '#default_value' => $this->options['general']['arrows'],
    '#description' => $this
      ->t('Navigation arrows on slides.'),
  ];
  $form['general']['buttons'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Buttons'),
    '#default_value' => $this->options['general']['buttons'],
    '#description' => $this
      ->t('Shows current slide position'),
  ];
  $form['general']['autoplay'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Autoplay'),
    '#default_value' => $this->options['general']['autoplay'],
    '#description' => $this
      ->t('Autoplay the slides.'),
  ];
  $form['general']['autoplayDelay'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Autoplay delay'),
    '#default_value' => $this->options['general']['autoplayDelay'],
    '#description' => $this
      ->t('Sets the delay/interval (in milliseconds) at which the autoplay will run.'),
  ];
  $form['general']['shuffle'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Shuffle the slides'),
    '#default_value' => $this->options['general']['shuffle'],
    '#description' => $this
      ->t('Shuffles the slides.'),
  ];
  $form['general']['fade'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Fade effect'),
    '#default_value' => $this->options['general']['fade'],
    '#description' => $this
      ->t('Fade effect on transition.'),
  ];
  $form['general']['carousel'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Show carousel instead of slider'),
    '#default_value' => $this->options['general']['carousel'],
    '#description' => $this
      ->t('By checking this it will turn into carousel. The image width should be less than window size.'),
  ];
  $form['general']['full_screen'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Full screen'),
    '#default_value' => $this->options['general']['full_screen'],
    '#description' => $this
      ->t('Add full screen button to the slider'),
  ];
  $form['general']['loop'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Loops slides'),
    '#default_value' => $this->options['general']['full_screen'],
    '#description' => $this
      ->t('slider will repeat the slides.'),
  ];
  $form['general']['orientation'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Vertical orientation'),
    '#default_value' => $this->options['general']['orientation'],
    '#description' => $this
      ->t('Indicates whether the slides will be arranged horizontally or vertically.'),
  ];
  $form['general']['thumbnails_position'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Thumbnails Position'),
    '#options' => [
      'bottom' => 'Bottom',
      'top' => 'Top',
      'left' => 'Left',
      'right' => 'Right',
    ],
    '#default_value' => $this->options['general']['thumbnails_position'],
  ];
}