bootstrap.js 94.7 KB
Newer Older
1
/*!
Mark Otto's avatar
grunt    
Mark Otto committed
2
 * Bootstrap v4.0.0-alpha (http://getbootstrap.com)
Mark Otto's avatar
Mark Otto committed
3
 * Copyright 2011-2015 Twitter, Inc.
Mark Otto's avatar
Mark Otto committed
4
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
Chris Rebert's avatar
Chris Rebert committed
5
 */
6

Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
7
8
9
10
11
12
13
14
15
16
if (typeof jQuery === 'undefined') {
  throw new Error('Bootstrap\'s JavaScript requires jQuery')
}

+function ($) {
  var version = $.fn.jquery.split(' ')[0].split('.')
  if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1)) {
    throw new Error('Bootstrap\'s JavaScript requires jQuery version 1.9.1 or higher')
  }
}(jQuery);
17

fat's avatar
fat committed
18

fat's avatar
fat committed
19
+function ($) {
fat's avatar
fat committed
20
21

/**
22
23
24
25
 * --------------------------------------------------------------------------
 * Bootstrap (v4.0.0): util.js
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
fat's avatar
fat committed
26
27
 */

28
'use strict';
fat's avatar
fat committed
29

30
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; }; })();
fat's avatar
fat committed
31

32
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) subClass.__proto__ = superClass; }
fat's avatar
fat committed
33

34
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
fat's avatar
fat committed
35

36
var Util = (function ($) {
fat's avatar
fat committed
37

38
39
40
41
42
  /**
   * ------------------------------------------------------------------------
   * Private TransitionEnd Helpers
   * ------------------------------------------------------------------------
   */
fat's avatar
fat committed
43

44
  var transition = false;
fat's avatar
fat committed
45

46
47
48
49
50
51
  var TransitionEndEvent = {
    WebkitTransition: 'webkitTransitionEnd',
    MozTransition: 'transitionend',
    OTransition: 'oTransitionEnd otransitionend',
    transition: 'transitionend'
  };
fat's avatar
fat committed
52

53
54
55
  // shoutout AngusCroll (https://goo.gl/pxwQGp)
  function toType(obj) {
    return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
fat's avatar
fat committed
56
57
  }

58
59
60
  function isElement(obj) {
    return (obj[0] || obj).nodeType;
  }
fat's avatar
fat committed
61

62
63
64
65
66
67
68
69
70
71
  function getSpecialTransitionEndEvent() {
    return {
      bindType: transition.end,
      delegateType: transition.end,
      handle: function handle(event) {
        if ($(event.target).is(this)) {
          return event.handleObj.handler.apply(this, arguments);
        }
      }
    };
fat's avatar
fat committed
72
73
  }

74
75
76
77
  function transitionEndTest() {
    if (window.QUnit) {
      return false;
    }
fat's avatar
fat committed
78

79
    var el = document.createElement('bootstrap');
fat's avatar
fat committed
80

81
82
83
    for (var name in TransitionEndEvent) {
      if (el.style[name] !== undefined) {
        return { end: TransitionEndEvent[name] };
fat's avatar
fat committed
84
      }
fat's avatar
fat committed
85
86
    }

87
    return false;
fat's avatar
fat committed
88
89
  }

90
91
  function transitionEndEmulator(duration) {
    var _this = this;
fat's avatar
fat committed
92

93
    var called = false;
fat's avatar
fat committed
94

95
96
97
    $(this).one(Util.TRANSITION_END, function () {
      called = true;
    });
fat's avatar
fat committed
98

99
100
101
102
103
    setTimeout(function () {
      if (!called) {
        Util.triggerTransitionEnd(_this);
      }
    }, duration);
fat's avatar
fat committed
104

105
    return this;
fat's avatar
fat committed
106
107
  }

108
109
  function setTransitionEndSupport() {
    transition = transitionEndTest();
fat's avatar
fat committed
110

111
    $.fn.emulateTransitionEnd = transitionEndEmulator;
fat's avatar
fat committed
112

113
114
    if (Util.supportsTransitionEnd()) {
      $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
fat's avatar
fat committed
115
    }
116
  }
fat's avatar
fat committed
117

118
119
120
121
122
  /**
   * --------------------------------------------------------------------------
   * Public Util Api
   * --------------------------------------------------------------------------
   */
fat's avatar
fat committed
123

124
  var Util = {
fat's avatar
fat committed
125

126
    TRANSITION_END: 'bsTransitionEnd',
fat's avatar
fat committed
127

128
129
130
131
    getUID: function getUID(prefix) {
      do prefix += ~ ~(Math.random() * 1000000); while (document.getElementById(prefix));
      return prefix;
    },
fat's avatar
fat committed
132

133
134
    getSelectorFromElement: function getSelectorFromElement(element) {
      var selector = element.getAttribute('data-target');
fat's avatar
fat committed
135

136
137
138
139
      if (!selector) {
        selector = element.getAttribute('href') || '';
        selector = /^#[a-z]/i.test(selector) ? selector : null;
      }
fat's avatar
fat committed
140

141
142
      return selector;
    },
fat's avatar
fat committed
143

144
145
146
    reflow: function reflow(element) {
      new Function('bs', 'return bs')(element.offsetHeight);
    },
fat's avatar
fat committed
147

148
149
150
    triggerTransitionEnd: function triggerTransitionEnd(element) {
      $(element).trigger(transition.end);
    },
fat's avatar
fat committed
151

152
153
    supportsTransitionEnd: function supportsTransitionEnd() {
      return !!transition;
154
    },
fat's avatar
fat committed
155

156
    typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
fat's avatar
fat committed
157

158
159
160
161
      for (var property in configTypes) {
        var expectedTypes = configTypes[property];
        var value = config[property];
        var valueType = undefined;
fat's avatar
fat committed
162

163
        if (value && isElement(value)) valueType = 'element';else valueType = toType(value);
fat's avatar
fat committed
164

165
166
167
168
        if (!new RegExp(expectedTypes).test(valueType)) {
          throw new Error('' + componentName.toUpperCase() + ': ' + ('Option "' + property + '" provided type "' + valueType + '" ') + ('but expected type "' + expectedTypes + '".'));
        }
      }
169
    }
fat's avatar
fat committed
170

171
  };
fat's avatar
fat committed
172

173
  setTransitionEndSupport();
fat's avatar
fat committed
174

175
176
  return Util;
})(jQuery);
fat's avatar
fat committed
177
178

