file TooltipEnabled.php

Namespace

Drupal\bootstrap\Plugin\Setting\JavaScript\Tooltips
  1. <?php
  2. namespace Drupal\bootstrap\Plugin\Setting\JavaScript\Tooltips;
  3. use Drupal\bootstrap\Plugin\Setting\SettingBase;
  4. use Drupal\bootstrap\Utility\Element;
  5. use Drupal\Core\Form\FormStateInterface;
  6. /**
  7. * The "tooltip_enabled" theme setting.
  8. *
  9. * @ingroup plugins_setting
  10. *
  11. * @BootstrapSetting(
  12. * id = "tooltip_enabled",
  13. * type = "checkbox",
  14. * title = @Translation("Enable Bootstrap Tooltips"),
  15. * description = @Translation("Elements that have the <code>data-toggle=&quot;tooltip&quot;</code> attribute set will automatically initialize the tooltip upon page load. <div class='alert alert-warning alert-sm'><strong>WARNING:</strong> This feature can sometimes impact performance. Disable if pages appear to &quot;hang&quot; after load.</div>"),
  16. * defaultValue = 1,
  17. * weight = -1,
  18. * groups = {
  19. * "javascript" = @Translation("JavaScript"),
  20. * "tooltips" = @Translation("Tooltips"),
  21. * },
  22. * )
  23. */
  24. class TooltipEnabled extends SettingBase {
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
  29. parent::alterFormElement($form, $form_state, $form_id);
  30. $group = $this->getGroupElement($form, $form_state);
  31. $group->setProperty('description', t('Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; Tooltips are an updated version, which don\'t rely on images, use CSS3 for animations, and data-attributes for local title storage. See <a href=":url" target="_blank">Bootstrap tooltips</a> for more documentation.', [
  32. ':url' => 'https://getbootstrap.com/docs/3.4/javascript/#tooltips',
  33. ]));
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function drupalSettings() {
  39. return !!$this->theme->getSetting('tooltip_enabled');
  40. }
  41. }

Classes

Name Description
TooltipEnabled The "tooltip_enabled" theme setting.