aboutsummaryrefslogtreecommitdiff
path: root/js/dist/modal.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/dist/modal.js')
-rw-r--r--js/dist/modal.js25
1 files changed, 21 insertions, 4 deletions
diff --git a/js/dist/modal.js b/js/dist/modal.js
index 68880ad58..d9797567c 100644
--- a/js/dist/modal.js
+++ b/js/dist/modal.js
@@ -89,6 +89,7 @@ var Modal = function ($) {
this._isShown = false;
this._isBodyOverflowing = false;
this._ignoreBackdropClick = false;
+ this._isTransitioning = false;
this._originalBodyPadding = 0;
this._scrollbarWidth = 0;
}
@@ -104,6 +105,13 @@ var Modal = function ($) {
Modal.prototype.show = function show(relatedTarget) {
var _this = this;
+ if (this._isTransitioning) {
+ throw new Error('Modal is transitioning');
+ }
+
+ if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) {
+ this._isTransitioning = true;
+ }
var showEvent = $.Event(Event.SHOW, {
relatedTarget: relatedTarget
});
@@ -148,8 +156,16 @@ var Modal = function ($) {
event.preventDefault();
}
- var hideEvent = $.Event(Event.HIDE);
+ if (this._isTransitioning) {
+ throw new Error('Modal is transitioning');
+ }
+
+ var transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE);
+ if (transition) {
+ this._isTransitioning = true;
+ }
+ var hideEvent = $.Event(Event.HIDE);
$(this._element).trigger(hideEvent);
if (!this._isShown || hideEvent.isDefaultPrevented()) {
@@ -168,8 +184,7 @@ var Modal = function ($) {
$(this._element).off(Event.CLICK_DISMISS);
$(this._dialog).off(Event.MOUSEDOWN_DISMISS);
- if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) {
-
+ if (transition) {
$(this._element).one(Util.TRANSITION_END, function (event) {
return _this2._hideModal(event);
}).emulateTransitionEnd(TRANSITION_DURATION);
@@ -234,6 +249,7 @@ var Modal = function ($) {
if (_this3._config.focus) {
_this3._element.focus();
}
+ _this3._isTransitioning = false;
$(_this3._element).trigger(shownEvent);
};
@@ -285,7 +301,8 @@ var Modal = function ($) {
var _this7 = this;
this._element.style.display = 'none';
- this._element.setAttribute('aria-hidden', true);
+ this._element.setAttribute('aria-hidden', 'true');
+ this._isTransitioning = false;
this._showBackdrop(function () {
$(document.body).removeClass(ClassName.OPEN);
_this7._resetAdjustments();