9a8cb5f7a572c27086f35e83c40f1d18d0eb8af3
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Setting / JavaScript / Modals / ModalSelectText.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_select_text" theme setting.
11  *
12  * @ingroup plugins_setting
13  *
14  * @BootstrapSetting(
15  *   id = "modal_select_text",
16  *   type = "checkbox",
17  *   title = @Translation("selectText"),
18  *   description = @Translation("Enabling this selects the text of the first available and visible input found after it has been focused."),
19  *   defaultValue = 1,
20  *   groups = {
21  *     "javascript" = @Translation("JavaScript"),
22  *     "modals" = @Translation("Modals"),
23  *     "options" = @Translation("Options"),
24  *   },
25  * )
26  */
27 class ModalSelectText 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         ':input[name="modal_focus_input"]' => ['checked' => TRUE],
39       ],
40     ]);
41   }
42
43   /**
44    * {@inheritdoc}
45    */
46   public function drupalSettings() {
47     return !!$this->theme->getSetting('modal_enabled');
48   }
49
50   /**
51    * {@inheritdoc}
52    */
53   public function getCacheTags() {
54     return ['rendered', 'library_info'];
55   }
56
57 }