Version 1
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Setting / JavaScript / Popovers / PopoverEnabled.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\bootstrap\Plugin\Setting\JavaScript\Popovers\PopoverEnabled.
5  */
6
7 namespace Drupal\bootstrap\Plugin\Setting\JavaScript\Popovers;
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 "popover_enabled" theme setting.
17  *
18  * @ingroup plugins_setting
19  *
20  * @BootstrapSetting(
21  *   id = "popover_enabled",
22  *   type = "checkbox",
23  *   title = @Translation("Enable Bootstrap Popovers"),
24  *   description = @Translation("Elements that have the <code>data-toggle=&quot;popover&quot;</code> attribute set will automatically initialize the popover upon page load. <strong class='error text-error'>WARNING: This feature can sometimes impact performance. Disable if pages appear to hang after initial load.</strong>"),
25  *   defaultValue = 1,
26  *   weight = -1,
27  *   groups = {
28  *     "javascript" = @Translation("JavaScript"),
29  *     "popovers" = @Translation("Popovers"),
30  *   },
31  * )
32  */
33 class PopoverEnabled 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('Add small overlays of content, like those on the iPad, to any element for housing secondary information.'));
43   }
44
45   /**
46    * {@inheritdoc}
47    */
48   public function drupalSettings() {
49     return !!$this->theme->getSetting('popover_enabled');
50   }
51
52 }