Completed
Push — master ( 36261e...adbdec )
by
unknown
14s queued 12s
created

carousel.js ➔ _extends   B

Complexity

Conditions 6

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 9
dl 0
loc 16
rs 8.6666
c 0
b 0
f 0
1
/*!
2
  * Bootstrap carousel.js v4.6.1 (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('jquery'), require('./util.js')) :
8
  typeof define === 'function' && define.amd ? define(['jquery', './util'], factory) :
0 ignored issues
show
Bug introduced by
The variable define seems to be never declared. If this is a global, consider adding a /** global: define */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
9
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Carousel = factory(global.jQuery, global.Util));
0 ignored issues
show
Bug introduced by
The variable globalThis seems to be never declared. If this is a global, consider adding a /** global: globalThis */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Best Practice introduced by
If you intend to check if the variable self is declared in the current environment, consider using typeof self === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
10
})(this, (function ($, Util) { 'use strict';
11
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
14
  var $__default = /*#__PURE__*/_interopDefaultLegacy($);
15
  var Util__default = /*#__PURE__*/_interopDefaultLegacy(Util);
16
17
  function _defineProperties(target, props) {
18
    for (var i = 0; i < props.length; i++) {
19
      var descriptor = props[i];
20
      descriptor.enumerable = descriptor.enumerable || false;
21
      descriptor.configurable = true;
22
      if ("value" in descriptor) descriptor.writable = true;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
23
      Object.defineProperty(target, descriptor.key, descriptor);
24
    }
25
  }
26
27
  function _createClass(Constructor, protoProps, staticProps) {
28
    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
29
    if (staticProps) _defineProperties(Constructor, staticProps);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
30
    return Constructor;
31
  }
32
33
  function _extends() {
34
    _extends = Object.assign || function (target) {
35
      for (var i = 1; i < arguments.length; i++) {
36
        var source = arguments[i];
37
0 ignored issues
show
Comprehensibility introduced by
It seems like you are trying to overwrite a function name here. _extends is already defined in line 36 as a function. While this will work, it can be very confusing.
Loading history...
38
        for (var key in source) {
39
          if (Object.prototype.hasOwnProperty.call(source, key)) {
40
            target[key] = source[key];
41
          }
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
42
        }
43
      }
44
45
      return target;
46
    };
47
48
    return _extends.apply(this, arguments);
49
  }
50
51
  /**
52
   * Constants
53
   */
54
55
  var NAME = 'carousel';
56
  var VERSION = '4.6.1';
57
  var DATA_KEY = 'bs.carousel';
58
  var EVENT_KEY = "." + DATA_KEY;
59
  var DATA_API_KEY = '.data-api';
60
  var JQUERY_NO_CONFLICT = $__default["default"].fn[NAME];
61
  var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
62
63
  var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
64
65
  var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
66
67
  var SWIPE_THRESHOLD = 40;
68
  var CLASS_NAME_CAROUSEL = 'carousel';
69
  var CLASS_NAME_ACTIVE = 'active';
70
  var CLASS_NAME_SLIDE = 'slide';
71
  var CLASS_NAME_RIGHT = 'carousel-item-right';
72
  var CLASS_NAME_LEFT = 'carousel-item-left';
73
  var CLASS_NAME_NEXT = 'carousel-item-next';
74
  var CLASS_NAME_PREV = 'carousel-item-prev';
75
  var CLASS_NAME_POINTER_EVENT = 'pointer-event';
76
  var DIRECTION_NEXT = 'next';
77
  var DIRECTION_PREV = 'prev';
78
  var DIRECTION_LEFT = 'left';
79
  var DIRECTION_RIGHT = 'right';
80
  var EVENT_SLIDE = "slide" + EVENT_KEY;
81
  var EVENT_SLID = "slid" + EVENT_KEY;
82
  var EVENT_KEYDOWN = "keydown" + EVENT_KEY;
83
  var EVENT_MOUSEENTER = "mouseenter" + EVENT_KEY;
84
  var EVENT_MOUSELEAVE = "mouseleave" + EVENT_KEY;
85
  var EVENT_TOUCHSTART = "touchstart" + EVENT_KEY;
86
  var EVENT_TOUCHMOVE = "touchmove" + EVENT_KEY;
87
  var EVENT_TOUCHEND = "touchend" + EVENT_KEY;
88
  var EVENT_POINTERDOWN = "pointerdown" + EVENT_KEY;
89
  var EVENT_POINTERUP = "pointerup" + EVENT_KEY;
90
  var EVENT_DRAG_START = "dragstart" + EVENT_KEY;
91
  var EVENT_LOAD_DATA_API = "load" + EVENT_KEY + DATA_API_KEY;
92
  var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
93
  var SELECTOR_ACTIVE = '.active';
94
  var SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
95
  var SELECTOR_ITEM = '.carousel-item';
96
  var SELECTOR_ITEM_IMG = '.carousel-item img';
97
  var SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
98
  var SELECTOR_INDICATORS = '.carousel-indicators';
99
  var SELECTOR_DATA_SLIDE = '[data-slide], [data-slide-to]';
100
  var SELECTOR_DATA_RIDE = '[data-ride="carousel"]';
101
  var Default = {
102
    interval: 5000,
103
    keyboard: true,
104
    slide: false,
105
    pause: 'hover',
106
    wrap: true,
107
    touch: true
108
  };
109
  var DefaultType = {
110
    interval: '(number|boolean)',
111
    keyboard: 'boolean',
112
    slide: '(boolean|string)',
113
    pause: '(string|boolean)',
114
    wrap: 'boolean',
115
    touch: 'boolean'
116
  };
117
  var PointerType = {
118
    TOUCH: 'touch',
119
    PEN: 'pen'
120
  };
121
  /**
122
   * Class definition
123
   */
124
125
  var Carousel = /*#__PURE__*/function () {
126
    function Carousel(element, config) {
127
      this._items = null;
128
      this._interval = null;
129
      this._activeElement = null;
130
      this._isPaused = false;
131
      this._isSliding = false;
132
      this.touchTimeout = null;
133
      this.touchStartX = 0;
134
      this.touchDeltaX = 0;
135
      this._config = this._getConfig(config);
136
      this._element = element;
137
      this._indicatorsElement = this._element.querySelector(SELECTOR_INDICATORS);
138
      this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
139
      this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
140
0 ignored issues
show
Bug introduced by
The variable navigator seems to be never declared. If this is a global, consider adding a /** global: navigator */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
141
      this._addEventListeners();
142
    } // Getters
143
144
145
    var _proto = Carousel.prototype;
146
147
    // Public
148
    _proto.next = function next() {
149
      if (!this._isSliding) {
150
        this._slide(DIRECTION_NEXT);
151
      }
152
    };
153
154
    _proto.nextWhenVisible = function nextWhenVisible() {
155
      var $element = $__default["default"](this._element); // Don't call next when the page isn't visible
156
      // or the carousel or its parent isn't visible
157
158
      if (!document.hidden && $element.is(':visible') && $element.css('visibility') !== 'hidden') {
159
        this.next();
160
      }
161
    };
162
163
    _proto.prev = function prev() {
164
      if (!this._isSliding) {
165
        this._slide(DIRECTION_PREV);
166
      }
167
    };
168
169
    _proto.pause = function pause(event) {
170
      if (!event) {
171
        this._isPaused = true;
172
      }
173
174
      if (this._element.querySelector(SELECTOR_NEXT_PREV)) {
175
        Util__default["default"].triggerTransitionEnd(this._element);
176
        this.cycle(true);
177
      }
178
179
      clearInterval(this._interval);
180
      this._interval = null;
181
    };
182
183
    _proto.cycle = function cycle(event) {
184
      if (!event) {
185
        this._isPaused = false;
186
      }
187
188
      if (this._interval) {
189
        clearInterval(this._interval);
190
        this._interval = null;
191
      }
192
193
      if (this._config.interval && !this._isPaused) {
194
        this._updateInterval();
195
196
        this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
197
      }
198
    };
199
200
    _proto.to = function to(index) {
201
      var _this = this;
202
203
      this._activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM);
204
205
      var activeIndex = this._getItemIndex(this._activeElement);
206
207
      if (index > this._items.length - 1 || index < 0) {
208
        return;
209
      }
210
211
      if (this._isSliding) {
212
        $__default["default"](this._element).one(EVENT_SLID, function () {
213
          return _this.to(index);
214
        });
215
        return;
216
      }
217
218
      if (activeIndex === index) {
219
        this.pause();
220
        this.cycle();
221
        return;
222
      }
223
224
      var direction = index > activeIndex ? DIRECTION_NEXT : DIRECTION_PREV;
225
226
      this._slide(direction, this._items[index]);
227
    };
228
229
    _proto.dispose = function dispose() {
230
      $__default["default"](this._element).off(EVENT_KEY);
231
      $__default["default"].removeData(this._element, DATA_KEY);
232
      this._items = null;
233
      this._config = null;
234
      this._element = null;
235
      this._interval = null;
236
      this._isPaused = null;
237
      this._isSliding = null;
238
      this._activeElement = null;
239
      this._indicatorsElement = null;
240
    } // Private
241
    ;
242
243
    _proto._getConfig = function _getConfig(config) {
244
      config = _extends({}, Default, config);
245
      Util__default["default"].typeCheckConfig(NAME, config, DefaultType);
246
      return config;
247
    };
248
249
    _proto._handleSwipe = function _handleSwipe() {
250
      var absDeltax = Math.abs(this.touchDeltaX);
251
252
      if (absDeltax <= SWIPE_THRESHOLD) {
253
        return;
254
      }
255
256
      var direction = absDeltax / this.touchDeltaX;
257
      this.touchDeltaX = 0; // swipe left
258
259
      if (direction > 0) {
260
        this.prev();
261
      } // swipe right
262
263
264
      if (direction < 0) {
265
        this.next();
266
      }
267
    };
268
269
    _proto._addEventListeners = function _addEventListeners() {
270
      var _this2 = this;
271
272
      if (this._config.keyboard) {
273
        $__default["default"](this._element).on(EVENT_KEYDOWN, function (event) {
274
          return _this2._keydown(event);
275
        });
276
      }
277
278
      if (this._config.pause === 'hover') {
279
        $__default["default"](this._element).on(EVENT_MOUSEENTER, function (event) {
280
          return _this2.pause(event);
281
        }).on(EVENT_MOUSELEAVE, function (event) {
282
          return _this2.cycle(event);
283
        });
284
      }
285
286
      if (this._config.touch) {
287
        this._addTouchEventListeners();
288
      }
289
    };
290
291
    _proto._addTouchEventListeners = function _addTouchEventListeners() {
292
      var _this3 = this;
293
294
      if (!this._touchSupported) {
295
        return;
296
      }
297
298
      var start = function start(event) {
299
        if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
300
          _this3.touchStartX = event.originalEvent.clientX;
301
        } else if (!_this3._pointerEvent) {
302
          _this3.touchStartX = event.originalEvent.touches[0].clientX;
303
        }
304
      };
305
306
      var move = function move(event) {
307
        // ensure swiping with one touch and not pinching
308
        _this3.touchDeltaX = event.originalEvent.touches && event.originalEvent.touches.length > 1 ? 0 : event.originalEvent.touches[0].clientX - _this3.touchStartX;
309
      };
310
311
      var end = function end(event) {
312
        if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
313
          _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
314
        }
315
316
        _this3._handleSwipe();
317
318
        if (_this3._config.pause === 'hover') {
319
          // If it's a touch-enabled device, mouseenter/leave are fired as
320
          // part of the mouse compatibility events on first tap - the carousel
321
          // would stop cycling until user tapped out of it;
322
          // here, we listen for touchend, explicitly pause the carousel
323
          // (as if it's the second time we tap on it, mouseenter compat event
324
          // is NOT fired) and after a timeout (to allow for mouse compatibility
325
          // events to fire) we explicitly restart cycling
326
          _this3.pause();
327
328
          if (_this3.touchTimeout) {
329
            clearTimeout(_this3.touchTimeout);
330
          }
331
332
          _this3.touchTimeout = setTimeout(function (event) {
333
            return _this3.cycle(event);
334
          }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
335
        }
336
      };
337
338
      $__default["default"](this._element.querySelectorAll(SELECTOR_ITEM_IMG)).on(EVENT_DRAG_START, function (e) {
339
        return e.preventDefault();
340
      });
341
342
      if (this._pointerEvent) {
343
        $__default["default"](this._element).on(EVENT_POINTERDOWN, function (event) {
344
          return start(event);
345
        });
346
        $__default["default"](this._element).on(EVENT_POINTERUP, function (event) {
347
          return end(event);
348
        });
349
350
        this._element.classList.add(CLASS_NAME_POINTER_EVENT);
351
      } else {
352
        $__default["default"](this._element).on(EVENT_TOUCHSTART, function (event) {
353
          return start(event);
354
        });
355
        $__default["default"](this._element).on(EVENT_TOUCHMOVE, function (event) {
356
          return move(event);
357
        });
358
        $__default["default"](this._element).on(EVENT_TOUCHEND, function (event) {
359
          return end(event);
360
        });
361
      }
362
    };
363
364
    _proto._keydown = function _keydown(event) {
365
      if (/input|textarea/i.test(event.target.tagName)) {
366
        return;
367
      }
368
369
      switch (event.which) {
370
        case ARROW_LEFT_KEYCODE:
371
          event.preventDefault();
372
          this.prev();
373
          break;
374
375
        case ARROW_RIGHT_KEYCODE:
376
          event.preventDefault();
377
          this.next();
378
          break;
379
      }
380
    };
381
382
    _proto._getItemIndex = function _getItemIndex(element) {
383
      this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(SELECTOR_ITEM)) : [];
384
      return this._items.indexOf(element);
385
    };
386
387
    _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
388
      var isNextDirection = direction === DIRECTION_NEXT;
389
      var isPrevDirection = direction === DIRECTION_PREV;
390
391
      var activeIndex = this._getItemIndex(activeElement);
392
393
      var lastItemIndex = this._items.length - 1;
394
      var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
395
396
      if (isGoingToWrap && !this._config.wrap) {
397
        return activeElement;
398
      }
399
400
      var delta = direction === DIRECTION_PREV ? -1 : 1;
401
      var itemIndex = (activeIndex + delta) % this._items.length;
402
      return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
403
    };