/**
179
180
181
182
 * --------------------------------------------------------------------------
 * Bootstrap (v4.0.0): alert.js
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
fat's avatar
fat committed
183
184
 */

185
var Alert = (function ($) {
fat's avatar
fat committed
186

187
188
189
190
191
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */
fat's avatar
fat committed
192

193
194
195
  var NAME = 'alert';
  var VERSION = '4.0.0';
  var DATA_KEY = 'bs.alert';
fat's avatar
fat committed
196
197
  var EVENT_KEY = '.' + DATA_KEY;
  var DATA_API_KEY = '.data-api';
198
199
  var JQUERY_NO_CONFLICT = $.fn[NAME];
  var TRANSITION_DURATION = 150;
fat's avatar
fat committed
200

201
202
203
  var Selector = {
    DISMISS: '[data-dismiss="alert"]'
  };
fat's avatar
fat committed
204

205
  var Event = {
fat's avatar
fat committed
206
207
208
    CLOSE: 'close' + EVENT_KEY,
    CLOSED: 'closed' + EVENT_KEY,
    CLICK_DATA_API: 'click' + EVENT_KEY + '' + DATA_API_KEY
209
  };
fat's avatar
fat committed
210

211
212
213
214
215
  var ClassName = {
    ALERT: 'alert',
    FADE: 'fade',
    IN: 'in'
  };
fat's avatar
fat committed
216

217
218
219
220
221
  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */
fat's avatar
fat committed
222

223
224
225
  var Alert = (function () {
    function Alert(element) {
      _classCallCheck(this, Alert);
fat's avatar
fat committed
226

227
228
      this._element = element;
    }
fat's avatar
fat committed
229

230
231
    _createClass(Alert, [{
      key: 'close',
fat's avatar
fat committed
232

233
      // public
fat's avatar
fat committed
234

235
236
      value: function close(element) {
        element = element || this._element;
fat's avatar
fat committed
237

238
239
        var rootElement = this._getRootElement(element);
        var customEvent = this._triggerCloseEvent(rootElement);
fat's avatar
fat committed
240

241
242
243
        if (customEvent.isDefaultPrevented()) {
          return;
        }
fat's avatar
fat committed
244

245
246
        this._removeElement(rootElement);
      }
fat's avatar
fat committed
247
248
249
250
251
252
    }, {
      key: 'dispose',
      value: function dispose() {
        $.removeData(this._element, DATA_KEY);
        this._element = null;
      }
253
254
    }, {
      key: '_getRootElement',
fat's avatar
fat committed
255

256
      // private
fat's avatar
fat committed
257

258
259
260
      value: function _getRootElement(element) {
        var parent = false;
        var selector = Util.getSelectorFromElement(element);
fat's avatar
fat committed
261

262
263
264
        if (selector) {
          parent = $(selector)[0];
        }
fat's avatar
fat committed
265

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

270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
        return parent;
      }
    }, {
      key: '_triggerCloseEvent',
      value: function _triggerCloseEvent(element) {
        var closeEvent = $.Event(Event.CLOSE);
        $(element).trigger(closeEvent);
        return closeEvent;
      }
    }, {
      key: '_removeElement',
      value: function _removeElement(element) {
        $(element).removeClass(ClassName.IN);

        if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) {
          this._destroyElement(element);
          return;
        }
fat's avatar
fat committed
288

289
290
291
292
293
294
295
296
297
        $(element).one(Util.TRANSITION_END, this._destroyElement.bind(this, element)).emulateTransitionEnd(TRANSITION_DURATION);
      }
    }, {
      key: '_destroyElement',
      value: function _destroyElement(element) {
        $(element).detach().trigger(Event.CLOSED).remove();
      }
    }], [{
      key: 'VERSION',
fat's avatar
fat committed
298

299
      // getters
fat's avatar
fat committed
300

301
302
303
304
305
      get: function () {
        return VERSION;
      }
    }, {
      key: '_jQueryInterface',
fat's avatar
fat committed
306

307
      // static
fat's avatar
fat committed
308

309
310
311
312
      value: function _jQueryInterface(config) {
        return this.each(function () {
          var $element = $(this);
          var data = $element.data(DATA_KEY);
fat's avatar
fat committed
313

314
315
316
317
          if (!data) {
            data = new Alert(this);
            $element.data(DATA_KEY, data);
          }
fat's avatar
fat committed
318

319
320
321
322
          if (config === 'close') {
            data[config](this);
          }
        });
fat's avatar
fat committed
323
      }
324
325
326
327
328
329
330
    }, {
      key: '_handleDismiss',
      value: function _handleDismiss(alertInstance) {
        return function (event) {
          if (event) {
            event.preventDefault();
          }
fat's avatar
fat committed
331

332
333
334
335
          alertInstance.close(this);
        };
      }
    }]);
fat's avatar
fat committed
336

337
338
    return Alert;
  })();
fat's avatar
fat committed
339

340
341
342
343
344
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
fat's avatar
fat committed
345

fat's avatar
fat committed
346
  $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
fat's avatar
fat committed
347

348
349
350
351
352
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
   */
fat's avatar
fat committed
353

354
355
356
357
358
359
  $.fn[NAME] = Alert._jQueryInterface;
  $.fn[NAME].Constructor = Alert;
  $.fn[NAME].noConflict = function () {
    $.fn[NAME] = JQUERY_NO_CONFLICT;
    return Alert._jQueryInterface;
  };
fat's avatar
fat committed
360

361
362
  return Alert;
})(jQuery);
fat's avatar
fat committed
363
364

