aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/dist/carousel.js
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/carousel.js')
-rw-r--r--vendor/twbs/bootstrap/js/dist/carousel.js893
1 files changed, 497 insertions, 396 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/carousel.js b/vendor/twbs/bootstrap/js/dist/carousel.js
index 877d0b959..287b2435f 100644
--- a/vendor/twbs/bootstrap/js/dist/carousel.js
+++ b/vendor/twbs/bootstrap/js/dist/carousel.js
@@ -1,8 +1,13 @@
+/*!
+ * Bootstrap carousel.js v4.3.1 (https://getbootstrap.com/)
+ * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./util.js')) :
typeof define === 'function' && define.amd ? define(['jquery', './util.js'], factory) :
- (global.Carousel = factory(global.jQuery,global.Util));
-}(this, (function ($,Util) { 'use strict';
+ (global = global || self, global.Carousel = factory(global.jQuery, global.Util));
+}(this, function ($, Util) { 'use strict';
$ = $ && $.hasOwnProperty('default') ? $['default'] : $;
Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
@@ -58,510 +63,606 @@
}
/**
- * --------------------------------------------------------------------------
- * Bootstrap (v4.1.3): carousel.js
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- * --------------------------------------------------------------------------
+ * ------------------------------------------------------------------------
+ * Constants
+ * ------------------------------------------------------------------------
*/
- var Carousel = function ($$$1) {
+ var NAME = 'carousel';
+ var VERSION = '4.3.1';
+ var DATA_KEY = 'bs.carousel';
+ var EVENT_KEY = "." + DATA_KEY;
+ var DATA_API_KEY = '.data-api';
+ var JQUERY_NO_CONFLICT = $.fn[NAME];
+ var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
+
+ var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
+
+ var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
+
+ var SWIPE_THRESHOLD = 40;
+ var Default = {
+ interval: 5000,
+ keyboard: true,
+ slide: false,
+ pause: 'hover',
+ wrap: true,
+ touch: true
+ };
+ var DefaultType = {
+ interval: '(number|boolean)',
+ keyboard: 'boolean',
+ slide: '(boolean|string)',
+ pause: '(string|boolean)',
+ wrap: 'boolean',
+ touch: 'boolean'
+ };
+ var Direction = {
+ NEXT: 'next',
+ PREV: 'prev',
+ LEFT: 'left',
+ RIGHT: 'right'
+ };
+ var Event = {
+ SLIDE: "slide" + EVENT_KEY,
+ SLID: "slid" + EVENT_KEY,
+ KEYDOWN: "keydown" + EVENT_KEY,
+ MOUSEENTER: "mouseenter" + EVENT_KEY,
+ MOUSELEAVE: "mouseleave" + EVENT_KEY,
+ TOUCHSTART: "touchstart" + EVENT_KEY,
+ TOUCHMOVE: "touchmove" + EVENT_KEY,
+ TOUCHEND: "touchend" + EVENT_KEY,
+ POINTERDOWN: "pointerdown" + EVENT_KEY,
+ POINTERUP: "pointerup" + EVENT_KEY,
+ DRAG_START: "dragstart" + EVENT_KEY,
+ LOAD_DATA_API: "load" + EVENT_KEY + DATA_API_KEY,
+ CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
+ };
+ var ClassName = {
+ CAROUSEL: 'carousel',
+ ACTIVE: 'active',
+ SLIDE: 'slide',
+ RIGHT: 'carousel-item-right',
+ LEFT: 'carousel-item-left',
+ NEXT: 'carousel-item-next',
+ PREV: 'carousel-item-prev',
+ ITEM: 'carousel-item',
+ POINTER_EVENT: 'pointer-event'
+ };
+ var Selector = {
+ ACTIVE: '.active',
+ ACTIVE_ITEM: '.active.carousel-item',
+ ITEM: '.carousel-item',
+ ITEM_IMG: '.carousel-item img',
+ NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
+ INDICATORS: '.carousel-indicators',
+ DATA_SLIDE: '[data-slide], [data-slide-to]',
+ DATA_RIDE: '[data-ride="carousel"]'
+ };
+ var PointerType = {
+ TOUCH: 'touch',
+ PEN: 'pen'
/**
* ------------------------------------------------------------------------
- * Constants
+ * Class Definition
* ------------------------------------------------------------------------
*/
- var NAME = 'carousel';
- var VERSION = '4.1.3';
- var DATA_KEY = 'bs.carousel';
- var EVENT_KEY = "." + DATA_KEY;
- var DATA_API_KEY = '.data-api';
- var JQUERY_NO_CONFLICT = $$$1.fn[NAME];
- var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
-
- var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
-
- var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
-
- var Default = {
- interval: 5000,
- keyboard: true,
- slide: false,
- pause: 'hover',
- wrap: true
- };
- var DefaultType = {
- interval: '(number|boolean)',
- keyboard: 'boolean',
- slide: '(boolean|string)',
- pause: '(string|boolean)',
- wrap: 'boolean'
- };
- var Direction = {
- NEXT: 'next',
- PREV: 'prev',
- LEFT: 'left',
- RIGHT: 'right'
+
+ };
+
+ var Carousel =
+ /*#__PURE__*/
+ function () {
+ function Carousel(element, config) {
+ this._items = null;
+ this._interval = null;
+ this._activeElement = null;
+ this._isPaused = false;
+ this._isSliding = false;
+ this.touchTimeout = null;
+ this.touchStartX = 0;
+ this.touchDeltaX = 0;
+ this._config = this._getConfig(config);
+ this._element = element;
+ this._indicatorsElement = this._element.querySelector(Selector.INDICATORS);
+ this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
+ this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
+
+ this._addEventListeners();
+ } // Getters
+
+
+ var _proto = Carousel.prototype;
+
+ // Public
+ _proto.next = function next() {
+ if (!this._isSliding) {
+ this._slide(Direction.NEXT);
+ }
};
- var Event = {
- SLIDE: "slide" + EVENT_KEY,
- SLID: "slid" + EVENT_KEY,
- KEYDOWN: "keydown" + EVENT_KEY,
- MOUSEENTER: "mouseenter" + EVENT_KEY,
- MOUSELEAVE: "mouseleave" + EVENT_KEY,
- TOUCHEND: "touchend" + EVENT_KEY,
- LOAD_DATA_API: "load" + EVENT_KEY + DATA_API_KEY,
- CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
+
+ _proto.nextWhenVisible = function nextWhenVisible() {
+ // Don't call next when the page isn't visible
+ // or the carousel or its parent isn't visible
+ if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
+ this.next();
+ }
};
- var ClassName = {
- CAROUSEL: 'carousel',
- ACTIVE: 'active',
- SLIDE: 'slide',
- RIGHT: 'carousel-item-right',
- LEFT: 'carousel-item-left',
- NEXT: 'carousel-item-next',
- PREV: 'carousel-item-prev',
- ITEM: 'carousel-item'
+
+ _proto.prev = function prev() {
+ if (!this._isSliding) {
+ this._slide(Direction.PREV);
+ }
};
- var Selector = {
- ACTIVE: '.active',
- ACTIVE_ITEM: '.active.carousel-item',
- ITEM: '.carousel-item',
- NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
- INDICATORS: '.carousel-indicators',
- DATA_SLIDE: '[data-slide], [data-slide-to]',
- DATA_RIDE: '[data-ride="carousel"]'
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
+ _proto.pause = function pause(event) {
+ if (!event) {
+ this._isPaused = true;
+ }
+
+ if (this._element.querySelector(Selector.NEXT_PREV)) {
+ Util.triggerTransitionEnd(this._element);
+ this.cycle(true);
+ }
+
+ clearInterval(this._interval);
+ this._interval = null;
};
- var Carousel =
- /*#__PURE__*/
- function () {
- function Carousel(element, config) {
- this._items = null;
- this._interval = null;
- this._activeElement = null;
+ _proto.cycle = function cycle(event) {
+ if (!event) {
this._isPaused = false;
- this._isSliding = false;
- this.touchTimeout = null;
- this._config = this._getConfig(config);
- this._element = $$$1(element)[0];
- this._indicatorsElement = this._element.querySelector(Selector.INDICATORS);
-
- this._addEventListeners();
- } // Getters
+ }
+ if (this._interval) {
+ clearInterval(this._interval);
+ this._interval = null;
+ }
- var _proto = Carousel.prototype;
+ if (this._config.interval && !this._isPaused) {
+ this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
+ }
+ };
- // Public
- _proto.next = function next() {
- if (!this._isSliding) {
- this._slide(Direction.NEXT);
- }
- };
+ _proto.to = function to(index) {
+ var _this = this;
- _proto.nextWhenVisible = function nextWhenVisible() {
- // Don't call next when the page isn't visible
- // or the carousel or its parent isn't visible
- if (!document.hidden && $$$1(this._element).is(':visible') && $$$1(this._element).css('visibility') !== 'hidden') {
- this.next();
- }
- };
+ this._activeElement = this._element.querySelector(Selector.ACTIVE_ITEM);
- _proto.prev = function prev() {
- if (!this._isSliding) {
- this._slide(Direction.PREV);
- }
- };
+ var activeIndex = this._getItemIndex(this._activeElement);
- _proto.pause = function pause(event) {
- if (!event) {
- this._isPaused = true;
- }
+ if (index > this._items.length - 1 || index < 0) {
+ return;
+ }
- if (this._element.querySelector(Selector.NEXT_PREV)) {
- Util.triggerTransitionEnd(this._element);
- this.cycle(true);
- }
+ if (this._isSliding) {
+ $(this._element).one(Event.SLID, function () {
+ return _this.to(index);
+ });
+ return;
+ }
- clearInterval(this._interval);
- this._interval = null;
- };
+ if (activeIndex === index) {
+ this.pause();
+ this.cycle();
+ return;
+ }
- _proto.cycle = function cycle(event) {
- if (!event) {
- this._isPaused = false;
- }
+ var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
- if (this._interval) {
- clearInterval(this._interval);
- this._interval = null;
- }
+ this._slide(direction, this._items[index]);
+ };
- if (this._config.interval && !this._isPaused) {
- this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
- }
- };
+ _proto.dispose = function dispose() {
+ $(this._element).off(EVENT_KEY);
+ $.removeData(this._element, DATA_KEY);
+ this._items = null;
+ this._config = null;
+ this._element = null;
+ this._interval = null;
+ this._isPaused = null;
+ this._isSliding = null;
+ this._activeElement = null;
+ this._indicatorsElement = null;
+ } // Private
+ ;
+
+ _proto._getConfig = function _getConfig(config) {
+ config = _objectSpread({}, Default, config);
+ Util.typeCheckConfig(NAME, config, DefaultType);
+ return config;
+ };
- _proto.to = function to(index) {
- var _this = this;
+ _proto._handleSwipe = function _handleSwipe() {
+ var absDeltax = Math.abs(this.touchDeltaX);
- this._activeElement = this._element.querySelector(Selector.ACTIVE_ITEM);
+ if (absDeltax <= SWIPE_THRESHOLD) {
+ return;
+ }
- var activeIndex = this._getItemIndex(this._activeElement);
+ var direction = absDeltax / this.touchDeltaX; // swipe left
- if (index > this._items.length - 1 || index < 0) {
- return;
- }
+ if (direction > 0) {
+ this.prev();
+ } // swipe right
- if (this._isSliding) {
- $$$1(this._element).one(Event.SLID, function () {
- return _this.to(index);
- });
- return;
- }
- if (activeIndex === index) {
- this.pause();
- this.cycle();
- return;
- }
+ if (direction < 0) {
+ this.next();
+ }
+ };
- var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
+ _proto._addEventListeners = function _addEventListeners() {
+ var _this2 = this;
- this._slide(direction, this._items[index]);
- };
+ if (this._config.keyboard) {
+ $(this._element).on(Event.KEYDOWN, function (event) {
+ return _this2._keydown(event);
+ });
+ }
- _proto.dispose = function dispose() {
- $$$1(this._element).off(EVENT_KEY);
- $$$1.removeData(this._element, DATA_KEY);
- this._items = null;
- this._config = null;
- this._element = null;
- this._interval = null;
- this._isPaused = null;
- this._isSliding = null;
- this._activeElement = null;
- this._indicatorsElement = null;
- }; // Private
+ if (this._config.pause === 'hover') {
+ $(this._element).on(Event.MOUSEENTER, function (event) {
+ return _this2.pause(event);
+ }).on(Event.MOUSELEAVE, function (event) {
+ return _this2.cycle(event);
+ });
+ }
+ if (this._config.touch) {
+ this._addTouchEventListeners();
+ }
+ };
- _proto._getConfig = function _getConfig(config) {
- config = _objectSpread({}, Default, config);
- Util.typeCheckConfig(NAME, config, DefaultType);
- return config;
- };
+ _proto._addTouchEventListeners = function _addTouchEventListeners() {
+ var _this3 = this;
- _proto._addEventListeners = function _addEventListeners() {
- var _this2 = this;
+ if (!this._touchSupported) {
+ return;
+ }
- if (this._config.keyboard) {
- $$$1(this._element).on(Event.KEYDOWN, function (event) {
- return _this2._keydown(event);
- });
+ var start = function start(event) {
+ if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
+ _this3.touchStartX = event.originalEvent.clientX;
+ } else if (!_this3._pointerEvent) {
+ _this3.touchStartX = event.originalEvent.touches[0].clientX;
}
+ };
- if (this._config.pause === 'hover') {
- $$$1(this._element).on(Event.MOUSEENTER, function (event) {
- return _this2.pause(event);
- }).on(Event.MOUSELEAVE, function (event) {
- return _this2.cycle(event);
- });
-
- if ('ontouchstart' in document.documentElement) {
- // If it's a touch-enabled device, mouseenter/leave are fired as
- // part of the mouse compatibility events on first tap - the carousel
- // would stop cycling until user tapped out of it;
- // here, we listen for touchend, explicitly pause the carousel
- // (as if it's the second time we tap on it, mouseenter compat event
- // is NOT fired) and after a timeout (to allow for mouse compatibility
- // events to fire) we explicitly restart cycling
- $$$1(this._element).on(Event.TOUCHEND, function () {
- _this2.pause();
-
- if (_this2.touchTimeout) {
- clearTimeout(_this2.touchTimeout);
- }
-
- _this2.touchTimeout = setTimeout(function (event) {
- return _this2.cycle(event);
- }, TOUCHEVENT_COMPAT_WAIT + _this2._config.interval);
- });
- }
+ var move = function move(event) {
+ // ensure swiping with one touch and not pinching
+ if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
+ _this3.touchDeltaX = 0;
+ } else {
+ _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
}
};
- _proto._keydown = function _keydown(event) {
- if (/input|textarea/i.test(event.target.tagName)) {
- return;
+ var end = function end(event) {
+ if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
+ _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
}
- switch (event.which) {
- case ARROW_LEFT_KEYCODE:
- event.preventDefault();
- this.prev();
- break;
+ _this3._handleSwipe();
- case ARROW_RIGHT_KEYCODE:
- event.preventDefault();
- this.next();
- break;
+ if (_this3._config.pause === 'hover') {
+ // If it's a touch-enabled device, mouseenter/leave are fired as
+ // part of the mouse compatibility events on first tap - the carousel
+ // would stop cycling until user tapped out of it;
+ // here, we listen for touchend, explicitly pause the carousel
+ // (as if it's the second time we tap on it, mouseenter compat event
+ // is NOT fired) and after a timeout (to allow for mouse compatibility
+ // events to fire) we explicitly restart cycling
+ _this3.pause();
- default:
- }
- };
+ if (_this3.touchTimeout) {
+ clearTimeout(_this3.touchTimeout);
+ }
- _proto._getItemIndex = function _getItemIndex(element) {
- this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector.ITEM)) : [];
- return this._items.indexOf(element);
+ _this3.touchTimeout = setTimeout(function (event) {
+ return _this3.cycle(event);
+ }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
+ }
};
- _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
- var isNextDirection = direction === Direction.NEXT;
- var isPrevDirection = direction === Direction.PREV;
+ $(this._element.querySelectorAll(Selector.ITEM_IMG)).on(Event.DRAG_START, function (e) {
+ return e.preventDefault();
+ });
- var activeIndex = this._getItemIndex(activeElement);
+ if (this._pointerEvent) {
+ $(this._element).on(Event.POINTERDOWN, function (event) {
+ return start(event);
+ });
+ $(this._element).on(Event.POINTERUP, function (event) {
+ return end(event);
+ });
- var lastItemIndex = this._items.length - 1;
- var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
+ this._element.classList.add(ClassName.POINTER_EVENT);
+ } else {
+ $(this._element).on(Event.TOUCHSTART, function (event) {
+ return start(event);
+ });
+ $(this._element).on(Event.TOUCHMOVE, function (event) {
+ return move(event);
+ });
+ $(this._element).on(Event.TOUCHEND, function (event) {
+ return end(event);
+ });
+ }
+ };
- if (isGoingToWrap && !this._config.wrap) {
- return activeElement;
- }
+ _proto._keydown = function _keydown(event) {
+ if (/input|textarea/i.test(event.target.tagName)) {
+ return;
+ }
- var delta = direction === Direction.PREV ? -1 : 1;
- var itemIndex = (activeIndex + delta) % this._items.length;
- return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
- };
+ switch (event.which) {
+ case ARROW_LEFT_KEYCODE:
+ event.preventDefault();
+ this.prev();
+ break;
- _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
- var targetIndex = this._getItemIndex(relatedTarget);
+ case ARROW_RIGHT_KEYCODE:
+ event.preventDefault();
+ this.next();
+ break;
- var fromIndex = this._getItemIndex(this._element.querySelector(Selector.ACTIVE_ITEM));
+ default:
+ }
+ };
- var slideEvent = $$$1.Event(Event.SLIDE, {
- relatedTarget: relatedTarget,
- direction: eventDirectionName,
- from: fromIndex,
- to: targetIndex
- });
- $$$1(this._element).trigger(slideEvent);
- return slideEvent;
- };
+ _proto._getItemIndex = function _getItemIndex(element) {
+ this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector.ITEM)) : [];
+ return this._items.indexOf(element);
+ };
- _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
- if (this._indicatorsElement) {
- var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector.ACTIVE));
- $$$1(indicators).removeClass(ClassName.ACTIVE);
+ _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
+ var isNextDirection = direction === Direction.NEXT;
+ var isPrevDirection = direction === Direction.PREV;
- var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
+ var activeIndex = this._getItemIndex(activeElement);
- if (nextIndicator) {
- $$$1(nextIndicator).addClass(ClassName.ACTIVE);
- }
- }
- };
+ var lastItemIndex = this._items.length - 1;
+ var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
- _proto._slide = function _slide(direction, element) {
- var _this3 = this;
+ if (isGoingToWrap && !this._config.wrap) {
+ return activeElement;
+ }
- var activeElement = this._element.querySelector(Selector.ACTIVE_ITEM);
+ var delta = direction === Direction.PREV ? -1 : 1;
+ var itemIndex = (activeIndex + delta) % this._items.length;
+ return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
+ };
- var activeElementIndex = this._getItemIndex(activeElement);
+ _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
+ var targetIndex = this._getItemIndex(relatedTarget);
- var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
+ var fromIndex = this._getItemIndex(this._element.querySelector(Selector.ACTIVE_ITEM));
- var nextElementIndex = this._getItemIndex(nextElement);
+ var slideEvent = $.Event(Event.SLIDE, {
+ relatedTarget: relatedTarget,
+ direction: eventDirectionName,
+ from: fromIndex,
+ to: targetIndex
+ });
+ $(this._element).trigger(slideEvent);
+ return slideEvent;
+ };
- var isCycling = Boolean(this._interval);
- var directionalClassName;
- var orderClassName;
- var eventDirectionName;
+ _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
+ if (this._indicatorsElement) {
+ var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector.ACTIVE));
+ $(indicators).removeClass(ClassName.ACTIVE);
- if (direction === Direction.NEXT) {
- directionalClassName = ClassName.LEFT;
- orderClassName = ClassName.NEXT;
- eventDirectionName = Direction.LEFT;
- } else {
- directionalClassName = ClassName.RIGHT;
- orderClassName = ClassName.PREV;
- eventDirectionName = Direction.RIGHT;
- }
+ var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
- if (nextElement && $$$1(nextElement).hasClass(ClassName.ACTIVE)) {
- this._isSliding = false;
- return;
+ if (nextIndicator) {
+ $(nextIndicator).addClass(ClassName.ACTIVE);
}
+ }
+ };
- var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
-
- if (slideEvent.isDefaultPrevented()) {
- return;
- }
+ _proto._slide = function _slide(direction, element) {
+ var _this4 = this;
- if (!activeElement || !nextElement) {
- // Some weirdness is happening, so we bail
- return;
- }
+ var activeElement = this._element.querySelector(Selector.ACTIVE_ITEM);
- this._isSliding = true;
+ var activeElementIndex = this._getItemIndex(activeElement);
- if (isCycling) {
- this.pause();
- }
+ var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
- this._setActiveIndicatorElement(nextElement);
+ var nextElementIndex = this._getItemIndex(nextElement);
- var slidEvent = $$$1.Event(Event.SLID, {
- relatedTarget: nextElement,
- direction: eventDirectionName,
- from: activeElementIndex,
- to: nextElementIndex
- });
+ var isCycling = Boolean(this._interval);
+ var directionalClassName;
+ var orderClassName;
+ var eventDirectionName;
- if ($$$1(this._element).hasClass(ClassName.SLIDE)) {
- $$$1(nextElement).addClass(orderClassName);
- Util.reflow(nextElement);
- $$$1(activeElement).addClass(directionalClassName);
- $$$1(nextElement).addClass(directionalClassName);
- var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
- $$$1(activeElement).one(Util.TRANSITION_END, function () {
- $$$1(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName.ACTIVE);
- $$$1(activeElement).removeClass(ClassName.ACTIVE + " " + orderClassName + " " + directionalClassName);
- _this3._isSliding = false;
- setTimeout(function () {
- return $$$1(_this3._element).trigger(slidEvent);
- }, 0);
- }).emulateTransitionEnd(transitionDuration);
- } else {
- $$$1(activeElement).removeClass(ClassName.ACTIVE);
- $$$1(nextElement).addClass(ClassName.ACTIVE);
- this._isSliding = false;
- $$$1(this._element).trigger(slidEvent);
- }
+ if (direction === Direction.NEXT) {
+ directionalClassName = ClassName.LEFT;
+ orderClassName = ClassName.NEXT;
+ eventDirectionName = Direction.LEFT;
+ } else {
+ directionalClassName = ClassName.RIGHT;
+ orderClassName = ClassName.PREV;
+ eventDirectionName = Direction.RIGHT;
+ }
- if (isCycling) {
- this.cycle();
- }
- }; // Static
+ if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) {
+ this._isSliding = false;
+ return;
+ }
+ var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
- Carousel._jQueryInterface = function _jQueryInterface(config) {
- return this.each(function () {
- var data = $$$1(this).data(DATA_KEY);
+ if (slideEvent.isDefaultPrevented()) {
+ return;
+ }
- var _config = _objectSpread({}, Default, $$$1(this).data());
+ if (!activeElement || !nextElement) {
+ // Some weirdness is happening, so we bail
+ return;
+ }
- if (typeof config === 'object') {
- _config = _objectSpread({}, _config, config);
- }
+ this._isSliding = true;
- var action = typeof config === 'string' ? config : _config.slide;
+ if (isCycling) {
+ this.pause();
+ }
- if (!data) {
- data = new Carousel(this, _config);
- $$$1(this).data(DATA_KEY, data);
- }
+ this._setActiveIndicatorElement(nextElement);
- if (typeof config === 'number') {
- data.to(config);
- } else if (typeof action === 'string') {
- if (typeof data[action] === 'undefined') {
- throw new TypeError("No method named \"" + action + "\"");
- }
-
- data[action]();
- } else if (_config.interval) {
- data.pause();
- data.cycle();
- }
- });
- };
+ var slidEvent = $.Event(Event.SLID, {
+ relatedTarget: nextElement,
+ direction: eventDirectionName,
+ from: activeElementIndex,
+ to: nextElementIndex
+ });
- Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
- var selector = Util.getSelectorFromElement(this);
+ if ($(this._element).hasClass(ClassName.SLIDE)) {
+ $(nextElement).addClass(orderClassName);
+ Util.reflow(nextElement);
+ $(activeElement).addClass(directionalClassName);
+ $(nextElement).addClass(directionalClassName);
+ var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
- if (!selector) {
- return;
+ if (nextElementInterval) {
+ this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
+ this._config.interval = nextElementInterval;
+ } else {
+ this._config.interval = this._config.defaultInterval || this._config.interval;
}
- var target = $$$1(selector)[0];
+ var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
+ $(activeElement).one(Util.TRANSITION_END, function () {
+ $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName.ACTIVE);
+ $(activeElement).removeClass(ClassName.ACTIVE + " " + orderClassName + " " + directionalClassName);
+ _this4._isSliding = false;
+ setTimeout(function () {
+ return $(_this4._element).trigger(slidEvent);
+ }, 0);
+ }).emulateTransitionEnd(transitionDuration);
+ } else {
+ $(activeElement).removeClass(ClassName.ACTIVE);
+ $(nextElement).addClass(ClassName.ACTIVE);
+ this._isSliding = false;
+ $(this._element).trigger(slidEvent);
+ }
- if (!target || !$$$1(target).hasClass(ClassName.CAROUSEL)) {
- return;
- }
+ if (isCycling) {
+ this.cycle();
+ }
+ } // Static
+ ;
- var config = _objectSpread({}, $$$1(target).data(), $$$1(this).data());
+ Carousel._jQueryInterface = function _jQueryInterface(config) {
+ return this.each(function () {
+ var data = $(this).data(DATA_KEY);
- var slideIndex = this.getAttribute('data-slide-to');
+ var _config = _objectSpread({}, Default, $(this).data());
- if (slideIndex) {
- config.interval = false;
+ if (typeof config === 'object') {
+ _config = _objectSpread({}, _config, config);
}
- Carousel._jQueryInterface.call($$$1(target), config);
+ var action = typeof config === 'string' ? config : _config.slide;
- if (slideIndex) {
- $$$1(target).data(DATA_KEY).to(slideIndex);
+ if (!data) {
+ data = new Carousel(this, _config);
+ $(this).data(DATA_KEY, data);
}
- event.preventDefault();
- };
+ if (typeof config === 'number') {
+ data.to(config);
+ } else if (typeof action === 'string') {
+ if (typeof data[action] === 'undefined') {
+ throw new TypeError("No method named \"" + action + "\"");
+ }
- _createClass(Carousel, null, [{
- key: "VERSION",
- get: function get() {
- return VERSION;
- }
- }, {
- key: "Default",
- get: function get() {
- return Default;
+ data[action]();
+ } else if (_config.interval && _config.ride) {
+ data.pause();
+ data.cycle();
}
- }]);
+ });
+ };
- return Carousel;
- }();
- /**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
- */
+ Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
+ var selector = Util.getSelectorFromElement(this);
+ if (!selector) {
+ return;
+ }
- $$$1(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler);
- $$$1(window).on(Event.LOAD_DATA_API, function () {
- var carousels = [].slice.call(document.querySelectorAll(Selector.DATA_RIDE));
+ var target = $(selector)[0];
- for (var i = 0, len = carousels.length; i < len; i++) {
- var $carousel = $$$1(carousels[i]);
+ if (!target || !$(target).hasClass(ClassName.CAROUSEL)) {
+ return;
+ }
+
+ var config = _objectSpread({}, $(target).data(), $(this).data());
- Carousel._jQueryInterface.call($carousel, $carousel.data());
+ var slideIndex = this.getAttribute('data-slide-to');
+
+ if (slideIndex) {
+ config.interval = false;
}
- });
- /**
- * ------------------------------------------------------------------------
- * jQuery
- * ------------------------------------------------------------------------
- */
- $$$1.fn[NAME] = Carousel._jQueryInterface;
- $$$1.fn[NAME].Constructor = Carousel;
+ Carousel._jQueryInterface.call($(target), config);
+
+ if (slideIndex) {
+ $(target).data(DATA_KEY).to(slideIndex);
+ }
- $$$1.fn[NAME].noConflict = function () {
- $$$1.fn[NAME] = JQUERY_NO_CONFLICT;
- return Carousel._jQueryInterface;
+ event.preventDefault();
};
+ _createClass(Carousel, null, [{
+ key: "VERSION",
+ get: function get() {
+ return VERSION;
+ }
+ }, {
+ key: "Default",
+ get: function get() {
+ return Default;
+ }
+ }]);
+
return Carousel;
- }($);
+ }();
+ /**
+ * ------------------------------------------------------------------------
+ * Data Api implementation
+ * ------------------------------------------------------------------------
+ */
+
+
+ $(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler);
+ $(window).on(Event.LOAD_DATA_API, function () {
+ var carousels = [].slice.call(document.querySelectorAll(Selector.DATA_RIDE));
+
+ for (var i = 0, len = carousels.length; i < len; i++) {
+ var $carousel = $(carousels[i]);
+
+ Carousel._jQueryInterface.call($carousel, $carousel.data());
+ }
+ });
+ /**
+ * ------------------------------------------------------------------------
+ * jQuery
+ * ------------------------------------------------------------------------
+ */
+
+ $.fn[NAME] = Carousel._jQueryInterface;
+ $.fn[NAME].Constructor = Carousel;
+
+ $.fn[NAME].noConflict = function () {
+ $.fn[NAME] = JQUERY_NO_CONFLICT;
+ return Carousel._jQueryInterface;
+ };
return Carousel;
-})));
+}));
//# sourceMappingURL=carousel.js.map