404
405
    _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
406
      var targetIndex = this._getItemIndex(relatedTarget);
407
408
      var fromIndex = this._getItemIndex(this._element.querySelector(SELECTOR_ACTIVE_ITEM));
409
410
      var slideEvent = $__default["default"].Event(EVENT_SLIDE, {
411
        relatedTarget: relatedTarget,
412
        direction: eventDirectionName,
413
        from: fromIndex,
414
        to: targetIndex
415
      });
416
      $__default["default"](this._element).trigger(slideEvent);
417
      return slideEvent;
418
    };
419
420
    _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
421
      if (this._indicatorsElement) {
422
        var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(SELECTOR_ACTIVE));
423
        $__default["default"](indicators).removeClass(CLASS_NAME_ACTIVE);
424
425
        var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
426
427
        if (nextIndicator) {
428
          $__default["default"](nextIndicator).addClass(CLASS_NAME_ACTIVE);
429
        }
430
      }
431
    };
432
433
    _proto._updateInterval = function _updateInterval() {
434
      var element = this._activeElement || this._element.querySelector(SELECTOR_ACTIVE_ITEM);
435
436
      if (!element) {
437
        return;
438
      }
439
440
      var elementInterval = parseInt(element.getAttribute('data-interval'), 10);
441
442
      if (elementInterval) {
443
        this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
444
        this._config.interval = elementInterval;
445
      } else {
446
        this._config.interval = this._config.defaultInterval || this._config.interval;
447
      }
448
    };