/**
365
366
367
368
369
 * --------------------------------------------------------------------------
 * Bootstrap (v4.0.0): button.js
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */
fat's avatar
fat committed
370

371
372
373
374
375
376
377
378
379
380
381
var Button = (function ($) {

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

  var NAME = 'button';
  var VERSION = '4.0.0';
  var DATA_KEY = 'bs.button';
fat's avatar
fat committed
382
383
  var EVENT_KEY = '.' + DATA_KEY;
  var DATA_API_KEY = '.data-api';
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
  var JQUERY_NO_CONFLICT = $.fn[NAME];
  var TRANSITION_DURATION = 150;

  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 = {
fat's avatar
fat committed
402
403
    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)
404
405
406
407
408
409
410
411
412
413
414
415
416
  };

  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */

  var Button = (function () {
    function Button(element) {
      _classCallCheck(this, Button);

      this._element = element;
fat's avatar
fat committed
417
    }
fat's avatar
fat committed
418

419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
    _createClass(Button, [{
      key: 'toggle',

      // public

      value: function toggle() {
        var triggerChangeEvent = true;
        var rootElement = $(this._element).closest(Selector.DATA_TOGGLE)[0];

        if (rootElement) {
          var input = $(this._element).find(Selector.INPUT)[0];

          if (input) {
            if (input.type === 'radio') {
              if (input.checked && $(this._element).hasClass(ClassName.ACTIVE)) {
                triggerChangeEvent = false;
              } else {
                var activeElement = $(rootElement).find(Selector.ACTIVE)[0];

                if (activeElement) {
                  $(activeElement).removeClass(ClassName.ACTIVE);
                }
              }
            }

            if (triggerChangeEvent) {
              input.checked = !$(this._element).hasClass(ClassName.ACTIVE);
              $(this._element).trigger('change');
            }
          }
        } else {
          this._element.setAttribute('aria-pressed', !$(this._element).hasClass(ClassName.ACTIVE));
        }
fat's avatar
fat committed
452

453
454
455
456
        if (triggerChangeEvent) {
          $(this._element).toggleClass(ClassName.ACTIVE);
        }
      }
fat's avatar
fat committed
457
458
459
460
461
462
    }, {
      key: 'dispose',
      value: function dispose() {
        $.removeData(this._element, DATA_KEY);
        this._element = null;
      }
463
464
    }], [{
      key: 'VERSION',
fat's avatar
fat committed
465

466
      // getters
fat's avatar
fat committed
467

468
469
470
471
472
      get: function () {
        return VERSION;
      }
    }, {
      key: '_jQueryInterface',
fat's avatar
fat committed
473

474
      // static
fat's avatar
fat committed
475

476
477
478
      value: function _jQueryInterface(config) {
        return this.each(function () {
          var data = $(this).data(DATA_KEY);
fat's avatar
fat committed
479

480
481
482
483
          if (!data) {
            data = new Button(this);
            $(this).data(DATA_KEY, data);
          }
fat's avatar
fat committed
484

485
486
487
488
489
490
          if (config === 'toggle') {
            data[config]();
          }
        });
      }
    }]);
fat's avatar
fat committed
491

492
493
    return Button;
  })();
fat's avatar
fat committed
494

495
496
497
498
499
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
fat's avatar
fat committed
500

fat's avatar
fat committed
501
  $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) {
502
    event.preventDefault();
fat's avatar
fat committed
503

504
    var button = event.target;
fat's avatar
fat committed
505

506
507
508
    if (!$(button).hasClass(ClassName.BUTTON)) {
      button = $(button).closest(Selector.BUTTON);
    }
fat's avatar
fat committed
509

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

516
517
518
519
520
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
   */
fat's avatar
fat committed
521

522
523
524
525
526
527
  $.fn[NAME] = Button._jQueryInterface;
  $.fn[NAME].Constructor = Button;
  $.fn[NAME].noConflict = function () {
    $.fn[NAME] = JQUERY_NO_CONFLICT;
    return Button._jQueryInterface;
  };
fat's avatar
fat committed
528

529
530
  return Button;
})(jQuery);
fat's avatar
fat committed
531
532

