bootstrap.js 109 KB
Newer Older
1
/*!
Mark Otto's avatar
Mark Otto committed
2
 * Bootstrap v4.0.0-beta (https://getbootstrap.com)
Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
3
 * Copyright 2011-2017 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
Mark Otto's avatar
Mark Otto committed
4
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
Jacob Thornton's avatar
Jacob Thornton committed
5
6
7
 */

if (typeof jQuery === 'undefined') {
Mark Otto's avatar
grunt    
Mark Otto committed
8
  throw new Error('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.')
Jacob Thornton's avatar
Jacob Thornton committed
9
10
}

Mark Otto's avatar
build    
Mark Otto committed
11
(function ($) {
Jacob Thornton's avatar
Jacob Thornton committed
12
  var version = $.fn.jquery.split(' ')[0].split('.')
XhmikosR's avatar
XhmikosR committed
13
14
  if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] >= 4)) {
    throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0')
Jacob Thornton's avatar
Jacob Thornton committed
15
  }
Mark Otto's avatar
build    
Mark Otto committed
16
})(jQuery);
Mark Otto's avatar
grunt    
Mark Otto committed
17

Mark Otto's avatar
build    
Mark Otto committed
18
(function () {
Mark Otto's avatar
grunt    
Mark Otto committed
19
20
21
22
23
24
25
26
27
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
Jacob Thornton's avatar
Jacob Thornton committed
28
29
30

/**
 * --------------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
31
 * Bootstrap (v4.0.0-beta): util.js
Jacob Thornton's avatar
Jacob Thornton committed
32
33
34
35
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */

Mark Otto's avatar
grunt    
Mark Otto committed
36
var Util = function ($) {
Jacob Thornton's avatar
Jacob Thornton committed
37
38
39
40
41
42
43
44
45

  /**
   * ------------------------------------------------------------------------
   * Private TransitionEnd Helpers
   * ------------------------------------------------------------------------
   */

  var transition = false;

Chris Rebert's avatar
grunt    
Chris Rebert committed
46
47
  var MAX_UID = 1000000;

Jacob Thornton's avatar
Jacob Thornton committed
48
49
50
51
52
53
  var TransitionEndEvent = {
    WebkitTransition: 'webkitTransitionEnd',
    MozTransition: 'transitionend',
    OTransition: 'oTransitionEnd otransitionend',
    transition: 'transitionend'

Mark Otto's avatar
dist    
Mark Otto committed
54
55
    // shoutout AngusCroll (https://goo.gl/pxwQGp)
  };function toType(obj) {
Mark Otto's avatar
grunt    
Mark Otto committed
56
    return {}.toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
Jacob Thornton's avatar
Jacob Thornton committed
57
58
59
60
61
62
63
64
65
66
67
68
  }

  function isElement(obj) {
    return (obj[0] || obj).nodeType;
  }

  function getSpecialTransitionEndEvent() {
    return {
      bindType: transition.end,
      delegateType: transition.end,
      handle: function handle(event) {
        if ($(event.target).is(this)) {
Mark Otto's avatar
Mark Otto committed
69
          return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
Jacob Thornton's avatar
Jacob Thornton committed
70
        }
Chris Rebert's avatar
grunt    
Chris Rebert committed
71
        return undefined;
Jacob Thornton's avatar
Jacob Thornton committed
72
73
74
75
76
77
78
79
80
81
82
      }
    };
  }

  function transitionEndTest() {
    if (window.QUnit) {
      return false;
    }

    var el = document.createElement('bootstrap');

Mark Otto's avatar
grunt    
Mark Otto committed
83
84
    for (var name in TransitionEndEvent) {
      if (el.style[name] !== undefined) {
Mark Otto's avatar
grunt    
Mark Otto committed
85
86
87
        return {
          end: TransitionEndEvent[name]
        };
Jacob Thornton's avatar
Jacob Thornton committed
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
      }
    }

    return false;
  }

  function transitionEndEmulator(duration) {
    var _this = this;

    var called = false;

    $(this).one(Util.TRANSITION_END, function () {
      called = true;
    });

    setTimeout(function () {
      if (!called) {
        Util.triggerTransitionEnd(_this);
      }
    }, duration);

    return this;
  }

  function setTransitionEndSupport() {
    transition = transitionEndTest();

    $.fn.emulateTransitionEnd = transitionEndEmulator;

    if (Util.supportsTransitionEnd()) {
      $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
    }
  }

  /**
   * --------------------------------------------------------------------------
   * Public Util Api
   * --------------------------------------------------------------------------
   */

  var Util = {

    TRANSITION_END: 'bsTransitionEnd',

    getUID: function getUID(prefix) {
Jacob Thornton's avatar
Jacob Thornton committed
133
      do {
Mark Otto's avatar
grunt    
Mark Otto committed
134
        // eslint-disable-next-line no-bitwise
Mark Otto's avatar
grunt    
Mark Otto committed
135
        prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
Jacob Thornton's avatar
Jacob Thornton committed
136
      } while (document.getElementById(prefix));
Jacob Thornton's avatar
Jacob Thornton committed
137
138
139
140
      return prefix;
    },
    getSelectorFromElement: function getSelectorFromElement(element) {
      var selector = element.getAttribute('data-target');
Mark Otto's avatar
grunt    
Mark Otto committed
141
      if (!selector || selector === '#') {
Jacob Thornton's avatar
Jacob Thornton committed
142
143
144
        selector = element.getAttribute('href') || '';
      }

Mark Otto's avatar
grunt    
Mark Otto committed
145
146
147
148
149
150
      try {
        var $selector = $(selector);
        return $selector.length > 0 ? selector : null;
      } catch (error) {
        return null;
      }
Jacob Thornton's avatar
Jacob Thornton committed
151
152
    },
    reflow: function reflow(element) {
Mark Otto's avatar
grunt    
Mark Otto committed
153
      return element.offsetHeight;
Jacob Thornton's avatar
Jacob Thornton committed
154
155
156
157
158
    },
    triggerTransitionEnd: function triggerTransitionEnd(element) {
      $(element).trigger(transition.end);
    },
    supportsTransitionEnd: function supportsTransitionEnd() {
Jacob Thornton's avatar
Jacob Thornton committed
159
      return Boolean(transition);
Jacob Thornton's avatar
Jacob Thornton committed
160
161
162
    },
    typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
      for (var property in configTypes) {
Jacob Thornton's avatar
Jacob Thornton committed
163
164
165
        if (configTypes.hasOwnProperty(property)) {
          var expectedTypes = configTypes[property];
          var value = config[property];
Mark Otto's avatar
grunt    
Mark Otto committed
166
          var valueType = value && isElement(value) ? 'element' : toType(value);
Jacob Thornton's avatar
Jacob Thornton committed
167

Jacob Thornton's avatar
Jacob Thornton committed
168
169
170
          if (!new RegExp(expectedTypes).test(valueType)) {
            throw new Error(componentName.toUpperCase() + ': ' + ('Option "' + property + '" provided type "' + valueType + '" ') + ('but expected type "' + expectedTypes + '".'));
          }
Jacob Thornton's avatar
Jacob Thornton committed
171
172
173
174
175
176
177
178
        }
      }
    }
  };

  setTransitionEndSupport();

  return Util;
Mark Otto's avatar
Mark Otto committed
179
}(jQuery);
Jacob Thornton's avatar
Jacob Thornton committed
180
181
182

/**
 * --------------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
183
 * Bootstrap (v4.0.0-beta): alert.js
Jacob Thornton's avatar
Jacob Thornton committed
184
185
186
187
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */

Mark Otto's avatar
Mark Otto committed
188
var Alert = function ($) {
Jacob Thornton's avatar
Jacob Thornton committed
189
190
191
192
193
194
195
196

  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME = 'alert';
Mark Otto's avatar
Mark Otto committed
197
  var VERSION = '4.0.0-beta';
Jacob Thornton's avatar
Jacob Thornton committed
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
  var DATA_KEY = 'bs.alert';
  var EVENT_KEY = '.' + DATA_KEY;
  var DATA_API_KEY = '.data-api';
  var JQUERY_NO_CONFLICT = $.fn[NAME];
  var TRANSITION_DURATION = 150;

  var Selector = {
    DISMISS: '[data-dismiss="alert"]'
  };

  var Event = {
    CLOSE: 'close' + EVENT_KEY,
    CLOSED: 'closed' + EVENT_KEY,
    CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY
  };

  var ClassName = {
    ALERT: 'alert',
    FADE: 'fade',
Mark Otto's avatar
grunt    
Mark Otto committed
217
    SHOW: 'show'
Jacob Thornton's avatar
Jacob Thornton committed
218

Mark Otto's avatar
dist    
Mark Otto committed
219
220
221
222
223
    /**
     * ------------------------------------------------------------------------
     * Class Definition
     * ------------------------------------------------------------------------
     */
Jacob Thornton's avatar
Jacob Thornton committed
224

Mark Otto's avatar
dist    
Mark Otto committed
225
  };
Mark Otto's avatar
grunt    
Mark Otto committed
226
  var Alert = function () {
Jacob Thornton's avatar
Jacob Thornton committed
227
228
229
230
231
232
233
234
    function Alert(element) {
      _classCallCheck(this, Alert);

      this._element = element;
    }

    // getters

Mark Otto's avatar
grunt    
Mark Otto committed
235
    // public
Jacob Thornton's avatar
Jacob Thornton committed
236

Mark Otto's avatar
grunt    
Mark Otto committed
237
238
    Alert.prototype.close = function close(element) {
      element = element || this._element;
Jacob Thornton's avatar
Jacob Thornton committed
239

Mark Otto's avatar
grunt    
Mark Otto committed
240
241
242
243
244
245
      var rootElement = this._getRootElement(element);
      var customEvent = this._triggerCloseEvent(rootElement);

      if (customEvent.isDefaultPrevented()) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
246

Mark Otto's avatar
grunt    
Mark Otto committed
247
248
      this._removeElement(rootElement);
    };
Jacob Thornton's avatar
Jacob Thornton committed
249

Mark Otto's avatar
grunt    
Mark Otto committed
250
251
252
253
254
255
    Alert.prototype.dispose = function dispose() {
      $.removeData(this._element, DATA_KEY);
      this._element = null;
    };

    // private
Jacob Thornton's avatar
Jacob Thornton committed
256

Mark Otto's avatar
grunt    
Mark Otto committed
257
258
259
260
261
262
    Alert.prototype._getRootElement = function _getRootElement(element) {
      var selector = Util.getSelectorFromElement(element);
      var parent = false;

      if (selector) {
        parent = $(selector)[0];
Jacob Thornton's avatar
Jacob Thornton committed
263
      }
Mark Otto's avatar
grunt    
Mark Otto committed
264
265
266

      if (!parent) {
        parent = $(element).closest('.' + ClassName.ALERT)[0];
Jacob Thornton's avatar
Jacob Thornton committed
267
268
      }

Mark Otto's avatar
grunt    
Mark Otto committed
269
270
      return parent;
    };
Jacob Thornton's avatar
Jacob Thornton committed
271

Mark Otto's avatar
grunt    
Mark Otto committed
272
273
    Alert.prototype._triggerCloseEvent = function _triggerCloseEvent(element) {
      var closeEvent = $.Event(Event.CLOSE);
Jacob Thornton's avatar
Jacob Thornton committed
274

Mark Otto's avatar
grunt    
Mark Otto committed
275
276
277
      $(element).trigger(closeEvent);
      return closeEvent;
    };
Jacob Thornton's avatar
Jacob Thornton committed
278

Mark Otto's avatar
grunt    
Mark Otto committed
279
    Alert.prototype._removeElement = function _removeElement(element) {
Mark Otto's avatar
grunt    
Mark Otto committed
280
281
      var _this2 = this;

Mark Otto's avatar
grunt    
Mark Otto committed
282
      $(element).removeClass(ClassName.SHOW);
Jacob Thornton's avatar
Jacob Thornton committed
283

Mark Otto's avatar
grunt    
Mark Otto committed
284
285
286
      if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) {
        this._destroyElement(element);
        return;
Jacob Thornton's avatar
Jacob Thornton committed
287
      }
Jacob Thornton's avatar
Jacob Thornton committed
288

Mark Otto's avatar
grunt    
Mark Otto committed
289
290
291
      $(element).one(Util.TRANSITION_END, function (event) {
        return _this2._destroyElement(element, event);
      }).emulateTransitionEnd(TRANSITION_DURATION);
Mark Otto's avatar
grunt    
Mark Otto committed
292
    };
Jacob Thornton's avatar
Jacob Thornton committed
293

Mark Otto's avatar
grunt    
Mark Otto committed
294
295
296
    Alert.prototype._destroyElement = function _destroyElement(element) {
      $(element).detach().trigger(Event.CLOSED).remove();
    };
Jacob Thornton's avatar
Jacob Thornton committed
297

Mark Otto's avatar
grunt    
Mark Otto committed
298
    // static
Jacob Thornton's avatar
Jacob Thornton committed
299

Mark Otto's avatar
grunt    
Mark Otto committed
300
301
302
303
    Alert._jQueryInterface = function _jQueryInterface(config) {
      return this.each(function () {
        var $element = $(this);
        var data = $element.data(DATA_KEY);
Jacob Thornton's avatar
Jacob Thornton committed
304

Mark Otto's avatar
grunt    
Mark Otto committed
305
306
307
308
        if (!data) {
          data = new Alert(this);
          $element.data(DATA_KEY, data);
        }
Jacob Thornton's avatar
Jacob Thornton committed
309

Mark Otto's avatar
grunt    
Mark Otto committed
310
311
312
313
314
        if (config === 'close') {
          data[config](this);
        }
      });
    };
Jacob Thornton's avatar
Jacob Thornton committed
315

Mark Otto's avatar
grunt    
Mark Otto committed
316
317
318
319
320
    Alert._handleDismiss = function _handleDismiss(alertInstance) {
      return function (event) {
        if (event) {
          event.preventDefault();
        }
Jacob Thornton's avatar
Jacob Thornton committed
321

Mark Otto's avatar
grunt    
Mark Otto committed
322
323
324
325
326
        alertInstance.close(this);
      };
    };

    _createClass(Alert, null, [{
Jacob Thornton's avatar
Jacob Thornton committed
327
328
329
330
331
332
333
      key: 'VERSION',
      get: function get() {
        return VERSION;
      }
    }]);

    return Alert;
Mark Otto's avatar
grunt    
Mark Otto committed
334
335
336
337
338
339
340
  }();

  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
Jacob Thornton's avatar
Jacob Thornton committed
341

Mark Otto's avatar
Mark Otto committed
342
  $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
Jacob Thornton's avatar
Jacob Thornton committed
343
344
345
346
347
348
349

  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
   */

Mark Otto's avatar
Mark Otto committed
350
  $.fn[NAME] = Alert._jQueryInterface;
Jacob Thornton's avatar
Jacob Thornton committed
351
352
353
354
355
356
357
  $.fn[NAME].Constructor = Alert;
  $.fn[NAME].noConflict = function () {
    $.fn[NAME] = JQUERY_NO_CONFLICT;
    return Alert._jQueryInterface;
  };

  return Alert;
Mark Otto's avatar
Mark Otto committed
358
}(jQuery);
Jacob Thornton's avatar
Jacob Thornton committed
359
360
361

