aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/src/toast.js
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twbs/bootstrap/js/src/toast.js')
-rw-r--r--vendor/twbs/bootstrap/js/src/toast.js60
1 files changed, 19 insertions, 41 deletions
diff --git a/vendor/twbs/bootstrap/js/src/toast.js b/vendor/twbs/bootstrap/js/src/toast.js
index 780279be9..54a8d5408 100644
--- a/vendor/twbs/bootstrap/js/src/toast.js
+++ b/vendor/twbs/bootstrap/js/src/toast.js
@@ -1,24 +1,17 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.1.3): toast.js
+ * Bootstrap (v5.2.0): toast.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
-import {
- defineJQueryPlugin,
- reflow,
- typeCheckConfig
-} from './util/index'
+import { defineJQueryPlugin, reflow } from './util/index'
import EventHandler from './dom/event-handler'
-import Manipulator from './dom/manipulator'
import BaseComponent from './base-component'
import { enableDismissTrigger } from './util/component-functions'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const NAME = 'toast'
@@ -52,16 +45,13 @@ const Default = {
}
/**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
+ * Class definition
*/
class Toast extends BaseComponent {
constructor(element, config) {
- super(element)
+ super(element, config)
- this._config = this._getConfig(config)
this._timeout = null
this._hasMouseInteraction = false
this._hasKeyboardInteraction = false
@@ -69,21 +59,19 @@ class Toast extends BaseComponent {
}
// Getters
+ static get Default() {
+ return Default
+ }
static get DefaultType() {
return DefaultType
}
- static get Default() {
- return Default
- }
-
static get NAME() {
return NAME
}
// Public
-
show() {
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW)
@@ -106,14 +94,13 @@ class Toast extends BaseComponent {
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._element.classList.add(CLASS_NAME_SHOW, CLASS_NAME_SHOWING)
this._queueCallback(complete, this._element, this._config.animation)
}
hide() {
- if (!this._element.classList.contains(CLASS_NAME_SHOW)) {
+ if (!this.isShown()) {
return
}
@@ -125,8 +112,7 @@ class Toast extends BaseComponent {
const complete = () => {
this._element.classList.add(CLASS_NAME_HIDE) // @deprecated
- this._element.classList.remove(CLASS_NAME_SHOWING)
- this._element.classList.remove(CLASS_NAME_SHOW)
+ this._element.classList.remove(CLASS_NAME_SHOWING, CLASS_NAME_SHOW)
EventHandler.trigger(this._element, EVENT_HIDDEN)
}
@@ -137,27 +123,19 @@ class Toast extends BaseComponent {
dispose() {
this._clearTimeout()
- if (this._element.classList.contains(CLASS_NAME_SHOW)) {
+ if (this.isShown()) {
this._element.classList.remove(CLASS_NAME_SHOW)
}
super.dispose()
}
- // Private
-
- _getConfig(config) {
- config = {
- ...Default,
- ...Manipulator.getDataAttributes(this._element),
- ...(typeof config === 'object' && config ? config : {})
- }
-
- typeCheckConfig(NAME, config, this.constructor.DefaultType)
-
- return config
+ isShown() {
+ return this._element.classList.contains(CLASS_NAME_SHOW)
}
+ // Private
+
_maybeScheduleHide() {
if (!this._config.autohide) {
return
@@ -212,7 +190,6 @@ class Toast extends BaseComponent {
}
// Static
-
static jQueryInterface(config) {
return this.each(function () {
const data = Toast.getOrCreateInstance(this, config)
@@ -228,13 +205,14 @@ class Toast extends BaseComponent {
}
}
+/**
+ * Data API implementation
+ */
+
enableDismissTrigger(Toast)
/**
- * ------------------------------------------------------------------------
* jQuery
- * ------------------------------------------------------------------------
- * add .Toast to jQuery only if jQuery is present
*/
defineJQueryPlugin(Toast)