diff options
author | Mario <mario@mariovavti.com> | 2022-08-19 13:15:48 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2022-08-19 13:15:48 +0000 |
commit | 185ddf1eaf82e08586be6c7689507ee924d9dd47 (patch) | |
tree | 218ff6da6fb1511a1b2823729607c7c4b13e30e9 /vendor/twbs/bootstrap/js/src/toast.js | |
parent | 7dee47183d05b6e1f7d5c5588e2df9993fb294dd (diff) | |
download | volse-hubzilla-185ddf1eaf82e08586be6c7689507ee924d9dd47.tar.gz volse-hubzilla-185ddf1eaf82e08586be6c7689507ee924d9dd47.tar.bz2 volse-hubzilla-185ddf1eaf82e08586be6c7689507ee924d9dd47.zip |
update to bootstrap 5.2 and fixes
Diffstat (limited to 'vendor/twbs/bootstrap/js/src/toast.js')
-rw-r--r-- | vendor/twbs/bootstrap/js/src/toast.js | 60 |
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) |