bootstrap.js 111 KB
Newer Older
1
/*!
Mark Otto's avatar
dist    
Mark Otto committed
2
3
4
5
6
7
8
  * Bootstrap v4.0.0-beta (https://getbootstrap.com)
  * Copyright 2011-2017 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  */
 
var bootstrap = (function (exports,$,Popper) {
'use strict';
Mark Otto's avatar
grunt    
Mark Otto committed
9

Mark Otto's avatar
dist    
Mark Otto committed
10
11
$ = $ && $.hasOwnProperty('default') ? $['default'] : $;
Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
Jacob Thornton's avatar
Jacob Thornton committed
12
13
14

/**
 * --------------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
15
 * Bootstrap (v4.0.0-beta): util.js
Jacob Thornton's avatar
Jacob Thornton committed
16
17
18
19
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */

Mark Otto's avatar
dist    
Mark Otto committed
20
var Util = function () {
Jacob Thornton's avatar
Jacob Thornton committed
21
22
23
24
25
26
27
28
29

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

  var transition = false;

Chris Rebert's avatar
grunt    
Chris Rebert committed
30
31
  var MAX_UID = 1000000;

Jacob Thornton's avatar
Jacob Thornton committed
32
33
34
35
36
37
  var TransitionEndEvent = {
    WebkitTransition: 'webkitTransitionEnd',
    MozTransition: 'transitionend',
    OTransition: 'oTransitionEnd otransitionend',
    transition: 'transitionend'

Mark Otto's avatar
dist    
Mark Otto committed
38
39
    // shoutout AngusCroll (https://goo.gl/pxwQGp)
  };function toType(obj) {
Mark Otto's avatar
grunt    
Mark Otto committed
40
    return {}.toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
Jacob Thornton's avatar
Jacob Thornton committed
41
42
43
44
45
46
47
48
49
50
51
52
  }

  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
53
          return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
Jacob Thornton's avatar
Jacob Thornton committed
54
        }
Mark Otto's avatar
dist    
Mark Otto committed
55
        return undefined; // eslint-disable-line no-undefined
Jacob Thornton's avatar
Jacob Thornton committed
56
57
58
59
60
61
62
63
64
65
66
      }
    };
  }

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

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

Mark Otto's avatar
grunt    
Mark Otto committed
67
    for (var name in TransitionEndEvent) {
Mark Otto's avatar
dist    
Mark Otto committed
68
      if (typeof el.style[name] !== 'undefined') {
Mark Otto's avatar
grunt    
Mark Otto committed
69
70
71
        return {
          end: TransitionEndEvent[name]
        };
Jacob Thornton's avatar
Jacob Thornton committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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
      }
    }

    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
117
      do {
Mark Otto's avatar
grunt    
Mark Otto committed
118
        // eslint-disable-next-line no-bitwise
Mark Otto's avatar
grunt    
Mark Otto committed
119
        prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
Jacob Thornton's avatar
Jacob Thornton committed
120
      } while (document.getElementById(prefix));
Jacob Thornton's avatar
Jacob Thornton committed
121
122
123
124
      return prefix;
    },
    getSelectorFromElement: function getSelectorFromElement(element) {
      var selector = element.getAttribute('data-target');
Mark Otto's avatar
grunt    
Mark Otto committed
125
      if (!selector || selector === '#') {
Jacob Thornton's avatar
Jacob Thornton committed
126
127
128
        selector = element.getAttribute('href') || '';
      }

Mark Otto's avatar
grunt    
Mark Otto committed
129
      try {
Mark Otto's avatar
dist    
Mark Otto committed
130
        var $selector = $(document).find(selector);
Mark Otto's avatar
grunt    
Mark Otto committed
131
132
133
134
        return $selector.length > 0 ? selector : null;
      } catch (error) {
        return null;
      }
Jacob Thornton's avatar
Jacob Thornton committed
135
136
    },
    reflow: function reflow(element) {
Mark Otto's avatar
grunt    
Mark Otto committed
137
      return element.offsetHeight;
Jacob Thornton's avatar
Jacob Thornton committed
138
139
140
141
142
    },
    triggerTransitionEnd: function triggerTransitionEnd(element) {
      $(element).trigger(transition.end);
    },
    supportsTransitionEnd: function supportsTransitionEnd() {
Jacob Thornton's avatar
Jacob Thornton committed
143
      return Boolean(transition);
Jacob Thornton's avatar
Jacob Thornton committed
144
145
146
    },
    typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
      for (var property in configTypes) {
Mark Otto's avatar
dist    
Mark Otto committed
147
        if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
Jacob Thornton's avatar
Jacob Thornton committed
148
149
          var expectedTypes = configTypes[property];
          var value = config[property];
Mark Otto's avatar
grunt    
Mark Otto committed
150
          var valueType = value && isElement(value) ? 'element' : toType(value);
Jacob Thornton's avatar
Jacob Thornton committed
151

Jacob Thornton's avatar
Jacob Thornton committed
152
153
154
          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
155
156
157
158
159
160
161
162
        }
      }
    }
  };

  setTransitionEndSupport();

  return Util;
