source: trip-planner-front/node_modules/bootstrap/js/dist/carousel.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 23.5 KB
Line 
1/*!
2 * Bootstrap carousel.js v5.1.3 (https://getbootstrap.com/)
3 * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5 */
6(function (global, factory) {
7 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./base-component.js')) :
8 typeof define === 'function' && define.amd ? define(['./dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) :
9 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Carousel = factory(global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base));
10})(this, (function (EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict';
11
12 const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
13
14 const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
15 const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
16 const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
17 const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
18
19 /**
20 * --------------------------------------------------------------------------
21 * Bootstrap (v5.1.3): util/index.js
22 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
23 * --------------------------------------------------------------------------
24 */
25 const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
26
27 const toType = obj => {
28 if (obj === null || obj === undefined) {
29 return `${obj}`;
30 }
31
32 return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
33 };
34
35 const getSelector = element => {
36 let selector = element.getAttribute('data-bs-target');
37
38 if (!selector || selector === '#') {
39 let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
40 // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
41 // `document.querySelector` will rightfully complain it is invalid.
42 // See https://github.com/twbs/bootstrap/issues/32273
43
44 if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) {
45 return null;
46 } // Just in case some CMS puts out a full URL with the anchor appended
47
48
49 if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
50 hrefAttr = `#${hrefAttr.split('#')[1]}`;
51 }
52
53 selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
54 }
55
56 return selector;
57 };
58
59 const getElementFromSelector = element => {
60 const selector = getSelector(element);
61 return selector ? document.querySelector(selector) : null;
62 };
63
64 const triggerTransitionEnd = element => {
65 element.dispatchEvent(new Event(TRANSITION_END));
66 };
67
68 const isElement = obj => {
69 if (!obj || typeof obj !== 'object') {
70 return false;
71 }
72
73 if (typeof obj.jquery !== 'undefined') {
74 obj = obj[0];
75 }
76
77 return typeof obj.nodeType !== 'undefined';
78 };
79
80 const typeCheckConfig = (componentName, config, configTypes) => {
81 Object.keys(configTypes).forEach(property => {
82 const expectedTypes = configTypes[property];
83 const value = config[property];
84 const valueType = value && isElement(value) ? 'element' : toType(value);
85
86 if (!new RegExp(expectedTypes).test(valueType)) {
87 throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
88 }
89 });
90 };
91
92 const isVisible = element => {
93 if (!isElement(element) || element.getClientRects().length === 0) {
94 return false;
95 }
96
97 return getComputedStyle(element).getPropertyValue('visibility') === 'visible';
98 };
99 /**
100 * Trick to restart an element's animation
101 *
102 * @param {HTMLElement} element
103 * @return void
104 *
105 * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
106 */
107
108
109 const reflow = element => {
110 // eslint-disable-next-line no-unused-expressions
111 element.offsetHeight;
112 };
113
114 const getjQuery = () => {
115 const {
116 jQuery
117 } = window;
118
119 if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
120 return jQuery;
121 }
122
123 return null;
124 };
125
126 const DOMContentLoadedCallbacks = [];
127
128 const onDOMContentLoaded = callback => {
129 if (document.readyState === 'loading') {
130 // add listener on the first call when the document is in loading state
131 if (!DOMContentLoadedCallbacks.length) {
132 document.addEventListener('DOMContentLoaded', () => {
133 DOMContentLoadedCallbacks.forEach(callback => callback());
134 });
135 }
136
137 DOMContentLoadedCallbacks.push(callback);
138 } else {
139 callback();
140 }
141 };
142
143 const isRTL = () => document.documentElement.dir === 'rtl';
144
145 const defineJQueryPlugin = plugin => {
146 onDOMContentLoaded(() => {
147 const $ = getjQuery();
148 /* istanbul ignore if */
149
150 if ($) {
151 const name = plugin.NAME;
152 const JQUERY_NO_CONFLICT = $.fn[name];
153 $.fn[name] = plugin.jQueryInterface;
154 $.fn[name].Constructor = plugin;
155
156 $.fn[name].noConflict = () => {
157 $.fn[name] = JQUERY_NO_CONFLICT;
158 return plugin.jQueryInterface;
159 };
160 }
161 });
162 };
163 /**
164 * Return the previous/next element of a list.
165 *
166 * @param {array} list The list of elements
167 * @param activeElement The active element
168 * @param shouldGetNext Choose to get next or previous element
169 * @param isCycleAllowed
170 * @return {Element|elem} The proper element
171 */
172
173
174 const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
175 let index = list.indexOf(activeElement); // if the element does not exist in the list return an element depending on the direction and if cycle is allowed
176
177 if (index === -1) {
178 return list[!shouldGetNext && isCycleAllowed ? list.length - 1 : 0];
179 }
180
181 const listLength = list.length;
182 index += shouldGetNext ? 1 : -1;
183
184 if (isCycleAllowed) {
185 index = (index + listLength) % listLength;
186 }
187
188 return list[Math.max(0, Math.min(index, listLength - 1))];
189 };
190
191 /**
192 * --------------------------------------------------------------------------
193 * Bootstrap (v5.1.3): carousel.js
194 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
195 * --------------------------------------------------------------------------
196 */
197 /**
198 * ------------------------------------------------------------------------
199 * Constants
200 * ------------------------------------------------------------------------
201 */
202
203 const NAME = 'carousel';
204 const DATA_KEY = 'bs.carousel';
205 const EVENT_KEY = `.${DATA_KEY}`;
206 const DATA_API_KEY = '.data-api';
207 const ARROW_LEFT_KEY = 'ArrowLeft';
208 const ARROW_RIGHT_KEY = 'ArrowRight';
209 const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
210
211 const SWIPE_THRESHOLD = 40;
212 const Default = {
213 interval: 5000,
214 keyboard: true,
215 slide: false,
216 pause: 'hover',
217 wrap: true,
218 touch: true
219 };
220 const DefaultType = {
221 interval: '(number|boolean)',
222 keyboard: 'boolean',
223 slide: '(boolean|string)',
224 pause: '(string|boolean)',
225 wrap: 'boolean',
226 touch: 'boolean'
227 };
228 const ORDER_NEXT = 'next';
229 const ORDER_PREV = 'prev';
230 const DIRECTION_LEFT = 'left';
231 const DIRECTION_RIGHT = 'right';
232 const KEY_TO_DIRECTION = {
233 [ARROW_LEFT_KEY]: DIRECTION_RIGHT,
234 [ARROW_RIGHT_KEY]: DIRECTION_LEFT
235 };
236 const EVENT_SLIDE = `slide${EVENT_KEY}`;
237 const EVENT_SLID = `slid${EVENT_KEY}`;
238 const EVENT_KEYDOWN = `keydown${EVENT_KEY}`;
239 const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY}`;
240 const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY}`;
241 const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`;
242 const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`;
243 const EVENT_TOUCHEND = `touchend${EVENT_KEY}`;
244 const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY}`;
245 const EVENT_POINTERUP = `pointerup${EVENT_KEY}`;
246 const EVENT_DRAG_START = `dragstart${EVENT_KEY}`;
247 const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
248 const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
249 const CLASS_NAME_CAROUSEL = 'carousel';
250 const CLASS_NAME_ACTIVE = 'active';
251 const CLASS_NAME_SLIDE = 'slide';
252 const CLASS_NAME_END = 'carousel-item-end';
253 const CLASS_NAME_START = 'carousel-item-start';
254 const CLASS_NAME_NEXT = 'carousel-item-next';
255 const CLASS_NAME_PREV = 'carousel-item-prev';
256 const CLASS_NAME_POINTER_EVENT = 'pointer-event';
257 const SELECTOR_ACTIVE = '.active';
258 const SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
259 const SELECTOR_ITEM = '.carousel-item';
260 const SELECTOR_ITEM_IMG = '.carousel-item img';
261 const SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
262 const SELECTOR_INDICATORS = '.carousel-indicators';
263 const SELECTOR_INDICATOR = '[data-bs-target]';
264 const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
265 const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
266 const POINTER_TYPE_TOUCH = 'touch';
267 const POINTER_TYPE_PEN = 'pen';
268 /**
269 * ------------------------------------------------------------------------
270 * Class Definition
271 * ------------------------------------------------------------------------
272 */
273
274 class Carousel extends BaseComponent__default.default {
275 constructor(element, config) {
276 super(element);
277 this._items = null;
278 this._interval = null;
279 this._activeElement = null;
280 this._isPaused = false;
281 this._isSliding = false;
282 this.touchTimeout = null;
283 this.touchStartX = 0;
284 this.touchDeltaX = 0;
285 this._config = this._getConfig(config);
286 this._indicatorsElement = SelectorEngine__default.default.findOne(SELECTOR_INDICATORS, this._element);
287 this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
288 this._pointerEvent = Boolean(window.PointerEvent);
289
290 this._addEventListeners();
291 } // Getters
292
293
294 static get Default() {
295 return Default;
296 }
297
298 static get NAME() {
299 return NAME;
300 } // Public
301
302
303 next() {
304 this._slide(ORDER_NEXT);
305 }
306
307 nextWhenVisible() {
308 // Don't call next when the page isn't visible
309 // or the carousel or its parent isn't visible
310 if (!document.hidden && isVisible(this._element)) {
311 this.next();
312 }
313 }
314
315 prev() {
316 this._slide(ORDER_PREV);
317 }
318
319 pause(event) {
320 if (!event) {
321 this._isPaused = true;
322 }
323
324 if (SelectorEngine__default.default.findOne(SELECTOR_NEXT_PREV, this._element)) {
325 triggerTransitionEnd(this._element);
326 this.cycle(true);
327 }
328
329 clearInterval(this._interval);
330 this._interval = null;
331 }
332
333 cycle(event) {
334 if (!event) {
335 this._isPaused = false;
336 }
337
338 if (this._interval) {
339 clearInterval(this._interval);
340 this._interval = null;
341 }
342
343 if (this._config && this._config.interval && !this._isPaused) {
344 this._updateInterval();
345
346 this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
347 }
348 }
349
350 to(index) {
351 this._activeElement = SelectorEngine__default.default.findOne(SELECTOR_ACTIVE_ITEM, this._element);
352
353 const activeIndex = this._getItemIndex(this._activeElement);
354
355 if (index > this._items.length - 1 || index < 0) {
356 return;
357 }
358
359 if (this._isSliding) {
360 EventHandler__default.default.one(this._element, EVENT_SLID, () => this.to(index));
361 return;
362 }
363
364 if (activeIndex === index) {
365 this.pause();
366 this.cycle();
367 return;
368 }
369
370 const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV;
371
372 this._slide(order, this._items[index]);
373 } // Private
374
375
376 _getConfig(config) {
377 config = { ...Default,
378 ...Manipulator__default.default.getDataAttributes(this._element),
379 ...(typeof config === 'object' ? config : {})
380 };
381 typeCheckConfig(NAME, config, DefaultType);
382 return config;
383 }
384
385 _handleSwipe() {
386 const absDeltax = Math.abs(this.touchDeltaX);
387
388 if (absDeltax <= SWIPE_THRESHOLD) {
389 return;
390 }
391
392 const direction = absDeltax / this.touchDeltaX;
393 this.touchDeltaX = 0;
394
395 if (!direction) {
396 return;
397 }
398
399 this._slide(direction > 0 ? DIRECTION_RIGHT : DIRECTION_LEFT);
400 }
401
402 _addEventListeners() {
403 if (this._config.keyboard) {
404 EventHandler__default.default.on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
405 }
406
407 if (this._config.pause === 'hover') {
408 EventHandler__default.default.on(this._element, EVENT_MOUSEENTER, event => this.pause(event));
409 EventHandler__default.default.on(this._element, EVENT_MOUSELEAVE, event => this.cycle(event));
410 }
411
412 if (this._config.touch && this._touchSupported) {
413 this._addTouchEventListeners();
414 }
415 }
416
417 _addTouchEventListeners() {
418 const hasPointerPenTouch = event => {
419 return this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH);
420 };
421
422 const start = event => {
423 if (hasPointerPenTouch(event)) {
424 this.touchStartX = event.clientX;
425 } else if (!this._pointerEvent) {
426 this.touchStartX = event.touches[0].clientX;
427 }
428 };
429
430 const move = event => {
431 // ensure swiping with one touch and not pinching
432 this.touchDeltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this.touchStartX;
433 };
434
435 const end = event => {
436 if (hasPointerPenTouch(event)) {
437 this.touchDeltaX = event.clientX - this.touchStartX;
438 }
439
440 this._handleSwipe();
441
442 if (this._config.pause === 'hover') {
443 // If it's a touch-enabled device, mouseenter/leave are fired as
444 // part of the mouse compatibility events on first tap - the carousel
445 // would stop cycling until user tapped out of it;
446 // here, we listen for touchend, explicitly pause the carousel
447 // (as if it's the second time we tap on it, mouseenter compat event
448 // is NOT fired) and after a timeout (to allow for mouse compatibility
449 // events to fire) we explicitly restart cycling
450 this.pause();
451
452 if (this.touchTimeout) {
453 clearTimeout(this.touchTimeout);
454 }
455
456 this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval);
457 }
458 };
459
460 SelectorEngine__default.default.find(SELECTOR_ITEM_IMG, this._element).forEach(itemImg => {
461 EventHandler__default.default.on(itemImg, EVENT_DRAG_START, event => event.preventDefault());
462 });
463
464 if (this._pointerEvent) {
465 EventHandler__default.default.on(this._element, EVENT_POINTERDOWN, event => start(event));
466 EventHandler__default.default.on(this._element, EVENT_POINTERUP, event => end(event));
467
468 this._element.classList.add(CLASS_NAME_POINTER_EVENT);
469 } else {
470 EventHandler__default.default.on(this._element, EVENT_TOUCHSTART, event => start(event));
471 EventHandler__default.default.on(this._element, EVENT_TOUCHMOVE, event => move(event));
472 EventHandler__default.default.on(this._element, EVENT_TOUCHEND, event => end(event));
473 }
474 }
475
476 _keydown(event) {
477 if (/input|textarea/i.test(event.target.tagName)) {
478 return;
479 }
480
481 const direction = KEY_TO_DIRECTION[event.key];
482
483 if (direction) {
484 event.preventDefault();
485
486 this._slide(direction);
487 }
488 }
489
490 _getItemIndex(element) {
491 this._items = element && element.parentNode ? SelectorEngine__default.default.find(SELECTOR_ITEM, element.parentNode) : [];
492 return this._items.indexOf(element);
493 }
494
495 _getItemByOrder(order, activeElement) {
496 const isNext = order === ORDER_NEXT;
497 return getNextActiveElement(this._items, activeElement, isNext, this._config.wrap);
498 }
499
500 _triggerSlideEvent(relatedTarget, eventDirectionName) {
501 const targetIndex = this._getItemIndex(relatedTarget);
502
503 const fromIndex = this._getItemIndex(SelectorEngine__default.default.findOne(SELECTOR_ACTIVE_ITEM, this._element));
504
505 return EventHandler__default.default.trigger(this._element, EVENT_SLIDE, {
506 relatedTarget,
507 direction: eventDirectionName,
508 from: fromIndex,
509 to: targetIndex
510 });
511 }
512
513 _setActiveIndicatorElement(element) {
514 if (this._indicatorsElement) {
515 const activeIndicator = SelectorEngine__default.default.findOne(SELECTOR_ACTIVE, this._indicatorsElement);
516 activeIndicator.classList.remove(CLASS_NAME_ACTIVE);
517 activeIndicator.removeAttribute('aria-current');
518 const indicators = SelectorEngine__default.default.find(SELECTOR_INDICATOR, this._indicatorsElement);
519
520 for (let i = 0; i < indicators.length; i++) {
521 if (Number.parseInt(indicators[i].getAttribute('data-bs-slide-to'), 10) === this._getItemIndex(element)) {
522 indicators[i].classList.add(CLASS_NAME_ACTIVE);
523 indicators[i].setAttribute('aria-current', 'true');
524 break;
525 }
526 }
527 }
528 }
529
530 _updateInterval() {
531 const element = this._activeElement || SelectorEngine__default.default.findOne(SELECTOR_ACTIVE_ITEM, this._element);
532
533 if (!element) {
534 return;
535 }
536
537 const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
538
539 if (elementInterval) {
540 this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
541 this._config.interval = elementInterval;
542 } else {
543 this._config.interval = this._config.defaultInterval || this._config.interval;
544 }
545 }
546
547 _slide(directionOrOrder, element) {
548 const order = this._directionToOrder(directionOrOrder);
549
550 const activeElement = SelectorEngine__default.default.findOne(SELECTOR_ACTIVE_ITEM, this._element);
551
552 const activeElementIndex = this._getItemIndex(activeElement);
553
554 const nextElement = element || this._getItemByOrder(order, activeElement);
555
556 const nextElementIndex = this._getItemIndex(nextElement);
557
558 const isCycling = Boolean(this._interval);
559 const isNext = order === ORDER_NEXT;
560 const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END;
561 const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV;
562
563 const eventDirectionName = this._orderToDirection(order);
564
565 if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE)) {
566 this._isSliding = false;
567 return;
568 }
569
570 if (this._isSliding) {
571 return;
572 }
573
574 const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
575
576 if (slideEvent.defaultPrevented) {
577 return;
578 }
579
580 if (!activeElement || !nextElement) {
581 // Some weirdness is happening, so we bail
582 return;
583 }
584
585 this._isSliding = true;
586
587 if (isCycling) {
588 this.pause();
589 }
590
591 this._setActiveIndicatorElement(nextElement);
592
593 this._activeElement = nextElement;
594
595 const triggerSlidEvent = () => {
596 EventHandler__default.default.trigger(this._element, EVENT_SLID, {
597 relatedTarget: nextElement,
598 direction: eventDirectionName,
599 from: activeElementIndex,
600 to: nextElementIndex
601 });
602 };
603
604 if (this._element.classList.contains(CLASS_NAME_SLIDE)) {
605 nextElement.classList.add(orderClassName);
606 reflow(nextElement);
607 activeElement.classList.add(directionalClassName);
608 nextElement.classList.add(directionalClassName);
609
610 const completeCallBack = () => {
611 nextElement.classList.remove(directionalClassName, orderClassName);
612 nextElement.classList.add(CLASS_NAME_ACTIVE);
613 activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName);
614 this._isSliding = false;
615 setTimeout(triggerSlidEvent, 0);
616 };
617
618 this._queueCallback(completeCallBack, activeElement, true);
619 } else {
620 activeElement.classList.remove(CLASS_NAME_ACTIVE);
621 nextElement.classList.add(CLASS_NAME_ACTIVE);
622 this._isSliding = false;
623 triggerSlidEvent();
624 }
625
626 if (isCycling) {
627 this.cycle();
628 }
629 }
630
631 _directionToOrder(direction) {
632 if (![DIRECTION_RIGHT, DIRECTION_LEFT].includes(direction)) {
633 return direction;
634 }
635
636 if (isRTL()) {
637 return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT;
638 }
639
640 return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV;
641 }
642
643 _orderToDirection(order) {
644 if (![ORDER_NEXT, ORDER_PREV].includes(order)) {
645 return order;
646 }
647
648 if (isRTL()) {
649 return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT;
650 }
651
652 return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT;
653 } // Static
654
655
656 static carouselInterface(element, config) {
657 const data = Carousel.getOrCreateInstance(element, config);
658 let {
659 _config
660 } = data;
661
662 if (typeof config === 'object') {
663 _config = { ..._config,
664 ...config
665 };
666 }
667
668 const action = typeof config === 'string' ? config : _config.slide;
669
670 if (typeof config === 'number') {
671 data.to(config);
672 } else if (typeof action === 'string') {
673 if (typeof data[action] === 'undefined') {
674 throw new TypeError(`No method named "${action}"`);
675 }
676
677 data[action]();
678 } else if (_config.interval && _config.ride) {
679 data.pause();
680 data.cycle();
681 }
682 }
683
684 static jQueryInterface(config) {
685 return this.each(function () {
686 Carousel.carouselInterface(this, config);
687 });
688 }
689
690 static dataApiClickHandler(event) {
691 const target = getElementFromSelector(this);
692
693 if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
694 return;
695 }
696
697 const config = { ...Manipulator__default.default.getDataAttributes(target),
698 ...Manipulator__default.default.getDataAttributes(this)
699 };
700 const slideIndex = this.getAttribute('data-bs-slide-to');
701
702 if (slideIndex) {
703 config.interval = false;
704 }
705
706 Carousel.carouselInterface(target, config);
707
708 if (slideIndex) {
709 Carousel.getInstance(target).to(slideIndex);
710 }
711
712 event.preventDefault();
713 }
714
715 }
716 /**
717 * ------------------------------------------------------------------------
718 * Data Api implementation
719 * ------------------------------------------------------------------------
720 */
721
722
723 EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler);
724 EventHandler__default.default.on(window, EVENT_LOAD_DATA_API, () => {
725 const carousels = SelectorEngine__default.default.find(SELECTOR_DATA_RIDE);
726
727 for (let i = 0, len = carousels.length; i < len; i++) {
728 Carousel.carouselInterface(carousels[i], Carousel.getInstance(carousels[i]));
729 }
730 });
731 /**
732 * ------------------------------------------------------------------------
733 * jQuery
734 * ------------------------------------------------------------------------
735 * add .Carousel to jQuery only if jQuery is present
736 */
737
738 defineJQueryPlugin(Carousel);
739
740 return Carousel;
741
742}));
743//# sourceMappingURL=carousel.js.map
Note: See TracBrowser for help on using the repository browser.