file ModalAnimation.php

Namespace

Drupal\bootstrap\Plugin\Setting\JavaScript\Modals
  1. <?php
  2. namespace Drupal\bootstrap\Plugin\Setting\JavaScript\Modals;
  3. use Drupal\bootstrap\Plugin\Setting\SettingBase;
  4. use Drupal\bootstrap\Utility\Element;
  5. use Drupal\Core\Form\FormStateInterface;
  6. /**
  7. * The "modal_animation" theme setting.
  8. *
  9. * @ingroup plugins_setting
  10. *
  11. * @BootstrapSetting(
  12. * id = "modal_animation",
  13. * type = "checkbox",
  14. * title = @Translation("animation"),
  15. * description = @Translation("Apply a CSS fade transition to modals."),
  16. * defaultValue = 1,
  17. * groups = {
  18. * "javascript" = @Translation("JavaScript"),
  19. * "modals" = @Translation("Modals"),
  20. * "options" = @Translation("Options"),
  21. * },
  22. * )
  23. */
  24. class ModalAnimation extends SettingBase {
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
  29. parent::alterFormElement($form, $form_state, $form_id);
  30. $group = $this->getGroupElement($form, $form_state);
  31. $group->note = [
  32. '#type' => 'container',
  33. '#weight' => -1,
  34. '#attributes' => ['class' => ['alert', 'alert-info', 'alert-sm']],
  35. 0 => [
  36. '#markup' => t('<strong>Note:</strong> jQuery UI dialog options will be mapped to Bootstrap modal options whenever possible, however they always take precedent over any global Bootstrap modal options set here for compatibility reasons.'),
  37. ],
  38. '#states' => [
  39. 'visible' => [
  40. ':input[name="modal_enabled"]' => ['checked' => TRUE],
  41. ':input[name="modal_jquery_ui_bridge"]' => ['checked' => TRUE],
  42. ],
  43. ],
  44. ];
  45. $group->setProperty('description', t('These are global options. Each modal can independently override desired settings by appending the option name to <code>data-</code>. Example: <code>data-backdrop="false"</code>.'));
  46. $group->setProperty('states', [
  47. 'visible' => [
  48. ':input[name="modal_enabled"]' => ['checked' => TRUE],
  49. ],
  50. ]);
  51. }
  52. /**
  53. * {@inheritdoc}
  54. */
  55. public function drupalSettings() {
  56. return !!$this->theme->getSetting('modal_enabled');
  57. }
  58. }

Classes

Name Description
ModalAnimation The "modal_animation" theme setting.