/**
 * --------------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
362
 * Bootstrap (v4.0.0-beta): button.js
Jacob Thornton's avatar
Jacob Thornton committed
363
364
365
366
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */

Mark Otto's avatar
Mark Otto committed
367
var Button = function ($) {
Jacob Thornton's avatar
Jacob Thornton committed
368
369
370
371
372
373
374
375

  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME = 'button';
Mark Otto's avatar
Mark Otto committed
376
  var VERSION = '4.0.0-beta';
Jacob Thornton's avatar
Jacob Thornton committed
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
  var DATA_KEY = 'bs.button';
  var EVENT_KEY = '.' + DATA_KEY;
  var DATA_API_KEY = '.data-api';
  var JQUERY_NO_CONFLICT = $.fn[NAME];

  var ClassName = {
    ACTIVE: 'active',
    BUTTON: 'btn',
    FOCUS: 'focus'
  };

  var Selector = {
    DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
    DATA_TOGGLE: '[data-toggle="buttons"]',
    INPUT: 'input',
    ACTIVE: '.active',
    BUTTON: '.btn'
  };

  var Event = {
    CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY,
    FOCUS_BLUR_DATA_API: 'focus' + EVENT_KEY + DATA_API_KEY + ' ' + ('blur' + EVENT_KEY + DATA_API_KEY)

Mark Otto's avatar
dist    
Mark Otto committed
400
401
402
403
404
    /**
     * ------------------------------------------------------------------------
     * Class Definition
     * ------------------------------------------------------------------------
     */
Jacob Thornton's avatar
Jacob Thornton committed
405

Mark Otto's avatar
dist    
Mark Otto committed
406
  };
Mark Otto's avatar
grunt    
Mark Otto committed
407
  var Button = function () {
Jacob Thornton's avatar
Jacob Thornton committed
408
409
410
411
412
413
414
415
    function Button(element) {
      _classCallCheck(this, Button);

      this._element = element;
    }

    // getters

Mark Otto's avatar
grunt    
Mark Otto committed
416
    // public
Jacob Thornton's avatar
Jacob Thornton committed
417

Mark Otto's avatar
grunt    
Mark Otto committed
418
419
    Button.prototype.toggle = function toggle() {
      var triggerChangeEvent = true;
Mark Otto's avatar
grunt    
Mark Otto committed
420
      var addAriaPressed = true;
Mark Otto's avatar
grunt    
Mark Otto committed
421
      var rootElement = $(this._element).closest(Selector.DATA_TOGGLE)[0];
Jacob Thornton's avatar
Jacob Thornton committed
422

Mark Otto's avatar
grunt    
Mark Otto committed
423
424
      if (rootElement) {
        var input = $(this._element).find(Selector.INPUT)[0];
Jacob Thornton's avatar
Jacob Thornton committed
425

Mark Otto's avatar
grunt    
Mark Otto committed
426
427
428
429
430
431
        if (input) {
          if (input.type === 'radio') {
            if (input.checked && $(this._element).hasClass(ClassName.ACTIVE)) {
              triggerChangeEvent = false;
            } else {
              var activeElement = $(rootElement).find(Selector.ACTIVE)[0];
Jacob Thornton's avatar
Jacob Thornton committed
432

Mark Otto's avatar
grunt    
Mark Otto committed
433
434
              if (activeElement) {
                $(activeElement).removeClass(ClassName.ACTIVE);
Jacob Thornton's avatar
Jacob Thornton committed
435
436
              }
            }
Mark Otto's avatar
grunt    
Mark Otto committed
437
          }
Jacob Thornton's avatar
Jacob Thornton committed
438

Mark Otto's avatar
grunt    
Mark Otto committed
439
          if (triggerChangeEvent) {
Johann-S's avatar
build    
Johann-S committed
440
441
442
            if (input.hasAttribute('disabled') || rootElement.hasAttribute('disabled') || input.classList.contains('disabled') || rootElement.classList.contains('disabled')) {
              return;
            }
Mark Otto's avatar
grunt    
Mark Otto committed
443
            input.checked = !$(this._element).hasClass(ClassName.ACTIVE);
Mark Otto's avatar
grunt    
Mark Otto committed
444
            $(input).trigger('change');
Jacob Thornton's avatar
Jacob Thornton committed
445
446
          }

Mark Otto's avatar
grunt    
Mark Otto committed
447
          input.focus();
Mark Otto's avatar
grunt    
Mark Otto committed
448
          addAriaPressed = false;
Jacob Thornton's avatar
Jacob Thornton committed
449
450
        }
      }
Mark Otto's avatar
grunt    
Mark Otto committed
451

Mark Otto's avatar
grunt    
Mark Otto committed
452
453
454
      if (addAriaPressed) {
        this._element.setAttribute('aria-pressed', !$(this._element).hasClass(ClassName.ACTIVE));
      }
Mark Otto's avatar
grunt    
Mark Otto committed
455

Mark Otto's avatar
grunt    
Mark Otto committed
456
457
      if (triggerChangeEvent) {
        $(this._element).toggleClass(ClassName.ACTIVE);
Jacob Thornton's avatar
Jacob Thornton committed
458
      }
Mark Otto's avatar
grunt    
Mark Otto committed
459
    };
Jacob Thornton's avatar
Jacob Thornton committed
460

Mark Otto's avatar
grunt    
Mark Otto committed
461
462
463
464
    Button.prototype.dispose = function dispose() {
      $.removeData(this._element, DATA_KEY);
      this._element = null;
    };
Jacob Thornton's avatar
Jacob Thornton committed
465

Mark Otto's avatar
grunt    
Mark Otto committed
466
    // static
Jacob Thornton's avatar
Jacob Thornton committed
467

Mark Otto's avatar
grunt    
Mark Otto committed
468
469
470
    Button._jQueryInterface = function _jQueryInterface(config) {
      return this.each(function () {
        var data = $(this).data(DATA_KEY);
Jacob Thornton's avatar
Jacob Thornton committed
471

Mark Otto's avatar
grunt    
Mark Otto committed
472
473
474
475
476
477
478
479
480
481
482
483
        if (!data) {
          data = new Button(this);
          $(this).data(DATA_KEY, data);
        }

        if (config === 'toggle') {
          data[config]();
        }
      });
    };

    _createClass(Button, null, [{
Jacob Thornton's avatar
Jacob Thornton committed
484
485
486
487
488
489
490
      key: 'VERSION',
      get: function get() {
        return VERSION;
      }
    }]);

    return Button;
Mark Otto's avatar
grunt    
Mark Otto committed
491
492
493
494
495
496
497
  }();

  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
Jacob Thornton's avatar
Jacob Thornton committed
498
499
500
501
502
503
504
505
506
507
508
509
510
511

  $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) {
    event.preventDefault();

    var button = event.target;

    if (!$(button).hasClass(ClassName.BUTTON)) {
      button = $(button).closest(Selector.BUTTON);
    }

    Button._jQueryInterface.call($(button), 'toggle');
  }).on(Event.FOCUS_BLUR_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) {
    var button = $(event.target).closest(Selector.BUTTON)[0];
    $(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type));
