You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.8 KiB

7 months ago
  1. /*!
  2. * Bootstrap alert.js v5.3.3 (https://getbootstrap.com/)
  3. * Copyright 2011-2024 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  4. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./base-component.js'), require('./dom/event-handler.js'), require('./util/component-functions.js'), require('./util/index.js')) :
  8. typeof define === 'function' && define.amd ? define(['./base-component', './dom/event-handler', './util/component-functions', './util/index'], factory) :
  9. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Alert = factory(global.BaseComponent, global.EventHandler, global.ComponentFunctions, global.Index));
  10. })(this, (function (BaseComponent, EventHandler, componentFunctions_js, index_js) { 'use strict';
  11. /**
  12. * --------------------------------------------------------------------------
  13. * Bootstrap alert.js
  14. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
  15. * --------------------------------------------------------------------------
  16. */
  17. /**
  18. * Constants
  19. */
  20. const NAME = 'alert';
  21. const DATA_KEY = 'bs.alert';
  22. const EVENT_KEY = `.${DATA_KEY}`;
  23. const EVENT_CLOSE = `close${EVENT_KEY}`;
  24. const EVENT_CLOSED = `closed${EVENT_KEY}`;
  25. const CLASS_NAME_FADE = 'fade';
  26. const CLASS_NAME_SHOW = 'show';
  27. /**
  28. * Class definition
  29. */
  30. class Alert extends BaseComponent {
  31. // Getters
  32. static get NAME() {
  33. return NAME;
  34. }
  35. // Public
  36. close() {
  37. const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE);
  38. if (closeEvent.defaultPrevented) {
  39. return;
  40. }
  41. this._element.classList.remove(CLASS_NAME_SHOW);
  42. const isAnimated = this._element.classList.contains(CLASS_NAME_FADE);
  43. this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
  44. }
  45. // Private
  46. _destroyElement() {
  47. this._element.remove();
  48. EventHandler.trigger(this._element, EVENT_CLOSED);
  49. this.dispose();
  50. }
  51. // Static
  52. static jQueryInterface(config) {
  53. return this.each(function () {
  54. const data = Alert.getOrCreateInstance(this);
  55. if (typeof config !== 'string') {
  56. return;
  57. }
  58. if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
  59. throw new TypeError(`No method named "${config}"`);
  60. }
  61. data[config](this);
  62. });
  63. }
  64. }
  65. /**
  66. * Data API implementation
  67. */
  68. componentFunctions_js.enableDismissTrigger(Alert, 'close');
  69. /**
  70. * jQuery
  71. */
  72. index_js.defineJQueryPlugin(Alert);
  73. return Alert;
  74. }));
  75. //# sourceMappingURL=alert.js.map