Version 1
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Setting / JavaScript / Popovers / PopoverAnimation.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\bootstrap\Plugin\Setting\JavaScript\Popovers\PopoverAnimation.
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_animation" theme setting.
17  *
18  * @ingroup plugins_setting
19  *
20  * @BootstrapSetting(
21  *   id = "popover_animation",
22  *   type = "checkbox",
23  *   title = @Translation("animation"),
24  *   description = @Translation("Apply a CSS fade transition to the popover."),
25  *   defaultValue = 1,
26  *   groups = {
27  *     "javascript" = @Translation("JavaScript"),
28  *     "popovers" = @Translation("Popovers"),
29  *     "options" = @Translation("Options"),
30  *   },
31  * )
32  */
33 class PopoverAnimation 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('These are global options. Each popover can independently override desired settings by appending the option name to <code>data-</code>. Example: <code>data-animation="false"</code>.'));
43     $group->setProperty('states', [
44       'visible' => [
45         ':input[name="popover_enabled"]' => ['checked' => TRUE],
46       ],
47     ]);
48   }
49
50   /**
51    * {@inheritdoc}
52    */
53   public function drupalSettings() {
54     return !!$this->theme->getSetting('popover_enabled');
55   }
56
57 }