04e5711c912e7b0520112da77ff040f9b358fd5c
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Setting / JavaScript / Tooltips / TooltipEnabled.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\bootstrap\Plugin\Setting\JavaScript\Tooltips\TooltipEnabled.
5  */
6
7 namespace Drupal\bootstrap\Plugin\Setting\JavaScript\Tooltips;
8
9 use Drupal\bootstrap\Annotation\BootstrapSetting;
10 use Drupal\bootstrap\Plugin\Setting\SettingBase;
11 use Drupal\bootstrap\Utility\Element;
12 use Drupal\Core\Annotation\Translation;
13 use Drupal\Core\Form\FormStateInterface;
14
15 /**
16  * The "tooltip_enabled" theme setting.
17  *
18  * @ingroup plugins_setting
19  *
20  * @BootstrapSetting(
21  *   id = "tooltip_enabled",
22  *   type = "checkbox",
23  *   title = @Translation("Enable Bootstrap Tooltips"),
24  *   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>"),
25  *   defaultValue = 1,
26  *   weight = -1,
27  *   groups = {
28  *     "javascript" = @Translation("JavaScript"),
29  *     "tooltips" = @Translation("Tooltips"),
30  *   },
31  * )
32  */
33 class TooltipEnabled extends SettingBase {
34
35   /**
36    * {@inheritdoc}
37    */
38   public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
39     parent::alterFormElement($form, $form_state, $form_id);
40
41     $group = $this->getGroupElement($form, $form_state);
42     $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.', [
43       ':url' => 'http://getbootstrap.com/javascript/#tooltips',
44     ]));
45   }
46
47   /**
48    * {@inheritdoc}
49    */
50   public function drupalSettings() {
51     return !!$this->theme->getSetting('tooltip_enabled');
52   }
53
54 }