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:
1.0 KB
|
Line | |
---|
1 | /**
|
---|
2 | * --------------------------------------------------------------------------
|
---|
3 | * Bootstrap (v5.1.3): util/component-functions.js
|
---|
4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
---|
5 | * --------------------------------------------------------------------------
|
---|
6 | */
|
---|
7 |
|
---|
8 | import EventHandler from '../dom/event-handler'
|
---|
9 | import { getElementFromSelector, isDisabled } from './index'
|
---|
10 |
|
---|
11 | const enableDismissTrigger = (component, method = 'hide') => {
|
---|
12 | const clickEvent = `click.dismiss${component.EVENT_KEY}`
|
---|
13 | const name = component.NAME
|
---|
14 |
|
---|
15 | EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
|
---|
16 | if (['A', 'AREA'].includes(this.tagName)) {
|
---|
17 | event.preventDefault()
|
---|
18 | }
|
---|
19 |
|
---|
20 | if (isDisabled(this)) {
|
---|
21 | return
|
---|
22 | }
|
---|
23 |
|
---|
24 | const target = getElementFromSelector(this) || this.closest(`.${name}`)
|
---|
25 | const instance = component.getOrCreateInstance(target)
|
---|
26 |
|
---|
27 | // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
|
---|
28 | instance[method]()
|
---|
29 | })
|
---|
30 | }
|
---|
31 |
|
---|
32 | export {
|
---|
33 | enableDismissTrigger
|
---|
34 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.