27a9c1a8796aa14f4fe1a3164e2081599afc3879
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Setting / JavaScript / Modals / ModalFocusInput.php
1 <?php
2
3 namespace Drupal\bootstrap\Plugin\Setting\JavaScript\Modals;
4
5 use Drupal\bootstrap\Plugin\Setting\SettingBase;
6 use Drupal\bootstrap\Utility\Element;
7 use Drupal\Core\Form\FormStateInterface;
8
9 /**
10  * The "modal_focus_input" theme setting.
11  *
12  * @ingroup plugins_setting
13  *
14  * @BootstrapSetting(
15  *   id = "modal_focus_input",
16  *   type = "checkbox",
17  *   title = @Translation("focusInput"),
18  *   description = @Translation("Enabling this focuses on the first available and visible input found in the modal after it's opened."),
19  *   defaultValue = 1,
20  *   groups = {
21  *     "javascript" = @Translation("JavaScript"),
22  *     "modals" = @Translation("Modals"),
23  *     "options" = @Translation("Options"),
24  *   },
25  * )
26  */
27 class ModalFocusInput 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     $setting = $this->getSettingElement($form, $form_state);
35     $setting->setProperty('states', [
36       'visible' => [
37         ':input[name="modal_enabled"]' => ['checked' => TRUE],
38       ],
39     ]);
40   }
41
42   /**
43    * {@inheritdoc}
44    */
45   public function drupalSettings() {
46     return !!$this->theme->getSetting('modal_enabled');
47   }
48
49   /**
50    * {@inheritdoc}
51    */
52   public function getCacheTags() {
53     return ['rendered', 'library_info'];
54   }
55
56 }