449
450
    _proto._slide = function _slide(direction, element) {
451
      var _this4 = this;
452
453
      var activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM);
454
455
      var activeElementIndex = this._getItemIndex(activeElement);
456
457
      var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
458
459
      var nextElementIndex = this._getItemIndex(nextElement);
460
461
      var isCycling = Boolean(this._interval);
462
      var directionalClassName;
463
      var orderClassName;
464
      var eventDirectionName;
465
466
      if (direction === DIRECTION_NEXT) {
467
        directionalClassName = CLASS_NAME_LEFT;
468
        orderClassName = CLASS_NAME_NEXT;
469
        eventDirectionName = DIRECTION_LEFT;
470
      } else {
471
        directionalClassName = CLASS_NAME_RIGHT;
472
        orderClassName = CLASS_NAME_PREV;
473
        eventDirectionName = DIRECTION_RIGHT;
474
      }
475
476
      if (nextElement && $__default["default"](nextElement).hasClass(CLASS_NAME_ACTIVE)) {
477
        this._isSliding = false;
478
        return;
479
      }
480
481
      var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
482
483
      if (slideEvent.isDefaultPrevented()) {
484
        return;
485
      }
486
487
      if (!activeElement || !nextElement) {
488
        // Some weirdness is happening, so we bail
489
        return;
490
      }
