2018-11-13 01:41:12 -05:00
|
|
|
/*!
|
2021-10-09 02:33:12 -04:00
|
|
|
* Bootstrap alert.js v5.1.3 (https://getbootstrap.com/)
|
2021-02-10 11:14:51 -05:00
|
|
|
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
2020-06-16 14:50:01 -04:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
2018-11-13 01:41:12 -05:00
|
|
|
*/
|
2018-07-23 20:51:14 -04:00
|
|
|
(function (global, factory) {
|
2021-08-04 11:41:51 -04:00
|
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/event-handler.js'), require('./base-component.js')) :
|
|
|
|
typeof define === 'function' && define.amd ? define(['./dom/event-handler', './base-component'], factory) :
|
|
|
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Alert = factory(global.EventHandler, global.Base));
|
2021-10-05 11:50:18 -04:00
|
|
|
})(this, (function (EventHandler, BaseComponent) { 'use strict';
|
2018-07-23 20:51:14 -04:00
|
|
|
|
2021-10-05 11:50:18 -04:00
|
|
|
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
2020-09-14 11:12:06 -04:00
|
|
|
|
2021-10-05 11:50:18 -04:00
|
|
|
const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
|
|
|
|
const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
|
2021-02-10 11:14:51 -05:00
|
|
|
|
2021-08-04 11:41:51 -04:00
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
2021-10-09 02:33:12 -04:00
|
|
|
* Bootstrap (v5.1.3): util/index.js
|
2021-08-04 11:41:51 -04:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
const getSelector = element => {
|
|
|
|
let selector = element.getAttribute('data-bs-target');
|
2019-03-01 11:31:34 -05:00
|
|
|
|
|
|
|
if (!selector || selector === '#') {
|
2021-03-23 12:26:54 -04:00
|
|
|
let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
|
2021-02-10 11:14:51 -05:00
|
|
|
// so everything starting with `#` or `.`. If a "real" URL is used as the selector,
|
|
|
|
// `document.querySelector` will rightfully complain it is invalid.
|
|
|
|
// See https://github.com/twbs/bootstrap/issues/32273
|
|
|
|
|
|
|
|
if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) {
|
|
|
|
return null;
|
|
|
|
} // Just in case some CMS puts out a full URL with the anchor appended
|
|
|
|
|
|
|
|
|
|
|
|
if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
|
2021-05-05 15:32:12 -04:00
|
|
|
hrefAttr = `#${hrefAttr.split('#')[1]}`;
|
2021-02-10 11:14:51 -05:00
|
|
|
}
|
|
|
|
|
2019-08-27 09:03:21 -04:00
|
|
|
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
|
2019-03-01 11:31:34 -05:00
|
|
|
}
|
|
|
|
|
2019-08-27 09:03:21 -04:00
|
|
|
return selector;
|
|
|
|
};
|
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
const getElementFromSelector = element => {
|
|
|
|
const selector = getSelector(element);
|
2019-08-27 09:03:21 -04:00
|
|
|
return selector ? document.querySelector(selector) : null;
|
2019-03-01 11:31:34 -05:00
|
|
|
};
|
|
|
|
|
2021-08-04 11:41:51 -04:00
|
|
|
const isDisabled = element => {
|
|
|
|
if (!element || element.nodeType !== Node.ELEMENT_NODE) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (element.classList.contains('disabled')) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof element.disabled !== 'undefined') {
|
|
|
|
return element.disabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
|
|
|
|
};
|
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
const getjQuery = () => {
|
|
|
|
const {
|
|
|
|
jQuery
|
|
|
|
} = window;
|
2019-08-27 09:03:21 -04:00
|
|
|
|
2020-11-23 08:17:16 -05:00
|
|
|
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
|
2019-08-27 09:03:21 -04:00
|
|
|
return jQuery;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
2021-06-22 14:29:16 -04:00
|
|
|
const DOMContentLoadedCallbacks = [];
|
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
const onDOMContentLoaded = callback => {
|
2020-11-11 12:07:37 -05:00
|
|
|
if (document.readyState === 'loading') {
|
2021-06-22 14:29:16 -04:00
|
|
|
// add listener on the first call when the document is in loading state
|
|
|
|
if (!DOMContentLoadedCallbacks.length) {
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
DOMContentLoadedCallbacks.forEach(callback => callback());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMContentLoadedCallbacks.push(callback);
|
2020-11-11 12:07:37 -05:00
|
|
|
} else {
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-05-13 12:22:20 -04:00
|
|
|
const defineJQueryPlugin = plugin => {
|
2021-03-23 12:26:54 -04:00
|
|
|
onDOMContentLoaded(() => {
|
|
|
|
const $ = getjQuery();
|
2021-02-10 11:14:51 -05:00
|
|
|
/* istanbul ignore if */
|
2020-12-03 09:18:59 -05:00
|
|
|
|
2021-02-10 11:14:51 -05:00
|
|
|
if ($) {
|
2021-05-13 12:22:20 -04:00
|
|
|
const name = plugin.NAME;
|
2021-03-23 12:26:54 -04:00
|
|
|
const JQUERY_NO_CONFLICT = $.fn[name];
|
2021-02-10 11:14:51 -05:00
|
|
|
$.fn[name] = plugin.jQueryInterface;
|
|
|
|
$.fn[name].Constructor = plugin;
|
2020-12-03 09:18:59 -05:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
$.fn[name].noConflict = () => {
|
2021-02-10 11:14:51 -05:00
|
|
|
$.fn[name] = JQUERY_NO_CONFLICT;
|
|
|
|
return plugin.jQueryInterface;
|
|
|
|
};
|
2020-12-03 09:18:59 -05:00
|
|
|
}
|
2021-02-10 11:14:51 -05:00
|
|
|
});
|
|
|
|
};
|
2020-12-03 09:18:59 -05:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
2021-10-09 02:33:12 -04:00
|
|
|
* Bootstrap (v5.1.3): util/component-functions.js
|
2021-08-04 11:41:51 -04:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
const enableDismissTrigger = (component, method = 'hide') => {
|
|
|
|
const clickEvent = `click.dismiss${component.EVENT_KEY}`;
|
|
|
|
const name = component.NAME;
|
2021-10-05 11:50:18 -04:00
|
|
|
EventHandler__default.default.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
|
2021-08-04 11:41:51 -04:00
|
|
|
if (['A', 'AREA'].includes(this.tagName)) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isDisabled(this)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const target = getElementFromSelector(this) || this.closest(`.${name}`);
|
|
|
|
const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
|
|
|
|
|
|
|
|
instance[method]();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
2021-10-09 02:33:12 -04:00
|
|
|
* Bootstrap (v5.1.3): alert.js
|
2021-03-23 12:26:54 -04:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*/
|
2020-12-03 09:18:59 -05:00
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* Constants
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
const NAME = 'alert';
|
|
|
|
const DATA_KEY = 'bs.alert';
|
|
|
|
const EVENT_KEY = `.${DATA_KEY}`;
|
|
|
|
const EVENT_CLOSE = `close${EVENT_KEY}`;
|
|
|
|
const EVENT_CLOSED = `closed${EVENT_KEY}`;
|
|
|
|
const CLASS_NAME_FADE = 'fade';
|
|
|
|
const CLASS_NAME_SHOW = 'show';
|
2019-10-08 02:39:10 -04:00
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* Class Definition
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
2015-05-07 19:34:28 -04:00
|
|
|
|
2021-10-05 11:50:18 -04:00
|
|
|
class Alert extends BaseComponent__default.default {
|
2021-03-23 12:26:54 -04:00
|
|
|
// Getters
|
2021-05-13 12:22:20 -04:00
|
|
|
static get NAME() {
|
|
|
|
return NAME;
|
2021-03-23 12:26:54 -04:00
|
|
|
} // Public
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2015-08-13 00:12:03 -04:00
|
|
|
|
2021-08-04 11:41:51 -04:00
|
|
|
close() {
|
2021-10-05 11:50:18 -04:00
|
|
|
const closeEvent = EventHandler__default.default.trigger(this._element, EVENT_CLOSE);
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2021-08-04 11:41:51 -04:00
|
|
|
if (closeEvent.defaultPrevented) {
|
2018-11-13 01:41:12 -05:00
|
|
|
return;
|
|
|
|
}
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2021-08-04 11:41:51 -04:00
|
|
|
this._element.classList.remove(CLASS_NAME_SHOW);
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2021-08-04 11:41:51 -04:00
|
|
|
const isAnimated = this._element.classList.contains(CLASS_NAME_FADE);
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2021-08-04 11:41:51 -04:00
|
|
|
this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
|
|
|
|
} // Private
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2016-11-01 00:36:10 -04:00
|
|
|
|
2021-08-04 11:41:51 -04:00
|
|
|
_destroyElement() {
|
|
|
|
this._element.remove();
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2021-10-05 11:50:18 -04:00
|
|
|
EventHandler__default.default.trigger(this._element, EVENT_CLOSED);
|
2021-08-04 11:41:51 -04:00
|
|
|
this.dispose();
|
2019-01-04 11:29:45 -05:00
|
|
|
} // Static
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
|
|
|
|
static jQueryInterface(config) {
|
2018-11-13 01:41:12 -05:00
|
|
|
return this.each(function () {
|
2021-06-22 14:29:16 -04:00
|
|
|
const data = Alert.getOrCreateInstance(this);
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2021-08-04 11:41:51 -04:00
|
|
|
if (typeof config !== 'string') {
|
|
|
|
return;
|
2018-11-13 01:41:12 -05:00
|
|
|
}
|
2016-10-09 20:26:51 -04:00
|
|
|
|
2021-08-04 11:41:51 -04:00
|
|
|
if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
|
|
|
|
throw new TypeError(`No method named "${config}"`);
|
2018-11-13 01:41:12 -05:00
|
|
|
}
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2021-08-04 11:41:51 -04:00
|
|
|
data[config](this);
|
|
|
|
});
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2021-03-23 12:26:54 -04:00
|
|
|
}
|
2018-11-13 01:41:12 -05:00
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* Data Api implementation
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
*/
|
2015-05-07 15:48:22 -04:00
|
|
|
|
|
|
|
|
2021-08-04 11:41:51 -04:00
|
|
|
enableDismissTrigger(Alert, 'close');
|
2018-11-13 01:41:12 -05:00
|
|
|
/**
|
|
|
|
* ------------------------------------------------------------------------
|
|
|
|
* jQuery
|
|
|
|
* ------------------------------------------------------------------------
|
2020-11-11 12:07:37 -05:00
|
|
|
* add .Alert to jQuery only if jQuery is present
|
2018-11-13 01:41:12 -05:00
|
|
|
*/
|
2017-09-30 17:28:03 -04:00
|
|
|
|
2021-05-13 12:22:20 -04:00
|
|
|
defineJQueryPlugin(Alert);
|
2015-05-07 15:48:22 -04:00
|
|
|
|
2015-05-07 19:34:28 -04:00
|
|
|
return Alert;
|
2018-07-23 20:51:14 -04:00
|
|
|
|
2021-10-05 11:50:18 -04:00
|
|
|
}));
|
2018-07-23 20:51:14 -04:00
|
|
|
//# sourceMappingURL=alert.js.map
|