1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-01 01:21:49 +02:00
This commit is contained in:
Mark Otto
2016-12-02 10:13:36 -08:00
parent e3a569f4f6
commit 3ec37d4a4d
24 changed files with 177 additions and 56 deletions

10
js/dist/carousel.js vendored
View File

@@ -108,9 +108,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() {
@@ -121,9 +122,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) {

File diff suppressed because one or more lines are too long

12
js/dist/collapse.js vendored
View File

@@ -103,7 +103,11 @@ var Collapse = function ($) {
Collapse.prototype.show = function show() {
var _this = 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;
}
@@ -176,7 +180,11 @@ var Collapse = function ($) {
Collapse.prototype.hide = function hide() {
var _this2 = 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;
}

File diff suppressed because one or more lines are too long

25
js/dist/modal.js vendored
View File

@@ -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();

File diff suppressed because one or more lines are too long

14
js/dist/tooltip.js vendored
View File

@@ -125,6 +125,7 @@ var Tooltip = function ($) {
this._timeout = 0;
this._hoverState = '';
this._activeTrigger = {};
this._isTransitioning = false;
this._tether = null;
// protected
@@ -210,9 +211,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);
@@ -262,6 +266,7 @@ var Tooltip = function ($) {
var complete = function complete() {
var prevHoverState = _this._hoverState;
_this._hoverState = null;
_this._isTransitioning = false;
$(_this.element).trigger(_this.constructor.Event.SHOWN);
@@ -271,6 +276,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;
}
@@ -284,6 +290,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 (_this2._hoverState !== HoverState.ACTIVE && tip.parentNode) {
tip.parentNode.removeChild(tip);
@@ -291,6 +300,7 @@ var Tooltip = function ($) {
_this2.element.removeAttribute('aria-describedby');
$(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
_this2._isTransitioning = false;
_this2.cleanupTether();
if (callback) {
@@ -307,7 +317,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();

File diff suppressed because one or more lines are too long