diff options
author | XhmikosR <xhmikosr@gmail.com> | 2019-04-18 14:47:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-18 14:47:52 +0300 |
commit | 091aa1e9fd411440c3ff3c95042a5aa1502e6978 (patch) | |
tree | 9343d4a164ad6e2c064d0305ba28e6d8870029e7 /js/dist/toast.js | |
parent | 5c5b15a077b796510fce745129612ee940b13b89 (diff) |
v5 dist (#28657)
Diffstat (limited to 'js/dist/toast.js')
-rw-r--r-- | js/dist/toast.js | 62 |
1 files changed, 27 insertions, 35 deletions
diff --git a/js/dist/toast.js b/js/dist/toast.js index 2dd6821d55..92947135a6 100644 --- a/js/dist/toast.js +++ b/js/dist/toast.js @@ -102,7 +102,9 @@ }; var triggerTransitionEnd = function triggerTransitionEnd(element) { - element.dispatchEvent(new Event(TRANSITION_END)); + var evt = document.createEvent('HTMLEvents'); + evt.initEvent(TRANSITION_END, true, true); + element.dispatchEvent(evt); }; var isElement = function isElement(obj) { @@ -149,7 +151,7 @@ var VERSION = '4.3.1'; var DATA_KEY = 'bs.toast'; var EVENT_KEY = "." + DATA_KEY; - var Event$1 = { + var Event = { CLICK_DISMISS: "click.dismiss" + EVENT_KEY, HIDE: "hide" + EVENT_KEY, HIDDEN: "hidden" + EVENT_KEY, @@ -202,7 +204,7 @@ _proto.show = function show() { var _this = this; - EventHandler.trigger(this._element, Event$1.SHOW); + EventHandler.trigger(this._element, Event.SHOW); if (this._config.animation) { this._element.classList.add(ClassName.FADE); @@ -213,10 +215,12 @@ _this._element.classList.add(ClassName.SHOW); - EventHandler.trigger(_this._element, Event$1.SHOWN); + EventHandler.trigger(_this._element, Event.SHOWN); if (_this._config.autohide) { - _this.hide(); + _this._timeout = setTimeout(function () { + _this.hide(); + }, _this._config.delay); } }; @@ -233,21 +237,29 @@ } }; - _proto.hide = function hide(withoutTimeout) { + _proto.hide = function hide() { var _this2 = this; if (!this._element.classList.contains(ClassName.SHOW)) { return; } - EventHandler.trigger(this._element, Event$1.HIDE); + EventHandler.trigger(this._element, Event.HIDE); - if (withoutTimeout) { - this._close(); + var complete = function complete() { + _this2._element.classList.add(ClassName.HIDE); + + EventHandler.trigger(_this2._element, Event.HIDDEN); + }; + + this._element.classList.remove(ClassName.SHOW); + + if (this._config.animation) { + var transitionDuration = getTransitionDurationFromElement(this._element); + EventHandler.one(this._element, TRANSITION_END, complete); + emulateTransitionEnd(this._element, transitionDuration); } else { - this._timeout = setTimeout(function () { - _this2._close(); - }, this._config.delay); + complete(); } }; @@ -259,7 +271,7 @@ this._element.classList.remove(ClassName.SHOW); } - EventHandler.off(this._element, Event$1.CLICK_DISMISS); + EventHandler.off(this._element, Event.CLICK_DISMISS); Data.removeData(this._element, DATA_KEY); this._element = null; this._config = null; @@ -275,29 +287,9 @@ _proto._setListeners = function _setListeners() { var _this3 = this; - EventHandler.on(this._element, Event$1.CLICK_DISMISS, Selector.DATA_DISMISS, function () { - return _this3.hide(true); + EventHandler.on(this._element, Event.CLICK_DISMISS, Selector.DATA_DISMISS, function () { + return _this3.hide(); }); - }; - - _proto._close = function _close() { - var _this4 = this; - - var complete = function complete() { - _this4._element.classList.add(ClassName.HIDE); - - EventHandler.trigger(_this4._element, Event$1.HIDDEN); - }; - - this._element.classList.remove(ClassName.SHOW); - - if (this._config.animation) { - var transitionDuration = getTransitionDurationFromElement(this._element); - EventHandler.one(this._element, TRANSITION_END, complete); - emulateTransitionEnd(this._element, transitionDuration); - } else { - complete(); - } } // Static ; |