You are here

public function Jssor::buildOptionsForm in Jssor Slider 8

Same name in this branch
  1. 8 src/Plugin/views/style/Jssor.php \Drupal\jssor\Plugin\views\style\Jssor::buildOptionsForm()
  2. 8 src/Plugin/views/row/Jssor.php \Drupal\jssor\Plugin\views\row\Jssor::buildOptionsForm()

Provide a form for setting options.

Overrides RowPluginBase::buildOptionsForm

File

src/Plugin/views/row/Jssor.php, line 46
Definition of Drupal\jssor\Plugin\views\row\Jssor.

Class

Jssor
Row handler plugin for displaying search results.

Namespace

Drupal\jssor\Plugin\views\row

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);

  // Get all image and text fields.
  $image_options = [];
  $caption_options = [];
  $transitions_options = [
    'Move' => [
      'L' => 'L',
      'R' => 'R',
      'T' => 'T',
      'B' => 'B',
      'TL' => 'TL',
      'TR' => 'TR',
      'BL' => 'BL',
      'BR' => 'BR',
    ],
    'Move|IB' => [
      'L|IB' => 'L|IB',
      'R|IB' => 'R|IB',
      'T|IB' => 'T|IB',
      'B|IB' => 'B|IB',
      'TL|IB' => 'TL|IB',
      'TR|IB' => 'TR|IB',
      'BL|IB' => 'BL|IB',
      'BR|IB' => 'BR|IB',
    ],
    'Move|IE' => [
      'L|IE' => 'L|IE',
      'R|IE' => 'R|IE',
      'T|IE' => 'T|IE',
      'B|IE' => 'B|IE',
      'TL|IE' => 'TL|IE',
      'TR|IE' => 'TR|IE',
      'BL|IE' => 'BL|IE',
      'BR|IE' => 'BR|IE',
    ],
    'Move|EP' => [
      'L|EP' => 'L|EP',
      'R|EP' => 'R|EP',
      'T|EP' => 'T|EP',
      'B|EP' => 'B|EP',
      'TL|EP' => 'TL|EP',
      'TR|EP' => 'TR|EP',
      'BL|EP' => 'BL|EP',
      'BR|EP' => 'BR|EP',
    ],
    'Move with Rotate' => [
      'L*' => 'L*',
      'R*' => 'R*',
      'T*' => 'T*',
      'B*' => 'B*',
      'TL*' => 'TL*',
      'TR*' => 'TR*',
      'BL*' => 'BL*',
      'BR*' => 'BR*',
    ],
    'Move with Rotate IE' => [
      'L*IE' => 'L*IE',
      'R*IE' => 'R*IE',
      'T*IE' => 'T*IE',
      'B*IE' => 'B*IE',
      'TL*IE' => 'TL*IE',
      'TR*IE' => 'TR*IE',
      'BL*IE' => 'BL*IE',
      'BR*IE' => 'BR*IE',
    ],
    'Move with Rotate IB' => [
      'L*IB' => 'L*IB',
      'R*IB' => 'R*IB',
      'T*IB' => 'T*IB',
      'B*IB' => 'B*IB',
      'TL*IB' => 'TL*IB',
      'TR*IB' => 'TR*IB',
      'BL*IB' => 'BL*IB',
      'BR*IB' => 'BR*IB',
    ],
    'Move with Rotate IW' => [
      'L*IW' => 'L*IW',
      'R*IW' => 'R*IW',
      'T*IW' => 'T*IW',
      'B*IW' => 'B*IW',
      'TL*IW' => 'TL*IW',
      'TR*IW' => 'TR*IW',
      'BL*IW' => 'BL*IW',
      'BR*IW' => 'BR*IW',
    ],
    'Move IE with Rotate IE' => [
      'L*IE*IE' => 'L*IE*IE',
      'R*IE*IE' => 'R*IE*IE',
      'T*IE*IE' => 'T*IE*IE',
      'B*IE*IE' => 'B*IE*IE',
      'TL*IE*IE' => 'TL*IE*IE',
      'TR*IE*IE' => 'TR*IE*IE',
      'BL*IE*IE' => 'BL*IE*IE',
      'BR*IE*IE' => 'BR*IE*IE',
    ],
    'Clip' => [
      'CLIP' => 'CLIP',
      'CLIP|LR' => 'CLIP|LR',
      'CLIP|TB' => 'CLIP|TB',
      'CLIP|L' => 'CLIP|L',
      'CLIP|R' => 'CLIP|R',
      'CLIP|T' => 'CLIP|T',
      'CLIP|B' => 'CLIP|B',
    ],
    'MClip' => [
      'MCLIP|L' => 'MCLIP|L',
      'MCLIP|R' => 'MCLIP|R',
      'MCLIP|T' => 'MCLIP|T',
      'MCLIP|B' => 'MCLIP|B',
    ],
    'Zoom' => [
      'ZM' => 'ZM',
      'ZM|P30' => 'ZM|P30',
      'ZM|P50' => 'ZM|P50',
      'ZM|P70' => 'ZM|P70',
      'ZM|P80' => 'ZM|P80',
      'ZMF|2' => 'ZMF|2',
      'ZMF|3' => 'ZMF|3',
      'ZMF|4' => 'ZMF|4',
      'ZMF|5' => 'ZMF|5',
      'ZMF|10' => 'ZMF|10',
      'ZML|L' => 'ZML|L',
      'ZML|R' => 'ZML|R',
      'ZML|T' => 'ZML|T',
      'ZML|B' => 'ZML|B',
      'ZML|TL' => 'ZML|TL',
      'ZML|TR' => 'ZML|TR',
      'ZML|BL' => 'ZML|BL',
      'ZML|BR' => 'ZML|BR',
      'ZML|IE|L' => 'ZML|IE|L',
      'ZML|IE|R' => 'ZML|IE|R',
      'ZML|IE|T' => 'ZML|IE|T',
      'ZML|IE|B' => 'ZML|IE|B',
      'ZML|IE|TL' => 'ZML|IE|TL',
      'ZML|IE|TR' => 'ZML|IE|TR',
      'ZML|IE|BL' => 'ZML|IE|BL',
      'ZML|IE|BR' => 'ZML|IE|BR',
      'ZMS|L' => 'ZMS|L',
      'ZMS|R' => 'ZMS|R',
      'ZMS|T' => 'ZMS|T',
      'ZMS|B' => 'ZMS|B',
      'ZMS|TL' => 'ZMS|TL',
      'ZMS|TR' => 'ZMS|TR',
      'ZMS|BL' => 'ZMS|BL',
      'ZMS|BR' => 'ZMS|BR',
    ],
  ];
  if ($fields = $this->view->display_handler
    ->getOption('fields')) {
    foreach ($fields as $id => $field) {
      switch ($field['type']) {
        case 'image':
          $image_options[$id] = $field['id'];
          break;
        case 'string':
          $caption_options[$id] = $field['id'];
          break;
      }
    }
  }
  $form['image_options'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Image field'),
    '#description' => $this
      ->t('Select image field.'),
    '#options' => $image_options,
    '#default_value' => $this->options['image_options'],
  );
  $form['caption_options'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Caption field'),
    '#description' => $this
      ->t('Select caption field.'),
    '#options' => $caption_options,
    '#default_value' => $this->options['caption_options'],
  );
  $form['play_in_mode'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Play in mode'),
    '#description' => $this
      ->t('Specifies how captions will play in.'),
    '#options' => [
      0 => $this
        ->t('No play'),
      1 => $this
        ->t('Goes after main slide played in, play captions in one by one'),
      3 => $this
        ->t('Goes after main slide played in, play all captions in parallelly'),
    ],
    '#default_value' => $this->options['play_in_mode'],
  ];
  $form['play_in_transition'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Transition'),
    '#description' => $this
      ->t('Transition.'),
    '#options' => $transitions_options,
    '#default_value' => $this->options['play_in_transition'],
  ];
  $form['play_out_mode'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Play in mode'),
    '#description' => $this
      ->t('Specifies how captions will play in.'),
    '#options' => [
      0 => $this
        ->t('No play'),
      1 => $this
        ->t('Goes after main slide played in, play captions in one by one'),
      3 => $this
        ->t('Goes after main slide played in, play all captions in parallelly'),
    ],
    '#default_value' => $this->options['play_out_mode'],
  ];
  $form['play_out_transition'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Transition'),
    '#description' => $this
      ->t('Transition.'),
    '#options' => $transitions_options,
    '#default_value' => $this->options['play_out_transition'],
  ];
}