You are here

public function AdminSettingsForm::tipsyOptionsForm in Tipsy 8

Implementation of form function for the tooltip options.

1 call to AdminSettingsForm::tipsyOptionsForm()
AdminSettingsForm::buildForm in src/Form/AdminSettingsForm.php
Form constructor.

File

src/Form/AdminSettingsForm.php, line 280

Class

AdminSettingsForm
Class AdminSettingsForm.

Namespace

Drupal\tipsy\Form

Code

public function tipsyOptionsForm($settings = FALSE, $drupal_forms = FALSE) {
  if ($settings == FALSE) {
    $settings = _tipsy_get_settings(TRUE);
  }
  $form = array();
  $form['fade'] = array(
    '#type' => 'checkbox',
    '#default_value' => $settings['options']['fade'],
    '#description' => $this
      ->t('This will make the tooltip fade.'),
    '#title' => $this
      ->t('Make Tipsy tooltips fade.'),
    '#weight' => 0,
    '#prefix' => '<div class="tipsy-selector-options clear-block">',
  );
  $form['gravity'] = array(
    '#type' => 'select',
    '#default_value' => $settings['options']['gravity'],
    '#title' => $this
      ->t('Tipsy arrow position'),
    '#description' => $this
      ->t('Specify the position of the tooltip when it appears.'),
    '#weight' => 2,
    '#options' => array(
      'nw' => $this
        ->t('North west'),
      'n' => $this
        ->t('North'),
      'ne' => $this
        ->t('North east'),
      'w' => $this
        ->t('West'),
      'e' => $this
        ->t('East'),
      'sw' => $this
        ->t('South west'),
      's' => $this
        ->t('South'),
      'se' => $this
        ->t('South east'),
      'autoNS' => $this
        ->t('Auto detect North/South'),
      'autoWE' => $this
        ->t('Auto detect West/East'),
    ),
  );
  $form['delayIn'] = array(
    '#type' => 'textfield',
    '#default_value' => $settings['options']['delayIn'],
    '#title' => $this
      ->t('Delay when appearing'),
    '#description' => $this
      ->t('Amount of milliseconds for the tooltip to appear.'),
    '#size' => 5,
    '#maxlength' => 5,
    '#weight' => 3,
  );
  $form['delayOut'] = array(
    '#type' => 'textfield',
    '#default_value' => $settings['options']['delayOut'],
    '#title' => $this
      ->t('Delay when disappearing'),
    '#description' => $this
      ->t('Amount of milliseconds for the tooltip to disappear.'),
    '#size' => 5,
    '#maxlength' => 5,
    '#weight' => 4,
  );
  $form['trigger'] = array(
    '#type' => 'select',
    '#default_value' => $settings['options']['trigger'],
    '#description' => $this
      ->t('Specify what action will make the tooltip appear.'),
    '#title' => $this
      ->t('Tipsy trigger'),
    '#weight' => 5,
    '#options' => array(
      'focus' => $this
        ->t('Focus'),
      'hover' => $this
        ->t('Hover'),
    ),
  );
  $form['opacity'] = array(
    '#type' => 'textfield',
    '#default_value' => $settings['options']['opacity'],
    '#title' => $this
      ->t('Tooltip opacity'),
    '#description' => $this
      ->t('A value between 0 and 1.'),
    '#size' => 5,
    '#maxlength' => 4,
    '#weight' => 6,
  );
  $form['offset'] = array(
    '#type' => 'textfield',
    '#default_value' => $settings['options']['offset'],
    '#title' => $this
      ->t('Tooltip offset'),
    '#description' => $this
      ->t('Number of pixels in which the tooltip will distance from the element.'),
    '#size' => 5,
    '#maxlength' => 5,
    '#weight' => 7,
  );
  if ($drupal_forms == FALSE) {
    $form['html'] = array(
      '#type' => 'checkbox',
      '#default_value' => $settings['options']['html'],
      '#description' => $this
        ->t('This will let HTML code be parsed inside the tooltip.'),
      '#title' => $this
        ->t('Allow HTML in tooltip content.'),
      '#weight' => 1,
    );
    $form['tooltip_content'] = array(
      '#type' => 'details',
      '#title' => $this
        ->t('Tooltip content'),
      '#weight' => 9,
      '#open' => TRUE,
    );
    $form['tooltip_content']['source'] = array(
      '#type' => 'radios',
      '#title' => $this
        ->t('Source'),
      '#default_value' => $settings['options']['tooltip_content']['source'],
      '#options' => array(
        'attribute' => $this
          ->t('HTML attribute'),
        'child' => $this
          ->t('Child element'),
      ),
    );
    $form['tooltip_content']['selector'] = array(
      '#type' => 'textarea',
      '#title' => $this
        ->t('Selector'),
      '#default_value' => $settings['options']['tooltip_content']['selector'],
      '#description' => $this
        ->t("The name of the HTML attribute or a selector pointing to the child element (e.g: .content). <br /> Refer to the module's README.txt for more information."),
      '#rows' => 1,
      '#maxlength' => 400,
    );
  }
  $form['closure'] = array(
    '#weight' => 10,
    '#suffix' => '</div>',
  );
  return $form;
}