Mark Otto's avatar
Mark Otto committed
163
}(jQuery);
Jacob Thornton's avatar
Jacob Thornton committed
164

Mark Otto's avatar
dist    
Mark Otto committed
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
var babelHelpers = {};
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 classCallCheck = function (instance, Constructor) {
  if (!(instance instanceof Constructor)) {
    throw new TypeError("Cannot call a class as a function");
  }
};

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;
  };
}();

var inherits = function (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;
};

var possibleConstructorReturn = function (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;
};

babelHelpers;

Jacob Thornton's avatar
Jacob Thornton committed
222
223
/**
 * --------------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
224
 * Bootstrap (v4.0.0-beta): alert.js
Jacob Thornton's avatar
Jacob Thornton committed
225
226
227
228
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */

Mark Otto's avatar
dist    
Mark Otto committed
229
var Alert = function () {
Jacob Thornton's avatar
Jacob Thornton committed
230
231
232
233
234
235
236
237

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

  var NAME = 'alert';
Mark Otto's avatar
Mark Otto committed
238
  var VERSION = '4.0.0-beta';
Jacob Thornton's avatar
Jacob Thornton committed
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
  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
258
    SHOW: 'show'
Jacob Thornton's avatar
Jacob Thornton committed
259

Mark Otto's avatar
dist    
Mark Otto committed
260
261
262
263
264
    /**
     * ------------------------------------------------------------------------
     * Class Definition
     * ------------------------------------------------------------------------
     */
Jacob Thornton's avatar
Jacob Thornton committed
265

Mark Otto's avatar
dist    
Mark Otto committed
266
  };
Mark Otto's avatar
grunt    
Mark Otto committed
267
  var Alert = function () {
Jacob Thornton's avatar
Jacob Thornton committed
268
    function Alert(element) {
Mark Otto's avatar
dist    
Mark Otto committed
269
      classCallCheck(this, Alert);
Jacob Thornton's avatar
Jacob Thornton committed
270
271
272
273
274
275

      this._element = element;
    }

    // getters

Mark Otto's avatar
grunt    
Mark Otto committed
276
    // public
Jacob Thornton's avatar
Jacob Thornton committed
277

Mark Otto's avatar
grunt    
Mark Otto committed
278
279
    Alert.prototype.close = function close(element) {
      element = element || this._element;
Jacob Thornton's avatar
Jacob Thornton committed
280

Mark Otto's avatar
grunt    
Mark Otto committed
281
282
283
284
285
286
      var rootElement = this._getRootElement(element);
      var customEvent = this._triggerCloseEvent(rootElement);

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

Mark Otto's avatar
grunt    
Mark Otto committed
288
289
      this._removeElement(rootElement);
    };
Jacob Thornton's avatar
Jacob Thornton committed
290

Mark Otto's avatar
grunt    
Mark Otto committed
291
292
293
294
295
296
    Alert.prototype.dispose = function dispose() {
      $.removeData(this._element, DATA_KEY);
      this._element = null;
    };

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

Mark Otto's avatar
grunt    
Mark Otto committed
298
299
300
301
302
303
    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
304
      }
Mark Otto's avatar
grunt    
Mark Otto committed
305
306
307

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

Mark Otto's avatar
grunt    
Mark Otto committed
310
311
      return parent;
    };
Jacob Thornton's avatar
Jacob Thornton committed
312

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

Mark Otto's avatar
grunt    
Mark Otto committed
316
317
318
      $(element).trigger(closeEvent);
      return closeEvent;
    };
Jacob Thornton's avatar
Jacob Thornton committed
319

