aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/dist/alert.js
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/alert.js')
-rw-r--r--vendor/twbs/bootstrap/js/dist/alert.js116
1 files changed, 73 insertions, 43 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/alert.js b/vendor/twbs/bootstrap/js/dist/alert.js
index 5572ad9c3..6a6b2e7ba 100644
--- a/vendor/twbs/bootstrap/js/dist/alert.js
+++ b/vendor/twbs/bootstrap/js/dist/alert.js
@@ -1,19 +1,26 @@
/*!
- * Bootstrap alert.js v5.0.2 (https://getbootstrap.com/)
+ * Bootstrap alert.js v5.1.1 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
(function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/selector-engine.js'), require('./dom/event-handler.js'), require('./base-component.js')) :
- typeof define === 'function' && define.amd ? define(['./dom/selector-engine', './dom/event-handler', './base-component'], factory) :
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Alert = factory(global.SelectorEngine, global.EventHandler, global.Base));
-}(this, (function (SelectorEngine, EventHandler, BaseComponent) { 'use strict';
+ 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));
+}(this, (function (EventHandler, BaseComponent) { 'use strict';
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
+ /**
+ * --------------------------------------------------------------------------
+ * Bootstrap (v5.1.1): util/index.js
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
+ * --------------------------------------------------------------------------
+ */
+
const getSelector = element => {
let selector = element.getAttribute('data-bs-target');
@@ -43,6 +50,22 @@
return selector ? document.querySelector(selector) : null;
};
+ 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';
+ };
+
const getjQuery = () => {
const {
jQuery
@@ -93,7 +116,33 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.2): alert.js
+ * Bootstrap (v5.1.1): util/component-functions.js
+ * 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;
+ EventHandler__default['default'].on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
+ 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]();
+ });
+ };
+
+ /**
+ * --------------------------------------------------------------------------
+ * Bootstrap (v5.1.1): alert.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -106,12 +155,8 @@
const NAME = 'alert';
const DATA_KEY = 'bs.alert';
const EVENT_KEY = `.${DATA_KEY}`;
- const DATA_API_KEY = '.data-api';
- const SELECTOR_DISMISS = '[data-bs-dismiss="alert"]';
const EVENT_CLOSE = `close${EVENT_KEY}`;
const EVENT_CLOSED = `closed${EVENT_KEY}`;
- const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
- const CLASS_NAME_ALERT = 'alert';
const CLASS_NAME_FADE = 'fade';
const CLASS_NAME_SHOW = 'show';
/**
@@ -127,37 +172,26 @@
} // Public
- close(element) {
- const rootElement = element ? this._getRootElement(element) : this._element;
-
- const customEvent = this._triggerCloseEvent(rootElement);
+ close() {
+ const closeEvent = EventHandler__default['default'].trigger(this._element, EVENT_CLOSE);
- if (customEvent === null || customEvent.defaultPrevented) {
+ if (closeEvent.defaultPrevented) {
return;
}
- this._removeElement(rootElement);
- } // Private
+ this._element.classList.remove(CLASS_NAME_SHOW);
+ const isAnimated = this._element.classList.contains(CLASS_NAME_FADE);
- _getRootElement(element) {
- return getElementFromSelector(element) || element.closest(`.${CLASS_NAME_ALERT}`);
- }
+ this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
+ } // Private
- _triggerCloseEvent(element) {
- return EventHandler__default['default'].trigger(element, EVENT_CLOSE);
- }
- _removeElement(element) {
- element.classList.remove(CLASS_NAME_SHOW);
- const isAnimated = element.classList.contains(CLASS_NAME_FADE);
+ _destroyElement() {
+ this._element.remove();
- this._queueCallback(() => this._destroyElement(element), element, isAnimated);
- }
-
- _destroyElement(element) {
- element.remove();
- EventHandler__default['default'].trigger(element, EVENT_CLOSED);
+ EventHandler__default['default'].trigger(this._element, EVENT_CLOSED);
+ this.dispose();
} // Static
@@ -165,20 +199,16 @@
return this.each(function () {
const data = Alert.getOrCreateInstance(this);
- if (config === 'close') {
- data[config](this);
+ if (typeof config !== 'string') {
+ return;
}
- });
- }
- static handleDismiss(alertInstance) {
- return function (event) {
- if (event) {
- event.preventDefault();
+ if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
+ throw new TypeError(`No method named "${config}"`);
}
- alertInstance.close(this);
- };
+ data[config](this);
+ });
}
}
@@ -189,7 +219,7 @@
*/
- EventHandler__default['default'].on(document, EVENT_CLICK_DATA_API, SELECTOR_DISMISS, Alert.handleDismiss(new Alert()));
+ enableDismissTrigger(Alert, 'close');
/**
* ------------------------------------------------------------------------
* jQuery