Mark Otto's avatar
Mark Otto committed
512
  });
Jacob Thornton's avatar
Jacob Thornton committed
513
514
515
516
517
518
519

  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
   */

Mark Otto's avatar
Mark Otto committed
520
  $.fn[NAME] = Button._jQueryInterface;
Jacob Thornton's avatar
Jacob Thornton committed
521
522
523
524
525
526
527
  $.fn[NAME].Constructor = Button;
  $.fn[NAME].noConflict = function () {
    $.fn[NAME] = JQUERY_NO_CONFLICT;
    return Button._jQueryInterface;
  };

  return Button;
Mark Otto's avatar
Mark Otto committed
528
}(jQuery);
Jacob Thornton's avatar
Jacob Thornton committed
529
530
531

/**
 * --------------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
532
 * Bootstrap (v4.0.0-beta): carousel.js
Jacob Thornton's avatar
Jacob Thornton committed
533
534
535
536
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */

Mark Otto's avatar
Mark Otto committed
537
var Carousel = function ($) {
Jacob Thornton's avatar
Jacob Thornton committed
538
539
540
541
542
543
544
545

  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME = 'carousel';
Mark Otto's avatar
Mark Otto committed
546
  var VERSION = '4.0.0-beta';
Jacob Thornton's avatar
Jacob Thornton committed
547
548
549
550
551
  var DATA_KEY = 'bs.carousel';
  var EVENT_KEY = '.' + DATA_KEY;
  var DATA_API_KEY = '.data-api';
  var JQUERY_NO_CONFLICT = $.fn[NAME];
  var TRANSITION_DURATION = 600;
Chris Rebert's avatar
grunt    
Chris Rebert committed
552
553
  var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
Mark Otto's avatar
build    
Mark Otto committed
554
  var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
Jacob Thornton's avatar
Jacob Thornton committed
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573

  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',
Mark Otto's avatar
grunt    
Mark Otto committed
574
575
576
    PREV: 'prev',
    LEFT: 'left',
    RIGHT: 'right'
Jacob Thornton's avatar
Jacob Thornton committed
577
578
579
580
581
582
583
584
  };

  var Event = {
    SLIDE: 'slide' + EVENT_KEY,
    SLID: 'slid' + EVENT_KEY,
    KEYDOWN: 'keydown' + EVENT_KEY,
    MOUSEENTER: 'mouseenter' + EVENT_KEY,
    MOUSELEAVE: 'mouseleave' + EVENT_KEY,
Mark Otto's avatar
build    
Mark Otto committed
585
    TOUCHEND: 'touchend' + EVENT_KEY,
Jacob Thornton's avatar
Jacob Thornton committed
586
587
588
589
590
591
592
593
    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',
Mark Otto's avatar
grunt    
Mark Otto committed
594
595
596
597
    RIGHT: 'carousel-item-right',
    LEFT: 'carousel-item-left',
    NEXT: 'carousel-item-next',
    PREV: 'carousel-item-prev',
Jacob Thornton's avatar
Jacob Thornton committed
598
599
600
601
602
603
604
    ITEM: 'carousel-item'
  };

  var Selector = {
    ACTIVE: '.active',
    ACTIVE_ITEM: '.active.carousel-item',
    ITEM: '.carousel-item',
Mark Otto's avatar
grunt    
Mark Otto committed
605
    NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
Jacob Thornton's avatar
Jacob Thornton committed
606
607
608
609
    INDICATORS: '.carousel-indicators',
    DATA_SLIDE: '[data-slide], [data-slide-to]',
    DATA_RIDE: '[data-ride="carousel"]'

Mark Otto's avatar
dist    
Mark Otto committed
610
611
612
613
614
    /**
     * ------------------------------------------------------------------------
     * Class Definition
     * ------------------------------------------------------------------------
     */
Jacob Thornton's avatar
Jacob Thornton committed
615

Mark Otto's avatar
dist    
Mark Otto committed
616
  };