491
492
      this._isSliding = true;
493
494
      if (isCycling) {
495
        this.pause();
496
      }
497
498
      this._setActiveIndicatorElement(nextElement);
499
500
      this._activeElement = nextElement;
501
      var slidEvent = $__default["default"].Event(EVENT_SLID, {
502
        relatedTarget: nextElement,
503
        direction: eventDirectionName,
504
        from: activeElementIndex,
505
        to: nextElementIndex
506
      });
507
508
      if ($__default["default"](this._element).hasClass(CLASS_NAME_SLIDE)) {
509
        $__default["default"](nextElement).addClass(orderClassName);
510
        Util__default["default"].reflow(nextElement);
511
        $__default["default"](activeElement).addClass(directionalClassName);
512
        $__default["default"](nextElement).addClass(directionalClassName);
513
        var transitionDuration = Util__default["default"].getTransitionDurationFromElement(activeElement);
514
        $__default["default"](activeElement).one(Util__default["default"].TRANSITION_END, function () {
515
          $__default["default"](nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(CLASS_NAME_ACTIVE);
516
          $__default["default"](activeElement).removeClass(CLASS_NAME_ACTIVE + " " + orderClassName + " " + directionalClassName);
517
          _this4._isSliding = false;
518
          setTimeout(function () {
519
            return $__default["default"](_this4._element).trigger(slidEvent);
520
          }, 0);
521
        }).emulateTransitionEnd(transitionDuration);
522
      } else {
523
        $__default["default"](activeElement).removeClass(CLASS_NAME_ACTIVE);
524
        $__default["default"](nextElement).addClass(CLASS_NAME_ACTIVE);
525
        this._isSliding = false;
526
        $__default["default"](this._element).trigger(slidEvent);
527
      }
528
529
      if (isCycling) {
530
        this.cycle();
531
      }
532
    } // Static