/**
533
534
 * --------------------------------------------------------------------------
 * Bootstrap (v4.0.0): carousel.js
535
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
536
537
 * --------------------------------------------------------------------------
 */
538

539
var Carousel = (function ($) {
fat's avatar
fat committed
540

541
542
543
544
545
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */
fat's avatar
fat committed
546

547
548
549
  var NAME = 'carousel';
  var VERSION = '4.0.0';
  var DATA_KEY = 'bs.carousel';
fat's avatar
fat committed
550
551
  var EVENT_KEY = '.' + DATA_KEY;
  var DATA_API_KEY = '.data-api';
552
553
  var JQUERY_NO_CONFLICT = $.fn[NAME];
  var TRANSITION_DURATION = 600;
XhmikosR's avatar
XhmikosR committed
554

555
  var Default = {
fat's avatar
fat committed
556
    interval: 5000,
557
558
    keyboard: true,
    slide: false,
fat's avatar
fat committed
559
    pause: 'hover',
560
561
562
    wrap: true
  };

563
564
565
566
567
568
569
570
  var DefaultType = {
    interval: '(number|boolean)',
    keyboard: 'boolean',
    slide: '(boolean|string)',
    pause: '(string|boolean)',
    wrap: 'boolean'
  };

571
572
573
574
575
576
  var Direction = {
    NEXT: 'next',
    PREVIOUS: 'prev'
  };

  var Event = {
fat's avatar
fat committed
577
578
579
580
581
582
583
    SLIDE: 'slide' + EVENT_KEY,
    SLID: 'slid' + EVENT_KEY,
    KEYDOWN: 'keydown' + EVENT_KEY,
    MOUSEENTER: 'mouseenter' + EVENT_KEY,
    MOUSELEAVE: 'mouseleave' + EVENT_KEY,
    LOAD_DATA_API: 'load' + EVENT_KEY + '' + DATA_API_KEY,
    CLICK_DATA_API: 'click' + EVENT_KEY + '' + DATA_API_KEY
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
  };

  var ClassName = {
    CAROUSEL: 'carousel',
    ACTIVE: 'active',
    SLIDE: 'slide',
    RIGHT: 'right',
    LEFT: 'left',
    ITEM: 'carousel-item'
  };

  var Selector = {
    ACTIVE: '.active',
    ACTIVE_ITEM: '.active.carousel-item',
    ITEM: '.carousel-item',
    NEXT_PREV: '.next, .prev',
    INDICATORS: '.carousel-indicators',
    DATA_SLIDE: '[data-slide], [data-slide-to]',
    DATA_RIDE: '[data-ride="carousel"]'
  };

  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */

  var Carousel = (function () {
    function Carousel(element, config) {
      _classCallCheck(this, Carousel);

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

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

622
      this._config = this._getConfig(config);
623
624
625
626
      this._element = $(element)[0];
      this._indicatorsElement = $(this._element).find(Selector.INDICATORS)[0];

      this._addEventListeners();
627
628
    }

629
630
    _createClass(Carousel, [{
      key: 'next',
631

632
      // public
633

634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
      value: function next() {
        if (!this._isSliding) {
          this._slide(Direction.NEXT);
        }
      }
    }, {
      key: 'prev',
      value: function prev() {
        if (!this._isSliding) {
          this._slide(Direction.PREVIOUS);
        }
      }
    }, {
      key: 'pause',
      value: function pause(event) {
        if (!event) {
          this._isPaused = true;
        }
fat's avatar
fat committed
652

653
654
655
656
        if ($(this._element).find(Selector.NEXT_PREV)[0] && Util.supportsTransitionEnd()) {
          Util.triggerTransitionEnd(this._element);
          this.cycle(true);
        }
fat's avatar
fat committed
657

658
659
660
661
662
663
664
665
666
        clearInterval(this._interval);
        this._interval = null;
      }
    }, {
      key: 'cycle',
      value: function cycle(event) {
        if (!event) {
          this._isPaused = false;
        }
fat's avatar
fat committed
667

668
669
670
671
        if (this._interval) {
          clearInterval(this._interval);
          this._interval = null;
        }
fat's avatar
fat committed
672

673
        if (this._config.interval && !this._isPaused) {
fat's avatar
fat committed
674
          this._interval = setInterval($.proxy(this.next, this), this._config.interval);
675
676
677
678
679
680
        }
      }
    }, {
      key: 'to',
      value: function to(index) {
        var _this2 = this;
fat's avatar
fat committed
681

682
        this._activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];
fat's avatar
fat committed
683

684
        var activeIndex = this._getItemIndex(this._activeElement);
fat's avatar
fat committed
685

686
687
688
        if (index > this._items.length - 1 || index < 0) {
          return;
        }
fat's avatar
fat committed
689

690
691
692
693
694
695
        if (this._isSliding) {
          $(this._element).one(Event.SLID, function () {
            return _this2.to(index);
          });
          return;
        }
fat's avatar
fat committed
696

697
698
699
700
701
        if (activeIndex == index) {
          this.pause();
          this.cycle();
          return;
        }
fat's avatar
fat committed
702

703
        var direction = index > activeIndex ? Direction.NEXT : Direction.PREVIOUS;
fat's avatar
fat committed
704

705
706
        this._slide(direction, this._items[index]);
      }
fat's avatar
fat committed
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
    }, {
      key: 'dispose',
      value: function dispose() {
        $(this._element).off(EVENT_KEY);
        $.removeData(this._element, DATA_KEY);

        this._items = null;
        this._config = null;
        this._element = null;
        this._interval = null;
        this._isPaused = null;
        this._isSliding = null;
        this._activeElement = null;
        this._indicatorsElement = null;
      }
722
    }, {
723
      key: '_getConfig',
fat's avatar
fat committed
724

725
      // private
fat's avatar
fat committed
726

727
728
729
730
731
732
733
      value: function _getConfig(config) {
        config = $.extend({}, Default, config);
        Util.typeCheckConfig(NAME, config, DefaultType);
        return config;
      }
    }, {
      key: '_addEventListeners',
734
735
      value: function _addEventListeners() {
        if (this._config.keyboard) {
fat's avatar
fat committed
736
          $(this._element).on(Event.KEYDOWN, $.proxy(this._keydown, this));
737
        }
fat's avatar
fat committed
738

739
        if (this._config.pause == 'hover' && !('ontouchstart' in document.documentElement)) {
fat's avatar
fat committed
740
          $(this._element).on(Event.MOUSEENTER, $.proxy(this.pause, this)).on(Event.MOUSELEAVE, $.proxy(this.cycle, this));
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
        }
      }
    }, {
      key: '_keydown',
      value: function _keydown(event) {
        event.preventDefault();

        if (/input|textarea/i.test(event.target.tagName)) return;

        switch (event.which) {
          case 37:
            this.prev();break;
          case 39:
            this.next();break;
          default:
            return;
fat's avatar
fat committed
757
758
        }
      }
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
    }, {
      key: '_getItemIndex',
      value: function _getItemIndex(element) {
        this._items = $.makeArray($(element).parent().find(Selector.ITEM));
        return this._items.indexOf(element);
      }
    }, {
      key: '_getItemByDirection',
      value: function _getItemByDirection(direction, activeElement) {
        var isNextDirection = direction === Direction.NEXT;
        var isPrevDirection = direction === Direction.PREVIOUS;
        var activeIndex = this._getItemIndex(activeElement);
        var lastItemIndex = this._items.length - 1;
        var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex == lastItemIndex;

        if (isGoingToWrap && !this._config.wrap) {
          return activeElement;
        }
fat's avatar
fat committed
777

778
779
        var delta = direction == Direction.PREVIOUS ? -1 : 1;
        var itemIndex = (activeIndex + delta) % this._items.length;
fat's avatar
fat committed
780

781
        return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
fat's avatar
fat committed
782
      }
783
784
785
786
787
788
789
    }, {
      key: '_triggerSlideEvent',
      value: function _triggerSlideEvent(relatedTarget, directionalClassname) {
        var slideEvent = $.Event(Event.SLIDE, {
          relatedTarget: relatedTarget,
          direction: directionalClassname
        });
fat's avatar
fat committed
790

791
        $(this._element).trigger(slideEvent);
fat's avatar
fat committed
792

793
794
795
796
797
798
799
        return slideEvent;
      }
    }, {
      key: '_setActiveIndicatorElement',
      value: function _setActiveIndicatorElement(element) {
        if (this._indicatorsElement) {
          $(this._indicatorsElement).find(Selector.ACTIVE).removeClass(ClassName.ACTIVE);
fat's avatar
fat committed
800

801
          var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
fat's avatar
fat committed
802

803
804
805
806
807
808
809
810
811
          if (nextIndicator) {
            $(nextIndicator).addClass(ClassName.ACTIVE);
          }
        }
      }
    }, {
      key: '_slide',
      value: function _slide(direction, element) {
        var _this3 = this;
fat's avatar
fat committed
812

813
814
        var activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];
        var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
fat's avatar
fat committed
815

816
        var isCycling = !!this._interval;
fat's avatar
fat committed
817

818
        var directionalClassName = direction == Direction.NEXT ? ClassName.LEFT : ClassName.RIGHT;
fat's avatar
fat committed
819

820
821
822
823
        if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) {
          this._isSliding = false;
          return;
        }
fat's avatar
fat committed
824

825
826
827
828
        var slideEvent = this._triggerSlideEvent(nextElement, directionalClassName);
        if (slideEvent.isDefaultPrevented()) {
          return;
        }
fat's avatar
fat committed
829

830
831
832
833
        if (!activeElement || !nextElement) {
          // some weirdness is happening, so we bail
          return;
        }
fat's avatar
fat committed
834

835
        this._isSliding = true;
fat's avatar
fat committed
836

837
838
839
        if (isCycling) {
          this.pause();
        }
fat's avatar
fat committed
840

841
        this._setActiveIndicatorElement(nextElement);
fat's avatar
fat committed
842

843
844
845
846
        var slidEvent = $.Event(Event.SLID, {
          relatedTarget: nextElement,
          direction: directionalClassName
        });
fat's avatar
fat committed
847

848
        if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.SLIDE)) {
fat's avatar
fat committed
849

850
          $(nextElement).addClass(direction);
fat's avatar
fat committed
851

852
          Util.reflow(nextElement);
fat's avatar
fat committed
853

854
855
          $(activeElement).addClass(directionalClassName);
          $(nextElement).addClass(directionalClassName);
fat's avatar
fat committed
856

857
858
          $(activeElement).one(Util.TRANSITION_END, function () {
            $(nextElement).removeClass(directionalClassName).removeClass(direction);
fat's avatar
fat committed
859

860
            $(nextElement).addClass(ClassName.ACTIVE);
fat's avatar
fat committed
861

862
            $(activeElement).removeClass(ClassName.ACTIVE).removeClass(direction).removeClass(directionalClassName);
fat's avatar
fat committed
863

864
            _this3._isSliding = false;
fat's avatar
fat committed
865

866
867
868
869
870
871
872
            setTimeout(function () {
              return $(_this3._element).trigger(slidEvent);
            }, 0);
          }).emulateTransitionEnd(TRANSITION_DURATION);
        } else {
          $(activeElement).removeClass(ClassName.ACTIVE);
          $(nextElement).addClass(ClassName.ACTIVE);
fat's avatar
fat committed
873

874
875
876
          this._isSliding = false;
          $(this._element).trigger(slidEvent);
        }
fat's avatar
fat committed
877

878
879
880
881
882
883
        if (isCycling) {
          this.cycle();
        }
      }
    }], [{
      key: 'VERSION',
fat's avatar
fat committed
884

885
      // getters
fat's avatar
fat committed
886

887
888
889
890
891
892
893
894
895
896
      get: function () {
        return VERSION;
      }
    }, {
      key: 'Default',
      get: function () {
        return Default;
      }
    }, {
      key: '_jQueryInterface',
fat's avatar
fat committed
897

898
      // static
fat's avatar
fat committed
899

900
901
902
903
      value: function _jQueryInterface(config) {
        return this.each(function () {
          var data = $(this).data(DATA_KEY);
          var _config = $.extend({}, Default, $(this).data());
fat's avatar
fat committed
904

905
906
907
          if (typeof config === 'object') {
            $.extend(_config, config);
          }
fat's avatar
fat committed
908

909
          var action = typeof config === 'string' ? config : _config.slide;
fat's avatar
fat committed
910

911
912
913
914
          if (!data) {
            data = new Carousel(this, _config);
            $(this).data(DATA_KEY, data);
          }
fat's avatar
fat committed
915

916
917
918
919
920
921
922
923
924
925
926
927
928
929
          if (typeof config == 'number') {
            data.to(config);
          } else if (action) {
            data[action]();
          } else if (_config.interval) {
            data.pause();
            data.cycle();
          }
        });
      }
    }, {
      key: '_dataApiClickHandler',
      value: function _dataApiClickHandler(event) {
        var selector = Util.getSelectorFromElement(this);
fat's avatar
fat committed
930

931
932
933
        if (!selector) {
          return;
        }
fat's avatar
fat committed
934

935
        var target = $(selector)[0];
fat's avatar
fat committed
936

937
938
939
        if (!target || !$(target).hasClass(ClassName.CAROUSEL)) {
          return;
        }
fat's avatar
fat committed
940

941
        var config = $.extend({}, $(target).data(), $(this).data());
fat's avatar
fat committed
942

943
944
945
946
        var slideIndex = this.getAttribute('data-slide-to');
        if (slideIndex) {
          config.interval = false;
        }
fat's avatar
fat committed
947

948
        Carousel._jQueryInterface.call($(target), config);
fat's avatar
fat committed
949

950
951
952
        if (slideIndex) {
          $(target).data(DATA_KEY).to(slideIndex);
        }
fat's avatar
fat committed
953

954
955
956
        event.preventDefault();
      }
    }]);