Mark Otto's avatar
grunt    
Mark Otto committed
617
  var Carousel = function () {
Jacob Thornton's avatar
Jacob Thornton committed
618
619
620
621
622
623
624
625
626
627
    function Carousel(element, config) {
      _classCallCheck(this, Carousel);

      this._items = null;
      this._interval = null;
      this._activeElement = null;

      this._isPaused = false;
      this._isSliding = false;

Mark Otto's avatar
build    
Mark Otto committed
628
629
      this.touchTimeout = null;

Jacob Thornton's avatar
Jacob Thornton committed
630
631
632
633
634
635
636
637
638
      this._config = this._getConfig(config);
      this._element = $(element)[0];
      this._indicatorsElement = $(this._element).find(Selector.INDICATORS)[0];

      this._addEventListeners();
    }

    // getters

Mark Otto's avatar
grunt    
Mark Otto committed
639
    // public
Jacob Thornton's avatar
Jacob Thornton committed
640

Mark Otto's avatar
grunt    
Mark Otto committed
641
    Carousel.prototype.next = function next() {
Mark Otto's avatar
grunt    
Mark Otto committed
642
643
      if (!this._isSliding) {
        this._slide(Direction.NEXT);
Mark Otto's avatar
grunt    
Mark Otto committed
644
645
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
646

Mark Otto's avatar
grunt    
Mark Otto committed
647
648
649
650
    Carousel.prototype.nextWhenVisible = function nextWhenVisible() {
      // Don't call next when the page isn't visible
      if (!document.hidden) {
        this.next();
Jacob Thornton's avatar
Jacob Thornton committed
651
      }
Mark Otto's avatar
grunt    
Mark Otto committed
652
653
654
    };

    Carousel.prototype.prev = function prev() {
Mark Otto's avatar
grunt    
Mark Otto committed
655
656
      if (!this._isSliding) {
        this._slide(Direction.PREV);
XhmikosR's avatar
XhmikosR committed
657
      }
Mark Otto's avatar
grunt    
Mark Otto committed
658
659
660
661
662
    };

    Carousel.prototype.pause = function pause(event) {
      if (!event) {
        this._isPaused = true;
Jacob Thornton's avatar
Jacob Thornton committed
663
664
      }

Mark Otto's avatar
grunt    
Mark Otto committed
665
666
667
668
669
670
671
672
673
674
675
676
677
      if ($(this._element).find(Selector.NEXT_PREV)[0] && Util.supportsTransitionEnd()) {
        Util.triggerTransitionEnd(this._element);
        this.cycle(true);
      }

      clearInterval(this._interval);
      this._interval = null;
    };

    Carousel.prototype.cycle = function cycle(event) {
      if (!event) {
        this._isPaused = false;
      }
Jacob Thornton's avatar
Jacob Thornton committed
678

Mark Otto's avatar
grunt    
Mark Otto committed
679
      if (this._interval) {
Jacob Thornton's avatar
Jacob Thornton committed
680
681
682
683
        clearInterval(this._interval);
        this._interval = null;
      }

Mark Otto's avatar
grunt    
Mark Otto committed
684
      if (this._config.interval && !this._isPaused) {
Mark Otto's avatar
grunt    
Mark Otto committed
685
        this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
Mark Otto's avatar
grunt    
Mark Otto committed
686
687
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
688

Mark Otto's avatar
grunt    
Mark Otto committed
689
    Carousel.prototype.to = function to(index) {
Mark Otto's avatar
grunt    
Mark Otto committed
690
      var _this3 = this;
Mark Otto's avatar
grunt    
Mark Otto committed
691
692
693
694
695
696
697

      this._activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];

      var activeIndex = this._getItemIndex(this._activeElement);

      if (index > this._items.length - 1 || index < 0) {
        return;
Jacob Thornton's avatar
Jacob Thornton committed
698
699
      }

Mark Otto's avatar
grunt    
Mark Otto committed
700
701
      if (this._isSliding) {
        $(this._element).one(Event.SLID, function () {
Mark Otto's avatar
grunt    
Mark Otto committed
702
          return _this3.to(index);
Mark Otto's avatar
grunt    
Mark Otto committed
703
704
705
        });
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
706

Mark Otto's avatar
grunt    
Mark Otto committed
707
708
709
710
711
      if (activeIndex === index) {
        this.pause();
        this.cycle();
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
712

Mark Otto's avatar
grunt    
Mark Otto committed
713
      var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
Jacob Thornton's avatar
Jacob Thornton committed
714

Mark Otto's avatar
grunt    
Mark Otto committed
715
716
      this._slide(direction, this._items[index]);
    };
Jacob Thornton's avatar
Jacob Thornton committed
717

Mark Otto's avatar
grunt    
Mark Otto committed
718
719
720
    Carousel.prototype.dispose = function dispose() {
      $(this._element).off(EVENT_KEY);
      $.removeData(this._element, DATA_KEY);
Jacob Thornton's avatar
Jacob Thornton committed
721

Mark Otto's avatar
grunt    
Mark Otto committed
722
723
724
725
726
727
728
729
730
      this._items = null;
      this._config = null;
      this._element = null;
      this._interval = null;
      this._isPaused = null;
      this._isSliding = null;
      this._activeElement = null;
      this._indicatorsElement = null;
    };
Jacob Thornton's avatar
Jacob Thornton committed
731

Mark Otto's avatar
grunt    
Mark Otto committed
732
    // private
Jacob Thornton's avatar
Jacob Thornton committed
733

Mark Otto's avatar
grunt    
Mark Otto committed
734
735
736
737
738
    Carousel.prototype._getConfig = function _getConfig(config) {
      config = $.extend({}, Default, config);
      Util.typeCheckConfig(NAME, config, DefaultType);
      return config;
    };
Jacob Thornton's avatar
Jacob Thornton committed
739

Mark Otto's avatar
grunt    
Mark Otto committed
740
    Carousel.prototype._addEventListeners = function _addEventListeners() {
Mark Otto's avatar
grunt    
Mark Otto committed
741
742
      var _this4 = this;

Mark Otto's avatar
grunt    
Mark Otto committed
743
      if (this._config.keyboard) {
Mark Otto's avatar
grunt    
Mark Otto committed
744
745
746
        $(this._element).on(Event.KEYDOWN, function (event) {
          return _this4._keydown(event);
        });
Jacob Thornton's avatar
Jacob Thornton committed
747
748
      }

Mark Otto's avatar
build    
Mark Otto committed
749
      if (this._config.pause === 'hover') {
Mark Otto's avatar
grunt    
Mark Otto committed
750
751
752
753
754
        $(this._element).on(Event.MOUSEENTER, function (event) {
          return _this4.pause(event);
        }).on(Event.MOUSELEAVE, function (event) {
          return _this4.cycle(event);
        });
Mark Otto's avatar
build    
Mark Otto committed
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
        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
          $(this._element).on(Event.TOUCHEND, function () {
            _this4.pause();
            if (_this4.touchTimeout) {
              clearTimeout(_this4.touchTimeout);
            }
            _this4.touchTimeout = setTimeout(function (event) {
              return _this4.cycle(event);
            }, TOUCHEVENT_COMPAT_WAIT + _this4._config.interval);
          });
        }
Jacob Thornton's avatar
Jacob Thornton committed
773
      }
Mark Otto's avatar
grunt    
Mark Otto committed
774
    };
Jacob Thornton's avatar
Jacob Thornton committed
775

Mark Otto's avatar
grunt    
Mark Otto committed
776
777
778
    Carousel.prototype._keydown = function _keydown(event) {
      if (/input|textarea/i.test(event.target.tagName)) {
        return;
Jacob Thornton's avatar
Jacob Thornton committed
779
      }
Mark Otto's avatar
grunt    
Mark Otto committed
780
781
782

      switch (event.which) {
        case ARROW_LEFT_KEYCODE:
Mark Otto's avatar
grunt    
Mark Otto committed
783
          event.preventDefault();
Mark Otto's avatar
grunt    
Mark Otto committed
784
785
786
          this.prev();
          break;
        case ARROW_RIGHT_KEYCODE:
Mark Otto's avatar
grunt    
Mark Otto committed
787
          event.preventDefault();
Mark Otto's avatar
grunt    
Mark Otto committed
788
789
790
791
          this.next();
          break;
        default:
          return;
Jacob Thornton's avatar
Jacob Thornton committed
792
      }
Mark Otto's avatar
grunt    
Mark Otto committed
793
    };
Jacob Thornton's avatar
Jacob Thornton committed
794

Mark Otto's avatar
grunt    
Mark Otto committed
795
796
797
798
    Carousel.prototype._getItemIndex = function _getItemIndex(element) {
      this._items = $.makeArray($(element).parent().find(Selector.ITEM));
      return this._items.indexOf(element);
    };
Jacob Thornton's avatar
Jacob Thornton committed
799

Mark Otto's avatar
grunt    
Mark Otto committed
800
801
    Carousel.prototype._getItemByDirection = function _getItemByDirection(direction, activeElement) {
      var isNextDirection = direction === Direction.NEXT;
Mark Otto's avatar
grunt    
Mark Otto committed
802
      var isPrevDirection = direction === Direction.PREV;
Mark Otto's avatar
grunt    
Mark Otto committed
803
804
805
      var activeIndex = this._getItemIndex(activeElement);
      var lastItemIndex = this._items.length - 1;
      var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
Jacob Thornton's avatar
Jacob Thornton committed
806

Mark Otto's avatar
grunt    
Mark Otto committed
807
808
      if (isGoingToWrap && !this._config.wrap) {
        return activeElement;
Jacob Thornton's avatar
Jacob Thornton committed
809
810
      }

Mark Otto's avatar
grunt    
Mark Otto committed
811
      var delta = direction === Direction.PREV ? -1 : 1;
Mark Otto's avatar
grunt    
Mark Otto committed
812
      var itemIndex = (activeIndex + delta) % this._items.length;
Jacob Thornton's avatar
Jacob Thornton committed
813

Mark Otto's avatar
grunt    
Mark Otto committed
814
815
      return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
    };
Jacob Thornton's avatar
Jacob Thornton committed
816

Mark Otto's avatar
grunt    
Mark Otto committed
817
    Carousel.prototype._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
Mark Otto's avatar
grunt    
Mark Otto committed
818
819
      var targetIndex = this._getItemIndex(relatedTarget);
      var fromIndex = this._getItemIndex($(this._element).find(Selector.ACTIVE_ITEM)[0]);
Mark Otto's avatar
grunt    
Mark Otto committed
820
821
      var slideEvent = $.Event(Event.SLIDE, {
        relatedTarget: relatedTarget,
Mark Otto's avatar
grunt    
Mark Otto committed
822
823
824
        direction: eventDirectionName,
        from: fromIndex,
        to: targetIndex
Mark Otto's avatar
grunt    
Mark Otto committed
825
      });
Jacob Thornton's avatar
Jacob Thornton committed
826

Mark Otto's avatar
grunt    
Mark Otto committed
827
      $(this._element).trigger(slideEvent);
Jacob Thornton's avatar
Jacob Thornton committed
828

Mark Otto's avatar
grunt    
Mark Otto committed
829
830
      return slideEvent;
    };
Jacob Thornton's avatar
Jacob Thornton committed
831

Mark Otto's avatar
grunt    
Mark Otto committed
832
833
834
    Carousel.prototype._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
      if (this._indicatorsElement) {
        $(this._indicatorsElement).find(Selector.ACTIVE).removeClass(ClassName.ACTIVE);
Jacob Thornton's avatar
Jacob Thornton committed
835

Mark Otto's avatar
grunt    
Mark Otto committed
836
        var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
Jacob Thornton's avatar
Jacob Thornton committed
837

Mark Otto's avatar
grunt    
Mark Otto committed
838
839
        if (nextIndicator) {
          $(nextIndicator).addClass(ClassName.ACTIVE);
Jacob Thornton's avatar
Jacob Thornton committed
840
        }
Mark Otto's avatar
grunt    
Mark Otto committed
841
842
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
843

Mark Otto's avatar
grunt    
Mark Otto committed
844
    Carousel.prototype._slide = function _slide(direction, element) {
Mark Otto's avatar
grunt    
Mark Otto committed
845
      var _this5 = this;
Jacob Thornton's avatar
Jacob Thornton committed
846

Mark Otto's avatar
grunt    
Mark Otto committed
847
      var activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];
Mark Otto's avatar
grunt    
Mark Otto committed
848
      var activeElementIndex = this._getItemIndex(activeElement);
Mark Otto's avatar
grunt    
Mark Otto committed
849
      var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
Mark Otto's avatar
grunt    
Mark Otto committed
850
      var nextElementIndex = this._getItemIndex(nextElement);
Mark Otto's avatar
grunt    
Mark Otto committed
851
      var isCycling = Boolean(this._interval);
Jacob Thornton's avatar
Jacob Thornton committed
852

Mark Otto's avatar
grunt    
Mark Otto committed
853
854
855
856
857
858
859
860
861
862
863
864
865
      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;
      }
Mark Otto's avatar
grunt    
Mark Otto committed
866
867
868
869
870

      if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) {
        this._isSliding = false;
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
871

Mark Otto's avatar
grunt    
Mark Otto committed
872
      var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
Mark Otto's avatar
grunt    
Mark Otto committed
873
874
875
      if (slideEvent.isDefaultPrevented()) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
876

Mark Otto's avatar
grunt    
Mark Otto committed
877
878
879
880
      if (!activeElement || !nextElement) {
        // some weirdness is happening, so we bail
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
881

Mark Otto's avatar
grunt    
Mark Otto committed
882
883
884
885
886
      this._isSliding = true;

      if (isCycling) {
        this.pause();
      }
Jacob Thornton's avatar
Jacob Thornton committed
887

Mark Otto's avatar
grunt    
Mark Otto committed
888
      this._setActiveIndicatorElement(nextElement);
Jacob Thornton's avatar
Jacob Thornton committed
889

Mark Otto's avatar
grunt    
Mark Otto committed
890
891
      var slidEvent = $.Event(Event.SLID, {
        relatedTarget: nextElement,
Mark Otto's avatar
grunt    
Mark Otto committed
892
893
894
        direction: eventDirectionName,
        from: activeElementIndex,
        to: nextElementIndex
Mark Otto's avatar
grunt    
Mark Otto committed
895
      });
Jacob Thornton's avatar
Jacob Thornton committed
896

Mark Otto's avatar
grunt    
Mark Otto committed
897
      if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.SLIDE)) {
Jacob Thornton's avatar
Jacob Thornton committed
898

Mark Otto's avatar
grunt    
Mark Otto committed
899
        $(nextElement).addClass(orderClassName);
Jacob Thornton's avatar
Jacob Thornton committed
900

Mark Otto's avatar
grunt    
Mark Otto committed
901
        Util.reflow(nextElement);
Jacob Thornton's avatar
Jacob Thornton committed
902

Mark Otto's avatar
grunt    
Mark Otto committed
903
904
        $(activeElement).addClass(directionalClassName);
        $(nextElement).addClass(directionalClassName);
Jacob Thornton's avatar
Jacob Thornton committed
905

Mark Otto's avatar
grunt    
Mark Otto committed
906
        $(activeElement).one(Util.TRANSITION_END, function () {
Mark Otto's avatar
grunt    
Mark Otto committed
907
          $(nextElement).removeClass(directionalClassName + ' ' + orderClassName).addClass(ClassName.ACTIVE);
Jacob Thornton's avatar
Jacob Thornton committed
908

Mark Otto's avatar
grunt    
Mark Otto committed
909
          $(activeElement).removeClass(ClassName.ACTIVE + ' ' + orderClassName + ' ' + directionalClassName);
Jacob Thornton's avatar
Jacob Thornton committed
910

Mark Otto's avatar
grunt    
Mark Otto committed
911
          _this5._isSliding = false;
Mark Otto's avatar
grunt    
Mark Otto committed
912
913

          setTimeout(function () {
Mark Otto's avatar
grunt    
Mark Otto committed
914
            return $(_this5._element).trigger(slidEvent);
Mark Otto's avatar
grunt    
Mark Otto committed
915
916
917
918
919
920
921
922
          }, 0);
        }).emulateTransitionEnd(TRANSITION_DURATION);
      } else {
        $(activeElement).removeClass(ClassName.ACTIVE);
        $(nextElement).addClass(ClassName.ACTIVE);

        this._isSliding = false;
        $(this._element).trigger(slidEvent);
Jacob Thornton's avatar
Jacob Thornton committed
923
924
      }

Mark Otto's avatar
grunt    
Mark Otto committed
925
926
927
928
      if (isCycling) {
        this.cycle();
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
929

Mark Otto's avatar
grunt    
Mark Otto committed
930
    // static
Jacob Thornton's avatar
Jacob Thornton committed
931

Mark Otto's avatar
grunt    
Mark Otto committed
932
933
934
935
    Carousel._jQueryInterface = function _jQueryInterface(config) {
      return this.each(function () {
        var data = $(this).data(DATA_KEY);
        var _config = $.extend({}, Default, $(this).data());
Jacob Thornton's avatar
Jacob Thornton committed
936

Mark Otto's avatar
grunt    
Mark Otto committed
937
938
939
        if ((typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object') {
          $.extend(_config, config);
        }
Jacob Thornton's avatar
Jacob Thornton committed
940

Mark Otto's avatar
grunt    
Mark Otto committed
941
        var action = typeof config === 'string' ? config : _config.slide;
Jacob Thornton's avatar
Jacob Thornton committed
942

Mark Otto's avatar
grunt    
Mark Otto committed
943
944
945
946
        if (!data) {
          data = new Carousel(this, _config);
          $(this).data(DATA_KEY, data);
        }
Jacob Thornton's avatar
Jacob Thornton committed
947

Mark Otto's avatar
grunt    
Mark Otto committed
948
949
950
951
952
953
954
955
956
957
        if (typeof config === 'number') {
          data.to(config);
        } else if (typeof action === 'string') {
          if (data[action] === undefined) {
            throw new Error('No method named "' + action + '"');
          }
          data[action]();
        } else if (_config.interval) {
          data.pause();
          data.cycle();
Jacob Thornton's avatar
Jacob Thornton committed
958
        }
Mark Otto's avatar
grunt    
Mark Otto committed
959
960
      });
    };
Jacob Thornton's avatar
Jacob Thornton committed
961

Mark Otto's avatar
grunt    
Mark Otto committed
962
963
    Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
      var selector = Util.getSelectorFromElement(this);
Jacob Thornton's avatar
Jacob Thornton committed
964

Mark Otto's avatar
grunt    
Mark Otto committed
965
966
967
      if (!selector) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
968

Mark Otto's avatar
grunt    
Mark Otto committed
969
      var target = $(selector)[0];
Jacob Thornton's avatar
Jacob Thornton committed
970

Mark Otto's avatar
grunt    
Mark Otto committed
971
972
973
      if (!target || !$(target).hasClass(ClassName.CAROUSEL)) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
974

Mark Otto's avatar
grunt    
Mark Otto committed
975
976
      var config = $.extend({}, $(target).data(), $(this).data());
      var slideIndex = this.getAttribute('data-slide-to');
Jacob Thornton's avatar
Jacob Thornton committed
977

Mark Otto's avatar
grunt    
Mark Otto committed
978
979
980
      if (slideIndex) {
        config.interval = false;
      }
Jacob Thornton's avatar
Jacob Thornton committed
981

Mark Otto's avatar
grunt    
Mark Otto committed
982
983
984
985
      Carousel._jQueryInterface.call($(target), config);

      if (slideIndex) {
        $(target).data(DATA_KEY).to(slideIndex);
Jacob Thornton's avatar
Jacob Thornton committed
986
      }
Mark Otto's avatar
grunt    
Mark Otto committed
987
988
989
990
991

      event.preventDefault();
    };

    _createClass(Carousel, null, [{
Jacob Thornton's avatar
Jacob Thornton committed
992
993
994
995
996
997
998
999
1000
      key: 'VERSION',
      get: function get() {
        return VERSION;
      }
    }, {
      key: 'Default',
      get: function get() {
        return Default;
      }
For faster browsing, not all history is shown. View entire blame