Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap-rubygem.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlake Gentry <blakesgentry@gmail.com>2017-01-06 21:10:24 +0300
committerBlake Gentry <blakesgentry@gmail.com>2017-01-06 21:10:24 +0300
commitf82164992580fca0c3e3dde7d6d097784a514e5b (patch)
treebb3ff36c326d696623203563a53cab5982970ad8 /assets/javascripts/bootstrap/carousel.js
parent023043a2da9098e7b8521a2ac62b7b5a470c40d9 (diff)
rake update[v4.0.0-alpha.6]
Diffstat (limited to 'assets/javascripts/bootstrap/carousel.js')
-rw-r--r--assets/javascripts/bootstrap/carousel.js80
1 files changed, 52 insertions, 28 deletions
diff --git a/assets/javascripts/bootstrap/carousel.js b/assets/javascripts/bootstrap/carousel.js
index cfe5ce3..c834f67 100644
--- a/assets/javascripts/bootstrap/carousel.js
+++ b/assets/javascripts/bootstrap/carousel.js
@@ -6,7 +6,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.5): carousel.js
+ * Bootstrap (v4.0.0-alpha.6): carousel.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -20,7 +20,7 @@ var Carousel = function ($) {
*/
var NAME = 'carousel';
- var VERSION = '4.0.0-alpha.5';
+ var VERSION = '4.0.0-alpha.6';
var DATA_KEY = 'bs.carousel';
var EVENT_KEY = '.' + DATA_KEY;
var DATA_API_KEY = '.data-api';
@@ -47,7 +47,9 @@ var Carousel = function ($) {
var Direction = {
NEXT: 'next',
- PREVIOUS: 'prev'
+ PREV: 'prev',
+ LEFT: 'left',
+ RIGHT: 'right'
};
var Event = {
@@ -64,8 +66,10 @@ var Carousel = function ($) {
CAROUSEL: 'carousel',
ACTIVE: 'active',
SLIDE: 'slide',
- RIGHT: 'right',
- LEFT: 'left',
+ RIGHT: 'carousel-item-right',
+ LEFT: 'carousel-item-left',
+ NEXT: 'carousel-item-next',
+ PREV: 'carousel-item-prev',
ITEM: 'carousel-item'
};
@@ -73,7 +77,7 @@ var Carousel = function ($) {
ACTIVE: '.active',
ACTIVE_ITEM: '.active.carousel-item',
ITEM: '.carousel-item',
- NEXT_PREV: '.next, .prev',
+ NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
INDICATORS: '.carousel-indicators',
DATA_SLIDE: '[data-slide], [data-slide-to]',
DATA_RIDE: '[data-ride="carousel"]'
@@ -108,9 +112,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 +126,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) {
@@ -151,7 +157,7 @@ var Carousel = function ($) {
}
if (this._config.interval && !this._isPaused) {
- this._interval = setInterval($.proxy(document.visibilityState ? this.nextWhenVisible : this.next, this), this._config.interval);
+ this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
}
};
@@ -207,27 +213,35 @@ var Carousel = function ($) {
};
Carousel.prototype._addEventListeners = function _addEventListeners() {
+ var _this2 = this;
+
if (this._config.keyboard) {
- $(this._element).on(Event.KEYDOWN, $.proxy(this._keydown, this));
+ $(this._element).on(Event.KEYDOWN, function (event) {
+ return _this2._keydown(event);
+ });
}
if (this._config.pause === 'hover' && !('ontouchstart' in document.documentElement)) {
- $(this._element).on(Event.MOUSEENTER, $.proxy(this.pause, this)).on(Event.MOUSELEAVE, $.proxy(this.cycle, this));
+ $(this._element).on(Event.MOUSEENTER, function (event) {
+ return _this2.pause(event);
+ }).on(Event.MOUSELEAVE, function (event) {
+ return _this2.cycle(event);
+ });
}
};
Carousel.prototype._keydown = function _keydown(event) {
- event.preventDefault();
-
if (/input|textarea/i.test(event.target.tagName)) {
return;
}
switch (event.which) {
case ARROW_LEFT_KEYCODE:
+ event.preventDefault();
this.prev();
break;
case ARROW_RIGHT_KEYCODE:
+ event.preventDefault();
this.next();
break;
default:
@@ -257,10 +271,10 @@ var Carousel = function ($) {
return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
};
- Carousel.prototype._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, directionalClassname) {
+ Carousel.prototype._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
var slideEvent = $.Event(Event.SLIDE, {
relatedTarget: relatedTarget,
- direction: directionalClassname
+ direction: eventDirectionName
});
$(this._element).trigger(slideEvent);
@@ -281,21 +295,33 @@ var Carousel = function ($) {
};
Carousel.prototype._slide = function _slide(direction, element) {
- var _this2 = this;
+ var _this3 = this;
var activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];
var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
var isCycling = Boolean(this._interval);
- var directionalClassName = direction === Direction.NEXT ? ClassName.LEFT : ClassName.RIGHT;
+ var directionalClassName = void 0;
+ var orderClassName = void 0;
+ var eventDirectionName = void 0;
+
+ if (direction === Direction.NEXT) {
+ directionalClassName = ClassName.LEFT;
+ orderClassName = ClassName.NEXT;
+ eventDirectionName = Direction.LEFT;
+ } else {
+ directionalClassName = ClassName.RIGHT;
+ orderClassName = ClassName.PREV;
+ eventDirectionName = Direction.RIGHT;
+ }
if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) {
this._isSliding = false;
return;
}
- var slideEvent = this._triggerSlideEvent(nextElement, directionalClassName);
+ var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
if (slideEvent.isDefaultPrevented()) {
return;
}
@@ -315,12 +341,12 @@ var Carousel = function ($) {
var slidEvent = $.Event(Event.SLID, {
relatedTarget: nextElement,
- direction: directionalClassName
+ direction: eventDirectionName
});
if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.SLIDE)) {
- $(nextElement).addClass(direction);
+ $(nextElement).addClass(orderClassName);
Util.reflow(nextElement);
@@ -328,16 +354,14 @@ var Carousel = function ($) {
$(nextElement).addClass(directionalClassName);
$(activeElement).one(Util.TRANSITION_END, function () {
- $(nextElement).removeClass(directionalClassName).removeClass(direction);
-
- $(nextElement).addClass(ClassName.ACTIVE);
+ $(nextElement).removeClass(directionalClassName + ' ' + orderClassName).addClass(ClassName.ACTIVE);
- $(activeElement).removeClass(ClassName.ACTIVE).removeClass(direction).removeClass(directionalClassName);
+ $(activeElement).removeClass(ClassName.ACTIVE + ' ' + orderClassName + ' ' + directionalClassName);
- _this2._isSliding = false;
+ _this3._isSliding = false;
setTimeout(function () {
- return $(_this2._element).trigger(slidEvent);
+ return $(_this3._element).trigger(slidEvent);
}, 0);
}).emulateTransitionEnd(TRANSITION_DURATION);
} else {