1 | /*!
|
---|
2 | * Bootstrap component-functions.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' ? factory(exports, require('../dom/event-handler.js'), require('../dom/selector-engine.js'), require('./index.js')) :
|
---|
8 | typeof define === 'function' && define.amd ? define(['exports', '../dom/event-handler', '../dom/selector-engine', './index'], factory) :
|
---|
9 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ComponentFunctions = {}, global.EventHandler, global.SelectorEngine, global.Index));
|
---|
10 | })(this, (function (exports, EventHandler, SelectorEngine, index_js) { 'use strict';
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * --------------------------------------------------------------------------
|
---|
14 | * Bootstrap util/component-functions.js
|
---|
15 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
---|
16 | * --------------------------------------------------------------------------
|
---|
17 | */
|
---|
18 |
|
---|
19 | const enableDismissTrigger = (component, method = 'hide') => {
|
---|
20 | const clickEvent = `click.dismiss${component.EVENT_KEY}`;
|
---|
21 | const name = component.NAME;
|
---|
22 | EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
|
---|
23 | if (['A', 'AREA'].includes(this.tagName)) {
|
---|
24 | event.preventDefault();
|
---|
25 | }
|
---|
26 | if (index_js.isDisabled(this)) {
|
---|
27 | return;
|
---|
28 | }
|
---|
29 | const target = SelectorEngine.getElementFromSelector(this) || this.closest(`.${name}`);
|
---|
30 | const instance = component.getOrCreateInstance(target);
|
---|
31 |
|
---|
32 | // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
|
---|
33 | instance[method]();
|
---|
34 | });
|
---|
35 | };
|
---|
36 |
|
---|
37 | exports.enableDismissTrigger = enableDismissTrigger;
|
---|
38 |
|
---|
39 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
---|
40 |
|
---|
41 | }));
|
---|
42 | //# sourceMappingURL=component-functions.js.map
|
---|