475d906872db82dc0b628ee32f3ed52faa26ced2
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Setting / JavaScript / Popovers / PopoverAnimation.php
1 <?php
2
3 namespace Drupal\bootstrap\Plugin\Setting\JavaScript\Popovers;
4
5 use Drupal\bootstrap\Plugin\Setting\SettingBase;
6 use Drupal\bootstrap\Utility\Element;
7 use Drupal\Core\Form\FormStateInterface;
8
9 /**
10  * The "popover_animation" theme setting.
11  *
12  * @ingroup plugins_setting
13  *
14  * @BootstrapSetting(
15  *   id = "popover_animation",
16  *   type = "checkbox",
17  *   title = @Translation("animation"),
18  *   description = @Translation("Apply a CSS fade transition to the popover."),
19  *   defaultValue = 1,
20  *   groups = {
21  *     "javascript" = @Translation("JavaScript"),
22  *     "popovers" = @Translation("Popovers"),
23  *     "options" = @Translation("Options"),
24  *   },
25  * )
26  */
27 class PopoverAnimation 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('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>.'));
37     $group->setProperty('states', [
38       'visible' => [
39         ':input[name="popover_enabled"]' => ['checked' => TRUE],
40       ],
41     ]);
42   }
43
44   /**
45    * {@inheritdoc}
46    */
47   public function drupalSettings() {
48     return !!$this->theme->getSetting('popover_enabled');
49   }
50
51 }