Mark Otto's avatar
grunt    
Mark Otto committed
320
    Alert.prototype._removeElement = function _removeElement(element) {
Mark Otto's avatar
dist    
Mark Otto committed
321
      var _this = this;
Mark Otto's avatar
grunt    
Mark Otto committed
322

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

Mark Otto's avatar
grunt    
Mark Otto committed
325
326
327
      if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) {
        this._destroyElement(element);
        return;
Jacob Thornton's avatar
Jacob Thornton committed
328
      }
Jacob Thornton's avatar
Jacob Thornton committed
329

Mark Otto's avatar
grunt    
Mark Otto committed
330
      $(element).one(Util.TRANSITION_END, function (event) {
Mark Otto's avatar
dist    
Mark Otto committed
331
        return _this._destroyElement(element, event);
Mark Otto's avatar
grunt    
Mark Otto committed
332
      }).emulateTransitionEnd(TRANSITION_DURATION);
Mark Otto's avatar
grunt    
Mark Otto committed
333
    };
Jacob Thornton's avatar
Jacob Thornton committed
334

Mark Otto's avatar
grunt    
Mark Otto committed
335
336
337
    Alert.prototype._destroyElement = function _destroyElement(element) {
      $(element).detach().trigger(Event.CLOSED).remove();
    };
Jacob Thornton's avatar
Jacob Thornton committed
338

Mark Otto's avatar
grunt    
Mark Otto committed
339
    // static
Jacob Thornton's avatar
Jacob Thornton committed
340

Mark Otto's avatar
grunt    
Mark Otto committed
341
342
343
344
    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
345

Mark Otto's avatar
grunt    
Mark Otto committed
346
347
348
349
        if (!data) {
          data = new Alert(this);
          $element.data(DATA_KEY, data);
        }
Jacob Thornton's avatar
Jacob Thornton committed
350

Mark Otto's avatar
grunt    
Mark Otto committed
351
352
353
354
355
        if (config === 'close') {
          data[config](this);
        }
      });
    };
Jacob Thornton's avatar
Jacob Thornton committed
356

Mark Otto's avatar
grunt    
Mark Otto committed
357
358
359
360
361
    Alert._handleDismiss = function _handleDismiss(alertInstance) {
      return function (event) {
        if (event) {
          event.preventDefault();
        }
Jacob Thornton's avatar
Jacob Thornton committed
362

Mark Otto's avatar
grunt    
Mark Otto committed
363
364
365
366
        alertInstance.close(this);
      };
    };

Mark Otto's avatar
dist    
Mark Otto committed
367
    createClass(Alert, null, [{
Jacob Thornton's avatar
Jacob Thornton committed
368
369
370
371
372
373
      key: 'VERSION',
      get: function get() {
        return VERSION;
      }
    }]);
    return Alert;
Mark Otto's avatar
grunt    
Mark Otto committed
374
375
376
377
378
379
380
  }();

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

Mark Otto's avatar
Mark Otto committed
382
  $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
Jacob Thornton's avatar
Jacob Thornton committed
383
384
385
386
387
388
389

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

Mark Otto's avatar
Mark Otto committed
390
  $.fn[NAME] = Alert._jQueryInterface;
Jacob Thornton's avatar
Jacob Thornton committed
391
392
393
394
395
396
397
  $.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
398
}(jQuery);
Jacob Thornton's avatar
Jacob Thornton committed
399
400
401

/**
 * --------------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
402
 * Bootstrap (v4.0.0-beta): button.js
Jacob Thornton's avatar
Jacob Thornton committed
403
404
405
406
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */

Mark Otto's avatar
dist    
Mark Otto committed
407
var Button = function () {
Jacob Thornton's avatar
Jacob Thornton committed
408
409
410
411
412
413
414
415

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

  var NAME = 'button';
Mark Otto's avatar
Mark Otto committed
416
  var VERSION = '4.0.0-beta';
Jacob Thornton's avatar
Jacob Thornton committed
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
  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
440
441
442
443
444
    /**
     * ------------------------------------------------------------------------
     * Class Definition
     * ------------------------------------------------------------------------
     */
Jacob Thornton's avatar
Jacob Thornton committed
445

Mark Otto's avatar
dist    
Mark Otto committed
446
  };