533
    ;
534
535
    Carousel._jQueryInterface = function _jQueryInterface(config) {
536
      return this.each(function () {
537
        var data = $__default["default"](this).data(DATA_KEY);
538
539
        var _config = _extends({}, Default, $__default["default"](this).data());
540
541
        if (typeof config === 'object') {
542
          _config = _extends({}, _config, config);
543
        }
544
545
        var action = typeof config === 'string' ? config : _config.slide;
546
547
        if (!data) {
548
          data = new Carousel(this, _config);
549
          $__default["default"](this).data(DATA_KEY, data);
550
        }
551
552
        if (typeof config === 'number') {
553
          data.to(config);
554
        } else if (typeof action === 'string') {
555
          if (typeof data[action] === 'undefined') {
556
            throw new TypeError("No method named \"" + action + "\"");
557
          }
558
559
          data[action]();
560
        } else if (_config.interval && _config.ride) {
561
          data.pause();
562
          data.cycle();
563
        }
564
      });
565
    };
566
567
    Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
568
      var selector = Util__default["default"].getSelectorFromElement(this);
569
570
      if (!selector) {
571
        return;
572
      }
573
574
      var target = $__default["default"](selector)[0];
575
576
      if (!target || !$__default["default"](target).hasClass(CLASS_NAME_CAROUSEL)) {
577
        return;
578
      }
579
580
      var config = _extends({}, $__default["default"](target).data(), $__default["default"](this).data());
581
582
      var slideIndex = this.getAttribute('data-slide-to');
583
584
      if (slideIndex) {
585
        config.interval = false;
586
      }
587
588
      Carousel._jQueryInterface.call($__default["default"](target), config);
589
590
      if (slideIndex) {
591
        $__default["default"](target).data(DATA_KEY).to(slideIndex);
592
      }
593
594
      event.preventDefault();
595
    };
596
597
    _createClass(Carousel, null, [{
598
      key: "VERSION",
599
      get: function get() {
600
        return VERSION;
601
      }
602
    }, {
603
      key: "Default",
604
      get: function get() {
605
        return Default;
606
      }
607
    }]);
608
609
    return Carousel;
610
  }();
611
  /**
612
   * Data API implementation
613
   */
614
615
616
  $__default["default"](document).on(EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel._dataApiClickHandler);
617
  $__default["default"](window).on(EVENT_LOAD_DATA_API, function () {
618
    var carousels = [].slice.call(document.querySelectorAll(SELECTOR_DATA_RIDE));
619
620
    for (var i = 0, len = carousels.length; i < len; i++) {
621
      var $carousel = $__default["default"](carousels[i]);
622
623
      Carousel._jQueryInterface.call($carousel, $carousel.data());
624
    }
625
  });
626
  /**
627
   * jQuery
628
   */
629
630
  $__default["default"].fn[NAME] = Carousel._jQueryInterface;
631
  $__default["default"].fn[NAME].Constructor = Carousel;
632
633
  $__default["default"].fn[NAME].noConflict = function () {
634
    $__default["default"].fn[NAME] = JQUERY_NO_CONFLICT;
635
    return Carousel._jQueryInterface;
636
  };
637
638
  return Carousel;
639
640
}));
641
//# sourceMappingURL=carousel.js.map
642