fat's avatar
fat committed
957

958
959
    return Carousel;
  })();
fat's avatar
fat committed
960

961
962
963
964
965
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
fat's avatar
fat committed
966

fat's avatar
fat committed
967
  $(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler);
fat's avatar
fat committed
968

fat's avatar
fat committed
969
  $(window).on(Event.LOAD_DATA_API, function () {
970
971
972
973
974
    $(Selector.DATA_RIDE).each(function () {
      var $carousel = $(this);
      Carousel._jQueryInterface.call($carousel, $carousel.data());
    });
  });
fat's avatar
fat committed
975

976
977
978
979
980
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
   */
fat's avatar
fat committed
981

982
983
984
985
986
987
  $.fn[NAME] = Carousel._jQueryInterface;
  $.fn[NAME].Constructor = Carousel;
  $.fn[NAME].noConflict = function () {
    $.fn[NAME] = JQUERY_NO_CONFLICT;
    return Carousel._jQueryInterface;
  };
fat's avatar
fat committed
988

989
990
  return Carousel;
})(jQuery);
fat's avatar
fat committed
991
992

/**
993
994
995
996
997
 * --------------------------------------------------------------------------
 * Bootstrap (v4.0.0): collapse.js
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */
Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
998

999
1000
var Collapse = (function ($) {

For faster browsing, not all history is shown. View entire blame