Mark Otto's avatar
grunt    
Mark Otto committed
447
  var Button = function () {
Jacob Thornton's avatar
Jacob Thornton committed
448
    function Button(element) {
Mark Otto's avatar
dist    
Mark Otto committed
449
      classCallCheck(this, Button);
Jacob Thornton's avatar
Jacob Thornton committed
450
451
452
453
454
455

      this._element = element;
    }

    // getters

Mark Otto's avatar
grunt    
Mark Otto committed
456
    // public
Jacob Thornton's avatar
Jacob Thornton committed
457

Mark Otto's avatar
grunt    
Mark Otto committed
458
459
    Button.prototype.toggle = function toggle() {
      var triggerChangeEvent = true;
Mark Otto's avatar
grunt    
Mark Otto committed
460
      var addAriaPressed = true;
Mark Otto's avatar
grunt    
Mark Otto committed
461
      var rootElement = $(this._element).closest(Selector.DATA_TOGGLE)[0];
Jacob Thornton's avatar
Jacob Thornton committed
462

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

Mark Otto's avatar
grunt    
Mark Otto committed
466
467
468
469
470
471
        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
472

Mark Otto's avatar
grunt    
Mark Otto committed
473
474
              if (activeElement) {
                $(activeElement).removeClass(ClassName.ACTIVE);
Jacob Thornton's avatar
Jacob Thornton committed
475
476
              }
            }
Mark Otto's avatar
grunt    
Mark Otto committed
477
          }
Jacob Thornton's avatar
Jacob Thornton committed
478

Mark Otto's avatar
grunt    
Mark Otto committed
479
          if (triggerChangeEvent) {
Johann-S's avatar
build    
Johann-S committed
480
481
482
            if (input.hasAttribute('disabled') || rootElement.hasAttribute('disabled') || input.classList.contains('disabled') || rootElement.classList.contains('disabled')) {
              return;
            }
Mark Otto's avatar
grunt    
Mark Otto committed
483
            input.checked = !$(this._element).hasClass(ClassName.ACTIVE);
Mark Otto's avatar
grunt    
Mark Otto committed
484
            $(input).trigger('change');
Jacob Thornton's avatar
Jacob Thornton committed
485
486
          }

Mark Otto's avatar
grunt    
Mark Otto committed
487
          input.focus();
Mark Otto's avatar
grunt    
Mark Otto committed
488
          addAriaPressed = false;
Jacob Thornton's avatar
Jacob Thornton committed
489
490
        }
      }
Mark Otto's avatar
grunt    
Mark Otto committed
491

Mark Otto's avatar
grunt    
Mark Otto committed
492
493
494
      if (addAriaPressed) {
        this._element.setAttribute('aria-pressed', !$(this._element).hasClass(ClassName.ACTIVE));
      }
Mark Otto's avatar
grunt    
Mark Otto committed
495

Mark Otto's avatar
grunt    
Mark Otto committed
496
497
      if (triggerChangeEvent) {
        $(this._element).toggleClass(ClassName.ACTIVE);
Jacob Thornton's avatar
Jacob Thornton committed
498
      }
Mark Otto's avatar
grunt    
Mark Otto committed
499
    };
Jacob Thornton's avatar
Jacob Thornton committed
500

Mark Otto's avatar
grunt    
Mark Otto committed
501
502
503
504
    Button.prototype.dispose = function dispose() {
      $.removeData(this._element, DATA_KEY);
      this._element = null;
    };
Jacob Thornton's avatar
Jacob Thornton committed
505

Mark Otto's avatar
grunt    
Mark Otto committed
506
    // static
Jacob Thornton's avatar
Jacob Thornton committed
507

Mark Otto's avatar
grunt    
Mark Otto committed
508
509
510
    Button._jQueryInterface = function _jQueryInterface(config) {
      return this.each(function () {
        var data = $(this).data(DATA_KEY);
Jacob Thornton's avatar
Jacob Thornton committed
511

Mark Otto's avatar
grunt    
Mark Otto committed
512
513
514
515
516
517
518
519
520
521
522
        if (!data) {
          data = new Button(this);
          $(this).data(DATA_KEY, data);
        }

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

Mark Otto's avatar
dist    
Mark Otto committed
523
    createClass(Button, null, [{
Jacob Thornton's avatar
Jacob Thornton committed
524
525
526
527
528
529
      key: 'VERSION',
      get: function get() {
        return VERSION;
      }
    }]);
    return Button;
Mark Otto's avatar
grunt    
Mark Otto committed
530
531
532
533
534
535
536
  }();

  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
Jacob Thornton's avatar
Jacob Thornton committed
537
538
539
540
541
542
543
544
545
546
547
548
549
550

  $(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
551
  });
Jacob Thornton's avatar
Jacob Thornton committed
552
553
554
555
556
557
558

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

Mark Otto's avatar
Mark Otto committed
559
  $.fn[NAME] = Button._jQueryInterface;
Jacob Thornton's avatar
Jacob Thornton committed
560
561
562
563
564
565
566
  $.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
567
}(jQuery);
Jacob Thornton's avatar
Jacob Thornton committed
568
569
570

