source: trip-planner-front/node_modules/bootstrap/js/src/alert.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/**
2 * --------------------------------------------------------------------------
3 * Bootstrap (v5.1.3): alert.js
4 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5 * --------------------------------------------------------------------------
6 */
7
8import { defineJQueryPlugin } from './util/index'
9import EventHandler from './dom/event-handler'
10import BaseComponent from './base-component'
11import { enableDismissTrigger } from './util/component-functions'
12
13/**
14 * ------------------------------------------------------------------------
15 * Constants
16 * ------------------------------------------------------------------------
17 */
18
19const NAME = 'alert'
20const DATA_KEY = 'bs.alert'
21const EVENT_KEY = `.${DATA_KEY}`
22
23const EVENT_CLOSE = `close${EVENT_KEY}`
24const EVENT_CLOSED = `closed${EVENT_KEY}`
25const CLASS_NAME_FADE = 'fade'
26const CLASS_NAME_SHOW = 'show'
27
28/**
29 * ------------------------------------------------------------------------
30 * Class Definition
31 * ------------------------------------------------------------------------
32 */
33
34class Alert extends BaseComponent {
35 // Getters
36
37 static get NAME() {
38 return NAME
39 }
40
41 // Public
42
43 close() {
44 const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE)
45
46 if (closeEvent.defaultPrevented) {
47 return
48 }
49
50 this._element.classList.remove(CLASS_NAME_SHOW)
51
52 const isAnimated = this._element.classList.contains(CLASS_NAME_FADE)
53 this._queueCallback(() => this._destroyElement(), this._element, isAnimated)
54 }
55
56 // Private
57 _destroyElement() {
58 this._element.remove()
59 EventHandler.trigger(this._element, EVENT_CLOSED)
60 this.dispose()
61 }
62
63 // Static
64
65 static jQueryInterface(config) {
66 return this.each(function () {
67 const data = Alert.getOrCreateInstance(this)
68
69 if (typeof config !== 'string') {
70 return
71 }
72
73 if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
74 throw new TypeError(`No method named "${config}"`)
75 }
76
77 data[config](this)
78 })
79 }
80}
81
82/**
83 * ------------------------------------------------------------------------
84 * Data Api implementation
85 * ------------------------------------------------------------------------
86 */
87
88enableDismissTrigger(Alert, 'close')
89
90/**
91 * ------------------------------------------------------------------------
92 * jQuery
93 * ------------------------------------------------------------------------
94 * add .Alert to jQuery only if jQuery is present
95 */
96
97defineJQueryPlugin(Alert)
98
99export default Alert
Note: See TracBrowser for help on using the repository browser.