You are here

public function ElevateZoomPlusForm::getFormElements in ElevateZoom Plus 8

Same name and namespace in other branches
  1. 7 modules/ui/src/Form/ElevateZoomPlusForm.php \Drupal\elevatezoomplus_ui\Form\ElevateZoomPlusForm::getFormElements()

Defines available options.

Return value

array All available options.

1 call to ElevateZoomPlusForm::getFormElements()
ElevateZoomPlusForm::attachSettingsForm in modules/ui/src/Form/ElevateZoomPlusForm.php
Attach the settings form.

File

modules/ui/src/Form/ElevateZoomPlusForm.php, line 349

Class

ElevateZoomPlusForm
Extends base form for elevatezoomplus instance configuration form.

Namespace

Drupal\elevatezoomplus_ui\Form

Code

public function getFormElements() {
  if (!isset($this->formElements)) {
    $elements = [];

    // @todo provide relevant respond options.
    $elements['responsive'] = [
      'type' => 'checkbox',
      'title' => $this
        ->t('Responsive'),
      'description' => $this
        ->t('Set to true to activate responsivenes. If you have a theme which changes size, or tablets which change orientation this is needed to be on.'),
      'access' => FALSE,
    ];
    $options = [
      'inner' => 'Inner',
      'lens' => 'Lens',
      'window' => 'Window',
    ];
    $elements['zoomType'] = [
      'type' => 'select',
      'title' => $this
        ->t('zoomType'),
      'options' => $options,
      'description' => $this
        ->t('The zoom type.'),
    ];
    $elements['zoomWindowWidth'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('zoomWindowWidth'),
      'description' => $this
        ->t('Width of the zoomWindow (Note: zoomType must be "window").'),
    ];
    $elements['zoomWindowHeight'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('zoomWindowHeight'),
      'description' => $this
        ->t('Height of the zoomWindow (Note: zoomType must be "window").'),
    ];
    $elements['zoomWindowOffsetX'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('zoomWindowOffsetX'),
      'description' => $this
        ->t('The x-axis offset of the zoom window.'),
    ];
    $elements['zoomWindowOffsetY'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('zoomWindowOffsetY'),
      'description' => $this
        ->t('The y-axis offset of the zoom window.'),
    ];
    $elements['zoomWindowPosition'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('zoomWindowPosition'),
      'description' => $this
        ->t('Accepts a position, a selector or an element Id. For positions, once positioned, use zoomWindowOffsetX and zoomWindowOffsetY to adjust. Possible values: 1-16.'),
    ];
    $elements['zoomWindowFadeIn'] = [
      'type' => 'checkbox',
      'title' => $this
        ->t('zoomWindowFadeIn'),
      'description' => $this
        ->t('Set as a number e.g 200 for speed of Window fadeIn.'),
    ];
    $elements['zoomWindowFadeOut'] = [
      'type' => 'checkbox',
      'title' => $this
        ->t('zoomWindowFadeOut'),
      'description' => $this
        ->t('Set as a number e.g 200 for speed of Window fadeOut.'),
    ];
    $elements['zoomTintFadeIn'] = [
      'type' => 'checkbox',
      'title' => $this
        ->t('zoomTintFadeIn'),
      'description' => $this
        ->t('Set as a number e.g 200 for speed of Tint fadeIn.'),
    ];
    $elements['zoomTintFadeOut'] = [
      'type' => 'checkbox',
      'title' => $this
        ->t('zoomTintFadeOut'),
      'description' => $this
        ->t('Set as a number e.g 200 for speed of Tint fadeOut.'),
    ];
    $elements['scrollZoom'] = [
      'type' => 'checkbox',
      'title' => $this
        ->t('scrollZoom'),
      'description' => $this
        ->t('Set to true to activate zoom on mouse scroll.'),
    ];
    $elements['imageCrossfade'] = [
      'type' => 'checkbox',
      'title' => $this
        ->t('imageCrossfade'),
      'description' => $this
        ->t('Set to true to activate simultaneous crossfade of images on gallery change.'),
    ];
    $elements['easing'] = [
      'type' => 'checkbox',
      'title' => $this
        ->t('easing'),
      'description' => $this
        ->t('Set to true to activate easing.'),
    ];
    $elements['easingType'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('easingType'),
      'description' => $this
        ->t('Default easing type is <code>easeOutExpo, (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b</code>. Extend jquery with other easing types before initiating the plugin and pass the easing type as a string value.'),
    ];
    $elements['easingDuration'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('easingDuration'),
      'description' => $this
        ->t('The easing duration.'),
    ];
    $elements['showLens'] = [
      'type' => 'checkbox',
      'title' => $this
        ->t('showLens'),
      'description' => $this
        ->t('Set to false to hide the Lens.'),
    ];
    $elements['lensSize'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('lensSize'),
      'description' => $this
        ->t('Used when zoomType set to lens, when zoom type is set to window, then the lens size is auto calculated.'),
    ];
    $elements['lensFadeIn'] = [
      'type' => 'checkbox',
      'title' => $this
        ->t('lensFadeIn'),
      'description' => $this
        ->t('Set as a number e.g 200 for speed of Lens fadeIn.'),
    ];
    $elements['lensFadeOut'] = [
      'type' => 'checkbox',
      'title' => $this
        ->t('lensFadeOut'),
      'description' => $this
        ->t('Set as a number e.g 200 for speed of Lens fadeOut.'),
    ];
    $elements['borderSize'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('borderSize'),
      'description' => $this
        ->t('Border Size of the ZoomBox - Must be set here as border taken into account for plugin calculations.'),
    ];
    $elements['borderColour'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('borderColour'),
      'description' => $this
        ->t('Border Color.'),
    ];
    $elements['lensBorder'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('lensBorder'),
      'description' => $this
        ->t('Width in pixels of the lens border.'),
      'field_suffix' => 'px',
    ];
    $elements['lensShape'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('lensShape'),
      'description' => $this
        ->t('Can also be round (note that only modern browsers support round, will default to square in older browsers).'),
    ];
    $elements['containLensZoom'] = [
      'type' => 'checkbox',
      'title' => $this
        ->t('containLensZoom'),
      'description' => $this
        ->t('For use with the Lens Zoom Type. This makes sure the lens does not fall outside the outside of the image.'),
    ];
    $elements['lensColour'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('lensColour'),
      'description' => $this
        ->t('Color of the lens background.'),
    ];
    $elements['lensOpacity'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('lensOpacity'),
      'description' => $this
        ->t('Used in combination with lensColour to make the lens see through. When using tint, this is overrided to 0.'),
    ];
    $elements['lenszoom'] = [
      'type' => 'checkbox',
      'title' => $this
        ->t('lenszoom'),
      'description' => $this
        ->t('The lens zoom.'),
    ];
    $elements['tint'] = [
      'type' => 'checkbox',
      'title' => $this
        ->t('tint'),
      'description' => $this
        ->t('Enable a tint overlay.'),
    ];
    $elements['tintColour'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('tintColour'),
      'description' => $this
        ->t('Color of the tint, can be #hex, word (red, blue), or rgb(x, x, x).'),
    ];
    $elements['tintOpacity'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('tintOpacity'),
      'description' => $this
        ->t('Opacity of the tint.'),
    ];
    $elements['constrainType'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('constrainType'),
      'description' => $this
        ->t('Constraint type.'),
    ];
    $elements['constrainSize'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('constrainSize'),
      'description' => $this
        ->t('Constraint size.'),
    ];

    // @todo exclude below from responsive options.
    $elements['cursor'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('cursor'),
      'description' => $this
        ->t('The default cursor is usually the arrow, if using a lightbox, then set the cursor to pointer so it looks clickable - Options are default, cursor, crosshair.'),
    ];

    // This has inconsistent schema, boolean vs string, adjust at front-end.
    $elements['loadingIcon'] = [
      'type' => 'textfield',
      'title' => $this
        ->t('loadingIcon'),
      'description' => $this
        ->t('Set to the url of the spinner icon to activate, e.g, http://www.example.com/spinner.gif.'),
    ];

    // Defines the default values if available.
    $defaults = ElevateZoomPlus::defaultSettings();
    foreach ($elements as $name => $element) {
      $fallback = $element['type'] == 'checkbox' ? FALSE : '';
      $elements[$name]['default'] = isset($defaults[$name]) ? $defaults[$name] : $fallback;
    }
    $this->formElements = $elements;
  }
  return $this->formElements;
}