Updated the Bootstrap theme.
[yaffs-website] / web / themes / contrib / bootstrap / src / Plugin / Setting / JavaScript / Modals / ModalSelectText.php
diff --git a/web/themes/contrib/bootstrap/src/Plugin/Setting/JavaScript/Modals/ModalSelectText.php b/web/themes/contrib/bootstrap/src/Plugin/Setting/JavaScript/Modals/ModalSelectText.php
new file mode 100644 (file)
index 0000000..9a8cb5f
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+
+namespace Drupal\bootstrap\Plugin\Setting\JavaScript\Modals;
+
+use Drupal\bootstrap\Plugin\Setting\SettingBase;
+use Drupal\bootstrap\Utility\Element;
+use Drupal\Core\Form\FormStateInterface;
+
+/**
+ * The "modal_select_text" theme setting.
+ *
+ * @ingroup plugins_setting
+ *
+ * @BootstrapSetting(
+ *   id = "modal_select_text",
+ *   type = "checkbox",
+ *   title = @Translation("selectText"),
+ *   description = @Translation("Enabling this selects the text of the first available and visible input found after it has been focused."),
+ *   defaultValue = 1,
+ *   groups = {
+ *     "javascript" = @Translation("JavaScript"),
+ *     "modals" = @Translation("Modals"),
+ *     "options" = @Translation("Options"),
+ *   },
+ * )
+ */
+class ModalSelectText extends SettingBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
+    parent::alterFormElement($form, $form_state, $form_id);
+    $setting = $this->getSettingElement($form, $form_state);
+    $setting->setProperty('states', [
+      'visible' => [
+        ':input[name="modal_enabled"]' => ['checked' => TRUE],
+        ':input[name="modal_focus_input"]' => ['checked' => TRUE],
+      ],
+    ]);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function drupalSettings() {
+    return !!$this->theme->getSetting('modal_enabled');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCacheTags() {
+    return ['rendered', 'library_info'];
+  }
+
+}