3 namespace Drupal\bootstrap\Plugin\Setting\JavaScript\Modals;
5 use Drupal\bootstrap\Plugin\Setting\SettingBase;
6 use Drupal\bootstrap\Utility\Element;
7 use Drupal\Core\Form\FormStateInterface;
10 * The "modal_focus_input" theme setting.
12 * @ingroup plugins_setting
15 * id = "modal_focus_input",
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."),
21 * "javascript" = @Translation("JavaScript"),
22 * "modals" = @Translation("Modals"),
23 * "options" = @Translation("Options"),
27 class ModalFocusInput extends SettingBase {
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', [
37 ':input[name="modal_enabled"]' => ['checked' => TRUE],
45 public function drupalSettings() {
46 return !!$this->theme->getSetting('modal_enabled');
52 public function getCacheTags() {
53 return ['rendered', 'library_info'];