/**
 * --------------------------------------------------------------------------
Mark Otto's avatar
Mark Otto committed
571
 * Bootstrap (v4.0.0-beta): carousel.js
Jacob Thornton's avatar
Jacob Thornton committed
572
573
574
575
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */

Mark Otto's avatar
dist    
Mark Otto committed
576
var Carousel = function () {
Jacob Thornton's avatar
Jacob Thornton committed
577
578
579
580
581
582
583
584

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

  var NAME = 'carousel';
Mark Otto's avatar
Mark Otto committed
585
  var VERSION = '4.0.0-beta';
Jacob Thornton's avatar
Jacob Thornton committed
586
587
588
589
590
  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
591
592
  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
593
  var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
Jacob Thornton's avatar
Jacob Thornton committed
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612

  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
613
614
615
    PREV: 'prev',
    LEFT: 'left',
    RIGHT: 'right'
Jacob Thornton's avatar
Jacob Thornton committed
616
617
618
619
620
621
622
623
  };

  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
624
    TOUCHEND: 'touchend' + EVENT_KEY,
Jacob Thornton's avatar
Jacob Thornton committed
625
626
627
628
629
630
631
632
    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
633
634
635
636
    RIGHT: 'carousel-item-right',
    LEFT: 'carousel-item-left',
    NEXT: 'carousel-item-next',
    PREV: 'carousel-item-prev',
Jacob Thornton's avatar
Jacob Thornton committed
637
638
639
640
641
642
643
    ITEM: 'carousel-item'
  };

  var Selector = {
    ACTIVE: '.active',
    ACTIVE_ITEM: '.active.carousel-item',
    ITEM: '.carousel-item',
Mark Otto's avatar
grunt    
Mark Otto committed
644
    NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
Jacob Thornton's avatar
Jacob Thornton committed
645
646
647
648
    INDICATORS: '.carousel-indicators',
    DATA_SLIDE: '[data-slide], [data-slide-to]',
    DATA_RIDE: '[data-ride="carousel"]'

Mark Otto's avatar
dist    
Mark Otto committed
649
650
651
652
653
    /**
     * ------------------------------------------------------------------------
     * Class Definition
     * ------------------------------------------------------------------------
     */
Jacob Thornton's avatar
Jacob Thornton committed
654

Mark Otto's avatar
dist    
Mark Otto committed
655
  };
