source: trip-planner-front/node_modules/bootstrap/js/dist/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: 7.3 KB
Line 
1/*!
2 * Bootstrap alert.js v5.1.3 (https://getbootstrap.com/)
3 * Copyright 2011-2021 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('./dom/event-handler.js'), require('./base-component.js')) :
8 typeof define === 'function' && define.amd ? define(['./dom/event-handler', './base-component'], factory) :
9 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Alert = factory(global.EventHandler, global.Base));
10})(this, (function (EventHandler, BaseComponent) { 'use strict';
11
12 const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
13
14 const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
15 const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
16
17 /**
18 * --------------------------------------------------------------------------
19 * Bootstrap (v5.1.3): util/index.js
20 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
21 * --------------------------------------------------------------------------
22 */
23
24 const getSelector = element => {
25 let selector = element.getAttribute('data-bs-target');
26
27 if (!selector || selector === '#') {
28 let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
29 // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
30 // `document.querySelector` will rightfully complain it is invalid.
31 // See https://github.com/twbs/bootstrap/issues/32273
32
33 if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) {
34 return null;
35 } // Just in case some CMS puts out a full URL with the anchor appended
36
37
38 if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
39 hrefAttr = `#${hrefAttr.split('#')[1]}`;
40 }
41
42 selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
43 }
44
45 return selector;
46 };
47
48 const getElementFromSelector = element => {
49 const selector = getSelector(element);
50 return selector ? document.querySelector(selector) : null;
51 };
52
53 const isDisabled = element => {
54 if (!element || element.nodeType !== Node.ELEMENT_NODE) {
55 return true;
56 }
57
58 if (element.classList.contains('disabled')) {
59 return true;
60 }
61
62 if (typeof element.disabled !== 'undefined') {
63 return element.disabled;
64 }
65
66 return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
67 };
68
69 const getjQuery = () => {
70 const {
71 jQuery
72 } = window;
73
74 if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
75 return jQuery;
76 }
77
78 return null;
79 };
80
81 const DOMContentLoadedCallbacks = [];
82
83 const onDOMContentLoaded = callback => {
84 if (document.readyState === 'loading') {
85 // add listener on the first call when the document is in loading state
86 if (!DOMContentLoadedCallbacks.length) {
87 document.addEventListener('DOMContentLoaded', () => {
88 DOMContentLoadedCallbacks.forEach(callback => callback());
89 });
90 }
91
92 DOMContentLoadedCallbacks.push(callback);
93 } else {
94 callback();
95 }
96 };
97
98 const defineJQueryPlugin = plugin => {
99 onDOMContentLoaded(() => {
100 const $ = getjQuery();
101 /* istanbul ignore if */
102
103 if ($) {
104 const name = plugin.NAME;
105 const JQUERY_NO_CONFLICT = $.fn[name];
106 $.fn[name] = plugin.jQueryInterface;
107 $.fn[name].Constructor = plugin;
108
109 $.fn[name].noConflict = () => {
110 $.fn[name] = JQUERY_NO_CONFLICT;
111 return plugin.jQueryInterface;
112 };
113 }
114 });
115 };
116
117 /**
118 * --------------------------------------------------------------------------
119 * Bootstrap (v5.1.3): util/component-functions.js
120 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
121 * --------------------------------------------------------------------------
122 */
123
124 const enableDismissTrigger = (component, method = 'hide') => {
125 const clickEvent = `click.dismiss${component.EVENT_KEY}`;
126 const name = component.NAME;
127 EventHandler__default.default.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
128 if (['A', 'AREA'].includes(this.tagName)) {
129 event.preventDefault();
130 }
131
132 if (isDisabled(this)) {
133 return;
134 }
135
136 const target = getElementFromSelector(this) || this.closest(`.${name}`);
137 const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
138
139 instance[method]();
140 });
141 };
142
143 /**
144 * --------------------------------------------------------------------------
145 * Bootstrap (v5.1.3): alert.js
146 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
147 * --------------------------------------------------------------------------
148 */
149 /**
150 * ------------------------------------------------------------------------
151 * Constants
152 * ------------------------------------------------------------------------
153 */
154
155 const NAME = 'alert';
156 const DATA_KEY = 'bs.alert';
157 const EVENT_KEY = `.${DATA_KEY}`;
158 const EVENT_CLOSE = `close${EVENT_KEY}`;
159 const EVENT_CLOSED = `closed${EVENT_KEY}`;
160 const CLASS_NAME_FADE = 'fade';
161 const CLASS_NAME_SHOW = 'show';
162 /**
163 * ------------------------------------------------------------------------
164 * Class Definition
165 * ------------------------------------------------------------------------
166 */
167
168 class Alert extends BaseComponent__default.default {
169 // Getters
170 static get NAME() {
171 return NAME;
172 } // Public
173
174
175 close() {
176 const closeEvent = EventHandler__default.default.trigger(this._element, EVENT_CLOSE);
177
178 if (closeEvent.defaultPrevented) {
179 return;
180 }
181
182 this._element.classList.remove(CLASS_NAME_SHOW);
183
184 const isAnimated = this._element.classList.contains(CLASS_NAME_FADE);
185
186 this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
187 } // Private
188
189
190 _destroyElement() {
191 this._element.remove();
192
193 EventHandler__default.default.trigger(this._element, EVENT_CLOSED);
194 this.dispose();
195 } // Static
196
197
198 static jQueryInterface(config) {
199 return this.each(function () {
200 const data = Alert.getOrCreateInstance(this);
201
202 if (typeof config !== 'string') {
203 return;
204 }
205
206 if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
207 throw new TypeError(`No method named "${config}"`);
208 }
209
210 data[config](this);
211 });
212 }
213
214 }
215 /**
216 * ------------------------------------------------------------------------
217 * Data Api implementation
218 * ------------------------------------------------------------------------
219 */
220
221
222 enableDismissTrigger(Alert, 'close');
223 /**
224 * ------------------------------------------------------------------------
225 * jQuery
226 * ------------------------------------------------------------------------
227 * add .Alert to jQuery only if jQuery is present
228 */
229
230 defineJQueryPlugin(Alert);
231
232 return Alert;
233
234}));
235//# sourceMappingURL=alert.js.map
Note: See TracBrowser for help on using the repository browser.