Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Setting / JavaScript / Tooltips / TooltipEnabled.php
1 <?php
2
3 namespace Drupal\bootstrap\Plugin\Setting\JavaScript\Tooltips;
4
5 use Drupal\bootstrap\Plugin\Setting\SettingBase;
6 use Drupal\bootstrap\Utility\Element;
7 use Drupal\Core\Form\FormStateInterface;
8
9 /**
10  * The "tooltip_enabled" theme setting.
11  *
12  * @ingroup plugins_setting
13  *
14  * @BootstrapSetting(
15  *   id = "tooltip_enabled",
16  *   type = "checkbox",
17  *   title = @Translation("Enable Bootstrap Tooltips"),
18  *   description = @Translation("Elements that have the <code>data-toggle=&quote;tooltip&quote;</code> attribute set will automatically initialize the tooltip upon page load. <strong class='error text-error'>WARNING: This feature can sometimes impact performance. Disable if pages appear to &quote;hang&quote; after initial load.</strong>"),
19  *   defaultValue = 1,
20  *   weight = -1,
21  *   groups = {
22  *     "javascript" = @Translation("JavaScript"),
23  *     "tooltips" = @Translation("Tooltips"),
24  *   },
25  * )
26  */
27 class TooltipEnabled extends SettingBase {
28
29   /**
30    * {@inheritdoc}
31    */
32   public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
33     parent::alterFormElement($form, $form_state, $form_id);
34
35     $group = $this->getGroupElement($form, $form_state);
36     $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.', [
37       ':url' => 'https://getbootstrap.com/docs/3.3/javascript/#tooltips',
38     ]));
39   }
40
41   /**
42    * {@inheritdoc}
43    */
44   public function drupalSettings() {
45     return !!$this->theme->getSetting('tooltip_enabled');
46   }
47
48 }