Mark Otto's avatar
grunt    
Mark Otto committed
656
  var Carousel = function () {
Jacob Thornton's avatar
Jacob Thornton committed
657
    function Carousel(element, config) {
Mark Otto's avatar
dist    
Mark Otto committed
658
      classCallCheck(this, Carousel);
Jacob Thornton's avatar
Jacob Thornton committed
659
660
661
662
663
664
665
666

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

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

Mark Otto's avatar
build    
Mark Otto committed
667
668
      this.touchTimeout = null;

Jacob Thornton's avatar
Jacob Thornton committed
669
670
671
672
673
674
675
676
677
      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
678
    // public
Jacob Thornton's avatar
Jacob Thornton committed
679

Mark Otto's avatar
grunt    
Mark Otto committed
680
    Carousel.prototype.next = function next() {
Mark Otto's avatar
grunt    
Mark Otto committed
681
682
      if (!this._isSliding) {
        this._slide(Direction.NEXT);
Mark Otto's avatar
grunt    
Mark Otto committed
683
684
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
685

Mark Otto's avatar
grunt    
Mark Otto committed
686
687
    Carousel.prototype.nextWhenVisible = function nextWhenVisible() {
      // Don't call next when the page isn't visible
Mark Otto's avatar
dist    
Mark Otto committed
688
689
      // or the carousel or its parent isn't visible
      if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
Mark Otto's avatar
grunt    
Mark Otto committed
690
        this.next();
Jacob Thornton's avatar
Jacob Thornton committed
691
      }
Mark Otto's avatar
grunt    
Mark Otto committed
692
693
694
    };

    Carousel.prototype.prev = function prev() {
Mark Otto's avatar
grunt    
Mark Otto committed
695
696
      if (!this._isSliding) {
        this._slide(Direction.PREV);
XhmikosR's avatar
XhmikosR committed
697
      }
Mark Otto's avatar
grunt    
Mark Otto committed
698
699
700
701
702
    };

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

Mark Otto's avatar
grunt    
Mark Otto committed
705
706
707
708
709
710
711
712
713
714
715
716
717
      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
718

Mark Otto's avatar
grunt    
Mark Otto committed
719
      if (this._interval) {
Jacob Thornton's avatar
Jacob Thornton committed
720
721
722
723
        clearInterval(this._interval);
        this._interval = null;
      }

Mark Otto's avatar
grunt    
Mark Otto committed
724
      if (this._config.interval && !this._isPaused) {
Mark Otto's avatar
grunt    
Mark Otto committed
725
        this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
Mark Otto's avatar
grunt    
Mark Otto committed
726
727
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
728

Mark Otto's avatar
grunt    
Mark Otto committed
729
    Carousel.prototype.to = function to(index) {
Mark Otto's avatar
dist    
Mark Otto committed
730
      var _this = this;
Mark Otto's avatar
grunt    
Mark Otto committed
731
732
733
734
735
736
737

      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
738
739
      }

Mark Otto's avatar
grunt    
Mark Otto committed
740
741
      if (this._isSliding) {
        $(this._element).one(Event.SLID, function () {
Mark Otto's avatar
dist    
Mark Otto committed
742
          return _this.to(index);
Mark Otto's avatar
grunt    
Mark Otto committed
743
744
745
        });
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
746

Mark Otto's avatar
grunt    
Mark Otto committed
747
748
749
750
751
      if (activeIndex === index) {
        this.pause();
        this.cycle();
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
752

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

Mark Otto's avatar
grunt    
Mark Otto committed
755
756
      this._slide(direction, this._items[index]);
    };
Jacob Thornton's avatar
Jacob Thornton committed
757

Mark Otto's avatar
grunt    
Mark Otto committed
758
759
760
    Carousel.prototype.dispose = function dispose() {
      $(this._element).off(EVENT_KEY);
      $.removeData(this._element, DATA_KEY);
Jacob Thornton's avatar
Jacob Thornton committed
761

Mark Otto's avatar
grunt    
Mark Otto committed
762
763
764
765
766
767
768
769
770
      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
771

Mark Otto's avatar
grunt    
Mark Otto committed
772
    // private
Jacob Thornton's avatar
Jacob Thornton committed
773

Mark Otto's avatar
grunt    
Mark Otto committed
774
775
776
777
778
    Carousel.prototype._getConfig = function _getConfig(config) {
      config = $.extend({}, Default, config);
      Util.typeCheckConfig(NAME, config, DefaultType);
      return config;
    };
Jacob Thornton's avatar
Jacob Thornton committed
779

Mark Otto's avatar
grunt    
Mark Otto committed
780
    Carousel.prototype._addEventListeners = function _addEventListeners() {
Mark Otto's avatar
dist    
Mark Otto committed
781
      var _this2 = this;
Mark Otto's avatar
grunt    
Mark Otto committed
782

Mark Otto's avatar
grunt    
Mark Otto committed
783
      if (this._config.keyboard) {
Mark Otto's avatar
grunt    
Mark Otto committed
784
        $(this._element).on(Event.KEYDOWN, function (event) {
Mark Otto's avatar
dist    
Mark Otto committed
785
          return _this2._keydown(event);
Mark Otto's avatar
grunt    
Mark Otto committed
786
        });
Jacob Thornton's avatar
Jacob Thornton committed
787
788
      }

Mark Otto's avatar
build    
Mark Otto committed
789
      if (this._config.pause === 'hover') {
Mark Otto's avatar
grunt    
Mark Otto committed
790
        $(this._element).on(Event.MOUSEENTER, function (event) {
Mark Otto's avatar
dist    
Mark Otto committed
791
          return _this2.pause(event);
Mark Otto's avatar
grunt    
Mark Otto committed
792
        }).on(Event.MOUSELEAVE, function (event) {
Mark Otto's avatar
dist    
Mark Otto committed
793
          return _this2.cycle(event);
Mark Otto's avatar
grunt    
Mark Otto committed
794
        });
Mark Otto's avatar
build    
Mark Otto committed
795
796
797
798
799
800
801
802
803
        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 () {
Mark Otto's avatar
dist    
Mark Otto committed
804
805
806
            _this2.pause();
            if (_this2.touchTimeout) {
              clearTimeout(_this2.touchTimeout);
Mark Otto's avatar
build    
Mark Otto committed
807
            }
Mark Otto's avatar
dist    
Mark Otto committed
808
809
810
            _this2.touchTimeout = setTimeout(function (event) {
              return _this2.cycle(event);
            }, TOUCHEVENT_COMPAT_WAIT + _this2._config.interval);
Mark Otto's avatar
build    
Mark Otto committed
811
812
          });
        }
Jacob Thornton's avatar
Jacob Thornton committed
813
      }
Mark Otto's avatar
grunt    
Mark Otto committed
814
    };
Jacob Thornton's avatar
Jacob Thornton committed
815

Mark Otto's avatar
grunt    
Mark Otto committed
816
817
818
    Carousel.prototype._keydown = function _keydown(event) {
      if (/input|textarea/i.test(event.target.tagName)) {
        return;
Jacob Thornton's avatar
Jacob Thornton committed
819
      }
Mark Otto's avatar
grunt    
Mark Otto committed
820
821
822

      switch (event.which) {
        case ARROW_LEFT_KEYCODE:
Mark Otto's avatar
grunt    
Mark Otto committed
823
          event.preventDefault();
Mark Otto's avatar
grunt    
Mark Otto committed
824
825
826
          this.prev();
          break;
        case ARROW_RIGHT_KEYCODE:
Mark Otto's avatar
grunt    
Mark Otto committed
827
          event.preventDefault();
Mark Otto's avatar
grunt    
Mark Otto committed
828
829
830
831
          this.next();
          break;
        default:
          return;
Jacob Thornton's avatar
Jacob Thornton committed
832
      }
Mark Otto's avatar
grunt    
Mark Otto committed
833
    };
Jacob Thornton's avatar
Jacob Thornton committed
834

Mark Otto's avatar
grunt    
Mark Otto committed
835
836
837
838
    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
839

Mark Otto's avatar
grunt    
Mark Otto committed
840
841
    Carousel.prototype._getItemByDirection = function _getItemByDirection(direction, activeElement) {
      var isNextDirection = direction === Direction.NEXT;
Mark Otto's avatar
grunt    
Mark Otto committed
842
      var isPrevDirection = direction === Direction.PREV;
Mark Otto's avatar
grunt    
Mark Otto committed
843
844
845
      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
846

Mark Otto's avatar
grunt    
Mark Otto committed
847
848
      if (isGoingToWrap && !this._config.wrap) {
        return activeElement;
Jacob Thornton's avatar
Jacob Thornton committed
849
850
      }

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

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

Mark Otto's avatar
grunt    
Mark Otto committed
857
    Carousel.prototype._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
Mark Otto's avatar
grunt    
Mark Otto committed
858
859
      var targetIndex = this._getItemIndex(relatedTarget);
      var fromIndex = this._getItemIndex($(this._element).find(Selector.ACTIVE_ITEM)[0]);
Mark Otto's avatar
grunt    
Mark Otto committed
860
861
      var slideEvent = $.Event(Event.SLIDE, {
        relatedTarget: relatedTarget,
Mark Otto's avatar
grunt    
Mark Otto committed
862
863
864
        direction: eventDirectionName,
        from: fromIndex,
        to: targetIndex
Mark Otto's avatar
grunt    
Mark Otto committed
865
      });
Jacob Thornton's avatar
Jacob Thornton committed
866

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

Mark Otto's avatar
grunt    
Mark Otto committed
869
870
      return slideEvent;
    };
Jacob Thornton's avatar
Jacob Thornton committed
871

Mark Otto's avatar
grunt    
Mark Otto committed
872
873
874
    Carousel.prototype._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
      if (this._indicatorsElement) {
        $(this._indicatorsElement).find(Selector.ACTIVE).removeClass(ClassName.ACTIVE);
Jacob Thornton's avatar
Jacob Thornton committed
875

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

Mark Otto's avatar
grunt    
Mark Otto committed
878
879
        if (nextIndicator) {
          $(nextIndicator).addClass(ClassName.ACTIVE);
Jacob Thornton's avatar
Jacob Thornton committed
880
        }
Mark Otto's avatar
grunt    
Mark Otto committed
881
882
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
883

Mark Otto's avatar
grunt    
Mark Otto committed
884
    Carousel.prototype._slide = function _slide(direction, element) {
Mark Otto's avatar
dist    
Mark Otto committed
885
      var _this3 = this;
Jacob Thornton's avatar
Jacob Thornton committed
886

Mark Otto's avatar
grunt    
Mark Otto committed
887
      var activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];
Mark Otto's avatar
grunt    
Mark Otto committed
888
      var activeElementIndex = this._getItemIndex(activeElement);
Mark Otto's avatar
grunt    
Mark Otto committed
889
      var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
Mark Otto's avatar
grunt    
Mark Otto committed
890
      var nextElementIndex = this._getItemIndex(nextElement);
Mark Otto's avatar
grunt    
Mark Otto committed
891
      var isCycling = Boolean(this._interval);
Jacob Thornton's avatar
Jacob Thornton committed
892

Mark Otto's avatar
grunt    
Mark Otto committed
893
894
895
896
897
898
899
900
901
902
903
904
905
      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
906
907
908
909
910

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

Mark Otto's avatar
grunt    
Mark Otto committed
912
      var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
Mark Otto's avatar
grunt    
Mark Otto committed
913
914
915
      if (slideEvent.isDefaultPrevented()) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
916

Mark Otto's avatar
grunt    
Mark Otto committed
917
918
919
920
      if (!activeElement || !nextElement) {
        // some weirdness is happening, so we bail
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
921

Mark Otto's avatar
grunt    
Mark Otto committed
922
923
924
925
926
      this._isSliding = true;

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

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

Mark Otto's avatar
grunt    
Mark Otto committed
930
931
      var slidEvent = $.Event(Event.SLID, {
        relatedTarget: nextElement,
Mark Otto's avatar
grunt    
Mark Otto committed
932
933
934
        direction: eventDirectionName,
        from: activeElementIndex,
        to: nextElementIndex
Mark Otto's avatar
grunt    
Mark Otto committed
935
      });
Jacob Thornton's avatar
Jacob Thornton committed
936

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

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

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

Mark Otto's avatar
grunt    
Mark Otto committed
943
944
        $(activeElement).addClass(directionalClassName);
        $(nextElement).addClass(directionalClassName);
Jacob Thornton's avatar
Jacob Thornton committed
945

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

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

Mark Otto's avatar
dist    
Mark Otto committed
951
          _this3._isSliding = false;
Mark Otto's avatar
grunt    
Mark Otto committed
952
953

          setTimeout(function () {
Mark Otto's avatar
dist    
Mark Otto committed
954
            return $(_this3._element).trigger(slidEvent);
Mark Otto's avatar
grunt    
Mark Otto committed
955
956
957
958
959
960
961
962
          }, 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
963
964
      }

Mark Otto's avatar
grunt    
Mark Otto committed
965
966
967
968
      if (isCycling) {
        this.cycle();
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
969

Mark Otto's avatar
grunt    
Mark Otto committed
970
    // static
Jacob Thornton's avatar
Jacob Thornton committed
971

Mark Otto's avatar
grunt    
Mark Otto committed
972
973
974
975
    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
976

Mark Otto's avatar
grunt    
Mark Otto committed
977
978
979
        if ((typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object') {
          $.extend(_config, config);
        }
Jacob Thornton's avatar
Jacob Thornton committed
980

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

Mark Otto's avatar
grunt    
Mark Otto committed
983
984
985
986
        if (!data) {
          data = new Carousel(this, _config);
          $(this).data(DATA_KEY, data);
        }
Jacob Thornton's avatar
Jacob Thornton committed
987

Mark Otto's avatar
grunt    
Mark Otto committed
988
989
990
        if (typeof config === 'number') {
          data.to(config);
        } else if (typeof action === 'string') {
Mark Otto's avatar
dist    
Mark Otto committed
991
          if (typeof data[action] === 'undefined') {
Mark Otto's avatar
grunt    
Mark Otto committed
992
993
994
995
996
997
            throw new Error('No method named "' + action + '"');
          }
          data[action]();
        } else if (_config.interval) {
          data.pause();
          data.cycle();
Jacob Thornton's avatar
Jacob Thornton committed
998
        }
Mark Otto's avatar
grunt    
Mark Otto committed
999
1000
      });
    };
For faster browsing, not all history is shown. View entire blame