From 3ec37d4a4d043ded903c807818e7894de084409f Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Fri, 2 Dec 2016 10:13:36 -0800 Subject: grunt --- dist/js/bootstrap.js | 66 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 12 deletions(-) (limited to 'dist/js/bootstrap.js') diff --git a/dist/js/bootstrap.js b/dist/js/bootstrap.js index 58057521c..6a384fcc9 100644 --- a/dist/js/bootstrap.js +++ b/dist/js/bootstrap.js @@ -624,9 +624,10 @@ var Carousel = function ($) { // public Carousel.prototype.next = function next() { - if (!this._isSliding) { - this._slide(Direction.NEXT); + if (this._isSliding) { + throw new Error('Carousel is sliding'); } + this._slide(Direction.NEXT); }; Carousel.prototype.nextWhenVisible = function nextWhenVisible() { @@ -637,9 +638,10 @@ var Carousel = function ($) { }; Carousel.prototype.prev = function prev() { - if (!this._isSliding) { - this._slide(Direction.PREVIOUS); + if (this._isSliding) { + throw new Error('Carousel is sliding'); } + this._slide(Direction.PREVIOUS); }; Carousel.prototype.pause = function pause(event) { @@ -1080,7 +1082,11 @@ var Collapse = function ($) { Collapse.prototype.show = function show() { var _this6 = this; - if (this._isTransitioning || $(this._element).hasClass(ClassName.ACTIVE)) { + if (this._isTransitioning) { + throw new Error('Collapse is transitioning'); + } + + if ($(this._element).hasClass(ClassName.ACTIVE)) { return; } @@ -1153,7 +1159,11 @@ var Collapse = function ($) { Collapse.prototype.hide = function hide() { var _this7 = this; - if (this._isTransitioning || !$(this._element).hasClass(ClassName.ACTIVE)) { + if (this._isTransitioning) { + throw new Error('Collapse is transitioning'); + } + + if (!$(this._element).hasClass(ClassName.ACTIVE)) { return; } @@ -1692,6 +1702,7 @@ var Modal = function ($) { this._isShown = false; this._isBodyOverflowing = false; this._ignoreBackdropClick = false; + this._isTransitioning = false; this._originalBodyPadding = 0; this._scrollbarWidth = 0; } @@ -1707,6 +1718,13 @@ var Modal = function ($) { Modal.prototype.show = function show(relatedTarget) { var _this9 = 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 }); @@ -1751,8 +1769,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()) { @@ -1771,8 +1797,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 _this10._hideModal(event); }).emulateTransitionEnd(TRANSITION_DURATION); @@ -1837,6 +1862,7 @@ var Modal = function ($) { if (_this11._config.focus) { _this11._element.focus(); } + _this11._isTransitioning = false; $(_this11._element).trigger(shownEvent); }; @@ -1888,7 +1914,8 @@ var Modal = function ($) { var _this15 = 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); _this15._resetAdjustments(); @@ -2807,6 +2834,7 @@ var Tooltip = function ($) { this._timeout = 0; this._hoverState = ''; this._activeTrigger = {}; + this._isTransitioning = false; this._tether = null; // protected @@ -2869,6 +2897,7 @@ var Tooltip = function ($) { $.removeData(this.element, this.constructor.DATA_KEY); $(this.element).off(this.constructor.EVENT_KEY); + $(this.element).closest('.modal').off('hide.bs.modal'); if (this.tip) { $(this.tip).remove(); @@ -2891,9 +2920,12 @@ var Tooltip = function ($) { if ($(this.element).css('display') === 'none') { throw new Error('Please use show on visible elements'); } - var showEvent = $.Event(this.constructor.Event.SHOW); + var showEvent = $.Event(this.constructor.Event.SHOW); if (this.isWithContent() && this._isEnabled) { + if (this._isTransitioning) { + throw new Error('Tooltip is transitioning'); + } $(this.element).trigger(showEvent); var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element); @@ -2943,6 +2975,7 @@ var Tooltip = function ($) { var complete = function complete() { var prevHoverState = _this22._hoverState; _this22._hoverState = null; + _this22._isTransitioning = false; $(_this22.element).trigger(_this22.constructor.Event.SHOWN); @@ -2952,6 +2985,7 @@ var Tooltip = function ($) { }; if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) { + this._isTransitioning = true; $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(Tooltip._TRANSITION_DURATION); return; } @@ -2965,6 +2999,9 @@ var Tooltip = function ($) { var tip = this.getTipElement(); var hideEvent = $.Event(this.constructor.Event.HIDE); + if (this._isTransitioning) { + throw new Error('Tooltip is transitioning'); + } var complete = function complete() { if (_this23._hoverState !== HoverState.ACTIVE && tip.parentNode) { tip.parentNode.removeChild(tip); @@ -2972,6 +3009,7 @@ var Tooltip = function ($) { _this23.element.removeAttribute('aria-describedby'); $(_this23.element).trigger(_this23.constructor.Event.HIDDEN); + _this23._isTransitioning = false; _this23.cleanupTether(); if (callback) { @@ -2988,7 +3026,7 @@ var Tooltip = function ($) { $(tip).removeClass(ClassName.ACTIVE); if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) { - + this._isTransitioning = true; $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); } else { complete(); @@ -3075,6 +3113,10 @@ var Tooltip = function ($) { return _this24._leave(event); }); } + + $(_this24.element).closest('.modal').on('hide.bs.modal', function () { + return _this24.hide(); + }); }); if (this.config.selector) { -- cgit v1.2.3