You are here

public function FieldSlideshow::settingsForm in Field Slideshow 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldFormatter/FieldSlideshow.php \Drupal\field_slideshow\Plugin\Field\FieldFormatter\FieldSlideshow::settingsForm()
  2. 8.2 src/Plugin/Field/FieldFormatter/FieldSlideshow.php \Drupal\field_slideshow\Plugin\Field\FieldFormatter\FieldSlideshow::settingsForm()

Settings form.

Parameters

array $form: Form.

\Drupal\Core\Form\FormStateInterface $form_state: Form state.

Return value

array|mixed Form array.

Overrides ImageFormatter::settingsForm

File

src/Plugin/Field/FieldFormatter/FieldSlideshow.php, line 223

Class

FieldSlideshow
Plugin implementation of the 'slideshow' formatter.

Namespace

Drupal\field_slideshow\Plugin\Field\FieldFormatter

Code

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

  // Colorbox support.
  if ($this->moduleHandler
    ->moduleExists('colorbox')) {
    $form['image_link']['#options']['colorbox'] = 'Colorbox';
    $form['colorbox_image_style'] = [
      '#title' => $this
        ->t('Colorbox image style'),
      '#type' => 'select',
      '#default_value' => $this
        ->getSetting('colorbox_image_style'),
      '#empty_option' => $this
        ->t('None (original image)'),
      '#options' => image_style_options(FALSE),
      '#states' => [
        'visible' => [
          ':input[name$="[settings_edit_form][settings][image_link]"]' => [
            'value' => 'colorbox',
          ],
        ],
      ],
    ];
  }
  $form['slideshow'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Slideshow settings'),
    '#open' => FALSE,
  ];
  $form['slideshow']['fx'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Transition'),
    '#required' => TRUE,
    '#options' => $this
      ->getTransitions(),
    '#default_value' => $this
      ->getSetting('slideshow')['fx'],
  ];
  $form['slideshow']['allowWrap'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Allow wrap'),
    '#default_value' => $this
      ->getSetting('slideshow')['allowWrap'],
  ];
  $form['slideshow']['autoHeight'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Auto height'),
    '#default_value' => $this
      ->getSetting('slideshow')['autoHeight'],
  ];
  $form['slideshow']['delay'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Delay'),
    '#description' => $this
      ->t('The number of milliseconds to add onto, or substract from, the time before the first slide transition occurs.'),
    '#default_value' => $this
      ->getSetting('slideshow')['delay'],
  ];
  $form['slideshow']['hideNonActive'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Hide non active'),
    '#description' => $this
      ->t('Determines whether or not Cycle2 hides the inactive slides.'),
    '#default_value' => $this
      ->getSetting('slideshow')['hideNonActive'],
  ];
  $form['slideshow']['loader'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Loader'),
    '#options' => [
      'true' => 'True',
      'false' => 'False',
      'wait' => 'Wait',
    ],
    '#default_value' => $this
      ->getSetting('slideshow')['loader'],
  ];
  $form['slideshow']['loop'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Loop'),
    '#description' => $this
      ->t('The number of times an auto-advancing slideshow should loop before terminating. If the value is less than 1 then the slideshow will loop continuously. Set to 1 to loop once, etc. Setting the allow-wrap option to false will override looping.'),
    '#min' => 0,
    '#step' => 1,
    '#default_value' => $this
      ->getSetting('slideshow')['loop'],
  ];
  $form['slideshow']['pauseOnHover'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Pause on hover'),
    '#description' => $this
      ->t('If true an auto-running slideshow will be paused while the mouse is over the slideshow.'),
    '#default_value' => $this
      ->getSetting('slideshow')['pauseOnHover'],
  ];
  $form['slideshow']['paused'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Paused'),
    '#description' => $this
      ->t('If true the slideshow will begin in a paused state.'),
    '#default_value' => $this
      ->getSetting('slideshow')['paused'],
  ];
  $form['slideshow']['random'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Random'),
    '#description' => $this
      ->t("If true the order of the slides will be randomized. This only effects slides that are initially in the markup, not slides added via the add command or via Cycle2's image loader functionality."),
    '#default_value' => $this
      ->getSetting('slideshow')['random'],
  ];
  $form['slideshow']['reverse'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Reverse'),
    '#description' => $this
      ->t('If true the slideshow will proceed in reverse order and transitions that support this option will run a reverse animation.'),
    '#default_value' => $this
      ->getSetting('slideshow')['reverse'],
  ];
  $form['slideshow']['speed'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Speed'),
    '#description' => $this
      ->t('The speed of the transition effect in milliseconds.'),
    '#min' => 0,
    '#step' => 1,
    '#default_value' => $this
      ->getSetting('slideshow')['speed'],
  ];
  $form['slideshow']['startingSlide'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Starting slide'),
    '#description' => $this
      ->t('The zero-based index of the slide that should be initially displayed.'),
    '#min' => 0,
    '#step' => 1,
    '#default_value' => $this
      ->getSetting('slideshow')['startingSlide'],
  ];
  $form['slideshow']['swipe'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Swipe'),
    '#description' => $this
      ->t('Set to true to enable swipe gesture support for advancing the slideshow forward or back. You should downlad cycle2.swipe plugin and place it in /libraries/jquery.cycle2/ directory.'),
    '#default_value' => $this
      ->getSetting('slideshow')['swipe'],
  ];
  $form['slideshow']['sync'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Sync'),
    '#description' => $this
      ->t('If true then animation of the incoming and outgoing slides will be synchronized. If false then the animation for the incoming slide will not start until the animation for the outgoing slide completes.'),
    '#default_value' => $this
      ->getSetting('slideshow')['sync'],
  ];
  $form['slideshow']['timeout'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Tmeout'),
    '#description' => $this
      ->t('The time between slide transitions in milliseconds.'),
    '#min' => 0,
    '#step' => 1,
    '#default_value' => $this
      ->getSetting('slideshow')['timeout'],
  ];
  $form['slideshow_pager'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Slideshow pager settings'),
    '#open' => FALSE,
  ];
  $form['slideshow_pager']['pager'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Pager'),
    '#options' => [
      'before' => $this
        ->t('Before'),
      'after' => $this
        ->t('After'),
    ],
    '#default_value' => $this
      ->getSetting('slideshow_pager')['pager'],
  ];
  $form['slideshow_pager']['pager_type'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Pager type'),
    '#options' => $this
      ->getPagerTypes(),
    '#default_value' => $this
      ->getSetting('slideshow_pager')['pager_type'],
  ];
  $form['slideshow_pager']['controls'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Controls'),
    '#default_value' => $this
      ->getSetting('slideshow_pager')['controls'],
  ];
  return $form;
}