diff options
| author | XhmikosR <[email protected]> | 2021-07-29 09:14:40 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-07-29 09:14:40 +0300 |
| commit | ef5336373fc2431b3d1d37cde85cd262210a1dc6 (patch) | |
| tree | e325fb4c5532b464d05780c731d0f118f2a88d7f /js/src/toast.js | |
| parent | 62edf07d7491684fe67a9c1e9439ed2bd10ca741 (diff) | |
| parent | c6c0bbb0b67fe89b55740a63fd10d4ad79044970 (diff) | |
| download | bootstrap-main-fod-simpler-table-structure.tar.xz bootstrap-main-fod-simpler-table-structure.zip | |
Merge branch 'main' into main-fod-simpler-table-structuremain-fod-simpler-table-structure
Diffstat (limited to 'js/src/toast.js')
| -rw-r--r-- | js/src/toast.js | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/js/src/toast.js b/js/src/toast.js index 8aeaa0148..bb5f768e6 100644 --- a/js/src/toast.js +++ b/js/src/toast.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.0.1): toast.js + * Bootstrap (v5.0.2): toast.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -13,6 +13,7 @@ import { import EventHandler from './dom/event-handler' import Manipulator from './dom/manipulator' import BaseComponent from './base-component' +import { enableDismissTrigger } from './util/component-functions' /** * ------------------------------------------------------------------------ @@ -24,7 +25,6 @@ const NAME = 'toast' const DATA_KEY = 'bs.toast' const EVENT_KEY = `.${DATA_KEY}` -const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}` const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}` const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}` const EVENT_FOCUSIN = `focusin${EVENT_KEY}` @@ -35,7 +35,7 @@ const EVENT_SHOW = `show${EVENT_KEY}` const EVENT_SHOWN = `shown${EVENT_KEY}` const CLASS_NAME_FADE = 'fade' -const CLASS_NAME_HIDE = 'hide' +const CLASS_NAME_HIDE = 'hide' // @deprecated - kept here only for backwards compatibility const CLASS_NAME_SHOW = 'show' const CLASS_NAME_SHOWING = 'showing' @@ -51,8 +51,6 @@ const Default = { delay: 5000 } -const SELECTOR_DATA_DISMISS = '[data-bs-dismiss="toast"]' - /** * ------------------------------------------------------------------------ * Class Definition @@ -101,15 +99,14 @@ class Toast extends BaseComponent { const complete = () => { this._element.classList.remove(CLASS_NAME_SHOWING) - this._element.classList.add(CLASS_NAME_SHOW) - EventHandler.trigger(this._element, EVENT_SHOWN) this._maybeScheduleHide() } - this._element.classList.remove(CLASS_NAME_HIDE) + this._element.classList.remove(CLASS_NAME_HIDE) // @deprecated reflow(this._element) + this._element.classList.add(CLASS_NAME_SHOW) this._element.classList.add(CLASS_NAME_SHOWING) this._queueCallback(complete, this._element, this._config.animation) @@ -127,11 +124,13 @@ class Toast extends BaseComponent { } const complete = () => { - this._element.classList.add(CLASS_NAME_HIDE) + this._element.classList.add(CLASS_NAME_HIDE) // @deprecated + this._element.classList.remove(CLASS_NAME_SHOWING) + this._element.classList.remove(CLASS_NAME_SHOW) EventHandler.trigger(this._element, EVENT_HIDDEN) } - this._element.classList.remove(CLASS_NAME_SHOW) + this._element.classList.add(CLASS_NAME_SHOWING) this._queueCallback(complete, this._element, this._config.animation) } @@ -201,7 +200,6 @@ class Toast extends BaseComponent { } _setListeners() { - EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, () => this.hide()) EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true)) EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false)) EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true)) @@ -230,6 +228,8 @@ class Toast extends BaseComponent { } } +enableDismissTrigger(Toast) + /** * ------------------------------------------------------------------------ * jQuery |
