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 | * --------------------------------------------------------------------------
|
---|
14 | * Bootstrap alert.js
|
---|
15 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
---|
16 | * --------------------------------------------------------------------------
|
---|
17 | */
|
---|
18 |
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Constants
|
---|
22 | */
|
---|
23 |
|
---|
24 | const NAME = 'alert';
|
---|
25 | const DATA_KEY = 'bs.alert';
|
---|
26 | const EVENT_KEY = `.${DATA_KEY}`;
|
---|
27 | const EVENT_CLOSE = `close${EVENT_KEY}`;
|
---|
28 | const EVENT_CLOSED = `closed${EVENT_KEY}`;
|
---|
29 | const CLASS_NAME_FADE = 'fade';
|
---|
30 | const CLASS_NAME_SHOW = 'show';
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Class definition
|
---|
34 | */
|
---|
35 |
|
---|
36 | class Alert extends BaseComponent {
|
---|
37 | // Getters
|
---|
38 | static get NAME() {
|
---|
39 | return NAME;
|
---|
40 | }
|
---|
41 |
|
---|
42 | // Public
|
---|
43 | close() {
|
---|
44 | const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE);
|
---|
45 | if (closeEvent.defaultPrevented) {
|
---|
46 | return;
|
---|
47 | }
|
---|
48 | this._element.classList.remove(CLASS_NAME_SHOW);
|
---|
49 | const isAnimated = this._element.classList.contains(CLASS_NAME_FADE);
|
---|
50 | this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
|
---|
51 | }
|
---|
52 |
|
---|
53 | // Private
|
---|
54 | _destroyElement() {
|
---|
55 | this._element.remove();
|
---|
56 | EventHandler.trigger(this._element, EVENT_CLOSED);
|
---|
57 | this.dispose();
|
---|
58 | }
|
---|
59 |
|
---|
60 | // Static
|
---|
61 | static jQueryInterface(config) {
|
---|
62 | return this.each(function () {
|
---|
63 | const data = Alert.getOrCreateInstance(this);
|
---|
64 | if (typeof config !== 'string') {
|
---|
65 | return;
|
---|
66 | }
|
---|
67 | if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
|
---|
68 | throw new TypeError(`No method named "${config}"`);
|
---|
69 | }
|
---|
70 | data[config](this);
|
---|
71 | });
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * Data API implementation
|
---|
77 | */
|
---|
78 |
|
---|
79 | componentFunctions_js.enableDismissTrigger(Alert, 'close');
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * jQuery
|
---|
83 | */
|
---|
84 |
|
---|
85 | index_js.defineJQueryPlugin(Alert);
|
---|
86 |
|
---|
87 | return Alert;
|
---|
88 |
|
---|
89 | }));
|
---|
90 | //# sourceMappingURL=alert.js.map
|
---|