bootstrap.bundle.js 240 KB
Newer Older
XhmikosR's avatar
XhmikosR committed
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
   * ------------------------------------------------------------------------
   */

  var NODE_TEXT = 3;
  var SelectorEngine = {
    matches: function matches(element, selector) {
      return element.matches(selector);
    },
    find: function find$1(selector, element) {
      var _ref;

      if (element === void 0) {
        element = document.documentElement;
      }

      return (_ref = []).concat.apply(_ref, find.call(element, selector));
    },
    findOne: function findOne$1(selector, element) {
      if (element === void 0) {
        element = document.documentElement;
      }

      return findOne.call(element, selector);
    },
    children: function children(element, selector) {
      var _ref2;

      var children = (_ref2 = []).concat.apply(_ref2, element.children);

      return children.filter(function (child) {
        return child.matches(selector);
      });
    },
    parents: function parents(element, selector) {
      var parents = [];
      var ancestor = element.parentNode;

      while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {
        if (this.matches(ancestor, selector)) {
          parents.push(ancestor);
        }

        ancestor = ancestor.parentNode;
      }

      return parents;
    },
    prev: function prev(element, selector) {
      var previous = element.previousElementSibling;

      while (previous) {
        if (previous.matches(selector)) {
          return [previous];
        }

        previous = previous.previousElementSibling;
      }

      return [];
    },
    next: function next(element, selector) {
      var next = element.nextElementSibling;

      while (next) {
        if (this.matches(next, selector)) {
          return [next];
        }

        next = next.nextElementSibling;
      }

      return [];
    }
  };

Mark Otto's avatar
dist  
Mark Otto committed
1076
  /**
XhmikosR's avatar
Dist    
XhmikosR committed
1077
1078
1079
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
Mark Otto's avatar
dist  
Mark Otto committed
1080
   */
Mark Otto's avatar
dist    
Mark Otto committed
1081

XhmikosR's avatar
Dist    
XhmikosR committed
1082
  var NAME$2 = 'carousel';
XhmikosR's avatar
XhmikosR committed
1083
  var VERSION$2 = '5.0.0-alpha2';
XhmikosR's avatar
Dist    
XhmikosR committed
1084
1085
1086
  var DATA_KEY$2 = 'bs.carousel';
  var EVENT_KEY$2 = "." + DATA_KEY$2;
  var DATA_API_KEY$2 = '.data-api';
XhmikosR's avatar
XhmikosR committed
1087
1088
  var ARROW_LEFT_KEY = 'ArrowLeft';
  var ARROW_RIGHT_KEY = 'ArrowRight';
XhmikosR's avatar
Dist    
XhmikosR committed
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
  var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch

  var SWIPE_THRESHOLD = 40;
  var Default = {
    interval: 5000,
    keyboard: true,
    slide: false,
    pause: 'hover',
    wrap: true,
    touch: true
  };
  var DefaultType = {
    interval: '(number|boolean)',
    keyboard: 'boolean',
    slide: '(boolean|string)',
    pause: '(string|boolean)',
    wrap: 'boolean',
    touch: 'boolean'
  };
XhmikosR's avatar
XhmikosR committed
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
  var DIRECTION_NEXT = 'next';
  var DIRECTION_PREV = 'prev';
  var DIRECTION_LEFT = 'left';
  var DIRECTION_RIGHT = 'right';
  var EVENT_SLIDE = "slide" + EVENT_KEY$2;
  var EVENT_SLID = "slid" + EVENT_KEY$2;
  var EVENT_KEYDOWN = "keydown" + EVENT_KEY$2;
  var EVENT_MOUSEENTER = "mouseenter" + EVENT_KEY$2;
  var EVENT_MOUSELEAVE = "mouseleave" + EVENT_KEY$2;
  var EVENT_TOUCHSTART = "touchstart" + EVENT_KEY$2;
  var EVENT_TOUCHMOVE = "touchmove" + EVENT_KEY$2;
  var EVENT_TOUCHEND = "touchend" + EVENT_KEY$2;
  var EVENT_POINTERDOWN = "pointerdown" + EVENT_KEY$2;
  var EVENT_POINTERUP = "pointerup" + EVENT_KEY$2;
  var EVENT_DRAG_START = "dragstart" + EVENT_KEY$2;
  var EVENT_LOAD_DATA_API = "load" + EVENT_KEY$2 + DATA_API_KEY$2;
  var EVENT_CLICK_DATA_API$2 = "click" + EVENT_KEY$2 + DATA_API_KEY$2;
  var CLASS_NAME_CAROUSEL = 'carousel';
  var CLASS_NAME_ACTIVE$1 = 'active';
  var CLASS_NAME_SLIDE = 'slide';
  var CLASS_NAME_RIGHT = 'carousel-item-right';
  var CLASS_NAME_LEFT = 'carousel-item-left';
  var CLASS_NAME_NEXT = 'carousel-item-next';
  var CLASS_NAME_PREV = 'carousel-item-prev';
  var CLASS_NAME_POINTER_EVENT = 'pointer-event';
XhmikosR's avatar
XhmikosR committed
1133
  var SELECTOR_ACTIVE = '.active';
XhmikosR's avatar
XhmikosR committed
1134
1135
1136
1137
1138
1139
1140
  var SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
  var SELECTOR_ITEM = '.carousel-item';
  var SELECTOR_ITEM_IMG = '.carousel-item img';
  var SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
  var SELECTOR_INDICATORS = '.carousel-indicators';
  var SELECTOR_DATA_SLIDE = '[data-slide], [data-slide-to]';
  var SELECTOR_DATA_RIDE = '[data-ride="carousel"]';
XhmikosR's avatar
Dist    
XhmikosR committed
1141
1142
1143
1144
  var PointerType = {
    TOUCH: 'touch',
    PEN: 'pen'
  };
XhmikosR's avatar
XhmikosR committed
1145
1146
1147
1148
1149
  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */
Mark Otto's avatar
dist    
Mark Otto committed
1150

XhmikosR's avatar
XhmikosR committed
1151
  var Carousel = /*#__PURE__*/function () {
XhmikosR's avatar
Dist    
XhmikosR committed
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
    function Carousel(element, config) {
      this._items = null;
      this._interval = null;
      this._activeElement = null;
      this._isPaused = false;
      this._isSliding = false;
      this.touchTimeout = null;
      this.touchStartX = 0;
      this.touchDeltaX = 0;
      this._config = this._getConfig(config);
      this._element = element;
XhmikosR's avatar
XhmikosR committed
1163
      this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
XhmikosR's avatar
Dist    
XhmikosR committed
1164
      this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
XhmikosR's avatar
XhmikosR committed
1165
      this._pointerEvent = Boolean(window.PointerEvent);
XhmikosR's avatar
Dist    
XhmikosR committed
1166
1167

      this._addEventListeners();
XhmikosR's avatar
XhmikosR committed
1168
1169

      Data.setData(element, DATA_KEY$2, this);
XhmikosR's avatar
Dist    
XhmikosR committed
1170
1171
1172
1173
1174
1175
1176
1177
    } // Getters


    var _proto = Carousel.prototype;

    // Public
    _proto.next = function next() {
      if (!this._isSliding) {
XhmikosR's avatar
XhmikosR committed
1178
        this._slide(DIRECTION_NEXT);
XhmikosR's avatar
Dist    
XhmikosR committed
1179
      }
Mark Otto's avatar
dist    
Mark Otto committed
1180
    };
Mark Otto's avatar
dist  
Mark Otto committed
1181

XhmikosR's avatar
Dist    
XhmikosR committed
1182
1183
1184
    _proto.nextWhenVisible = function nextWhenVisible() {
      // Don't call next when the page isn't visible
      // or the carousel or its parent isn't visible
XhmikosR's avatar
XhmikosR committed
1185
      if (!document.hidden && isVisible(this._element)) {
XhmikosR's avatar
Dist    
XhmikosR committed
1186
1187
        this.next();
      }
Mark Otto's avatar
dist  
Mark Otto committed
1188
1189
    };

XhmikosR's avatar
Dist    
XhmikosR committed
1190
1191
    _proto.prev = function prev() {
      if (!this._isSliding) {
XhmikosR's avatar
XhmikosR committed
1192
        this._slide(DIRECTION_PREV);
XhmikosR's avatar
Dist    
XhmikosR committed
1193
1194
      }
    };
Mark Otto's avatar
dist  
Mark Otto committed
1195

XhmikosR's avatar
Dist    
XhmikosR committed
1196
1197
1198
1199
    _proto.pause = function pause(event) {
      if (!event) {
        this._isPaused = true;
      }
Mark Otto's avatar
dist  
Mark Otto committed
1200

XhmikosR's avatar
XhmikosR committed
1201
      if (SelectorEngine.findOne(SELECTOR_NEXT_PREV, this._element)) {
XhmikosR's avatar
XhmikosR committed
1202
        triggerTransitionEnd(this._element);
XhmikosR's avatar
Dist    
XhmikosR committed
1203
1204
        this.cycle(true);
      }
Mark Otto's avatar
dist  
Mark Otto committed
1205

XhmikosR's avatar
Dist    
XhmikosR committed
1206
1207
1208
      clearInterval(this._interval);
      this._interval = null;
    };
Mark Otto's avatar
dist  
Mark Otto committed
1209

XhmikosR's avatar
Dist    
XhmikosR committed
1210
1211
1212
1213
    _proto.cycle = function cycle(event) {
      if (!event) {
        this._isPaused = false;
      }
Mark Otto's avatar
dist  
Mark Otto committed
1214

XhmikosR's avatar
Dist    
XhmikosR committed
1215
      if (this._interval) {
Mark Otto's avatar
dist    
Mark Otto committed
1216
1217
        clearInterval(this._interval);
        this._interval = null;
XhmikosR's avatar
Dist    
XhmikosR committed
1218
      }
Mark Otto's avatar
dist  
Mark Otto committed
1219

XhmikosR's avatar
XhmikosR committed
1220
      if (this._config && this._config.interval && !this._isPaused) {
XhmikosR's avatar
Dist    
XhmikosR committed
1221
1222
1223
        this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
      }
    };
Mark Otto's avatar
dist  
Mark Otto committed
1224

XhmikosR's avatar
Dist    
XhmikosR committed
1225
1226
    _proto.to = function to(index) {
      var _this = this;
Mark Otto's avatar
dist  
Mark Otto committed
1227

XhmikosR's avatar
XhmikosR committed
1228
      this._activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
Mark Otto's avatar
dist    
Mark Otto committed
1229

XhmikosR's avatar
Dist    
XhmikosR committed
1230
      var activeIndex = this._getItemIndex(this._activeElement);
Mark Otto's avatar
dist    
Mark Otto committed
1231

XhmikosR's avatar
Dist    
XhmikosR committed
1232
1233
1234
      if (index > this._items.length - 1 || index < 0) {
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
1235

XhmikosR's avatar
Dist    
XhmikosR committed
1236
      if (this._isSliding) {
XhmikosR's avatar
XhmikosR committed
1237
        EventHandler.one(this._element, EVENT_SLID, function () {
XhmikosR's avatar
Dist    
XhmikosR committed
1238
1239
1240
1241
          return _this.to(index);
        });
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
1242

XhmikosR's avatar
Dist    
XhmikosR committed
1243
1244
1245
1246
1247
      if (activeIndex === index) {
        this.pause();
        this.cycle();
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
1248

XhmikosR's avatar
XhmikosR committed
1249
      var direction = index > activeIndex ? DIRECTION_NEXT : DIRECTION_PREV;
Mark Otto's avatar
dist  
Mark Otto committed
1250

XhmikosR's avatar
Dist    
XhmikosR committed
1251
1252
      this._slide(direction, this._items[index]);
    };
Mark Otto's avatar
dist  
Mark Otto committed
1253

XhmikosR's avatar
Dist    
XhmikosR committed
1254
    _proto.dispose = function dispose() {
XhmikosR's avatar
XhmikosR committed
1255
1256
      EventHandler.off(this._element, EVENT_KEY$2);
      Data.removeData(this._element, DATA_KEY$2);
XhmikosR's avatar
Dist    
XhmikosR committed
1257
1258
1259
1260
1261
1262
1263
1264
      this._items = null;
      this._config = null;
      this._element = null;
      this._interval = null;
      this._isPaused = null;
      this._isSliding = null;
      this._activeElement = null;
      this._indicatorsElement = null;
Mark Otto's avatar
Mark Otto committed
1265
1266
    } // Private
    ;
XhmikosR's avatar
Dist    
XhmikosR committed
1267
1268

    _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
1269
      config = _extends({}, Default, config);
XhmikosR's avatar
XhmikosR committed
1270
      typeCheckConfig(NAME$2, config, DefaultType);
XhmikosR's avatar
Dist    
XhmikosR committed
1271
1272
      return config;
    };
Mark Otto's avatar
dist    
Mark Otto committed
1273

XhmikosR's avatar
Dist    
XhmikosR committed
1274
1275
    _proto._handleSwipe = function _handleSwipe() {
      var absDeltax = Math.abs(this.touchDeltaX);
Mark Otto's avatar
dist    
Mark Otto committed
1276

XhmikosR's avatar
Dist    
XhmikosR committed
1277
1278
1279
      if (absDeltax <= SWIPE_THRESHOLD) {
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
1280

XhmikosR's avatar
XhmikosR committed
1281
1282
      var direction = absDeltax / this.touchDeltaX;
      this.touchDeltaX = 0; // swipe left
Mark Otto's avatar
dist    
Mark Otto committed
1283

XhmikosR's avatar
Dist    
XhmikosR committed
1284
1285
1286
      if (direction > 0) {
        this.prev();
      } // swipe right
Mark Otto's avatar
dist    
Mark Otto committed
1287

Mark Otto's avatar
dist    
Mark Otto committed
1288

XhmikosR's avatar
Dist    
XhmikosR committed
1289
1290
1291
1292
      if (direction < 0) {
        this.next();
      }
    };
Mark Otto's avatar
dist  
Mark Otto committed
1293

XhmikosR's avatar
Dist    
XhmikosR committed
1294
1295
    _proto._addEventListeners = function _addEventListeners() {
      var _this2 = this;
Mark Otto's avatar
dist  
Mark Otto committed
1296

XhmikosR's avatar
Dist    
XhmikosR committed
1297
      if (this._config.keyboard) {
XhmikosR's avatar
XhmikosR committed
1298
        EventHandler.on(this._element, EVENT_KEYDOWN, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1299
1300
1301
          return _this2._keydown(event);
        });
      }
Mark Otto's avatar
dist    
Mark Otto committed
1302

XhmikosR's avatar
Dist    
XhmikosR committed
1303
      if (this._config.pause === 'hover') {
XhmikosR's avatar
XhmikosR committed
1304
        EventHandler.on(this._element, EVENT_MOUSEENTER, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1305
          return _this2.pause(event);
XhmikosR's avatar
XhmikosR committed
1306
        });
XhmikosR's avatar
XhmikosR committed
1307
        EventHandler.on(this._element, EVENT_MOUSELEAVE, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1308
1309
1310
          return _this2.cycle(event);
        });
      }
Mark Otto's avatar
dist    
Mark Otto committed
1311

1312
      if (this._config.touch && this._touchSupported) {
Mark Otto's avatar
Mark Otto committed
1313
1314
        this._addTouchEventListeners();
      }
XhmikosR's avatar
Dist    
XhmikosR committed
1315
    };
Mark Otto's avatar
dist  
Mark Otto committed
1316

XhmikosR's avatar
Dist    
XhmikosR committed
1317
1318
    _proto._addTouchEventListeners = function _addTouchEventListeners() {
      var _this3 = this;
Mark Otto's avatar
dist    
Mark Otto committed
1319

XhmikosR's avatar
Dist    
XhmikosR committed
1320
      var start = function start(event) {
XhmikosR's avatar
XhmikosR committed
1321
1322
        if (_this3._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
          _this3.touchStartX = event.clientX;
XhmikosR's avatar
Dist    
XhmikosR committed
1323
        } else if (!_this3._pointerEvent) {
XhmikosR's avatar
XhmikosR committed
1324
          _this3.touchStartX = event.touches[0].clientX;
Mark Otto's avatar
dist    
Mark Otto committed
1325
1326
        }
      };
Mark Otto's avatar
dist  
Mark Otto committed
1327

XhmikosR's avatar
Dist    
XhmikosR committed
1328
1329
      var move = function move(event) {
        // ensure swiping with one touch and not pinching
XhmikosR's avatar
XhmikosR committed
1330
        if (event.touches && event.touches.length > 1) {
XhmikosR's avatar
Dist    
XhmikosR committed
1331
1332
          _this3.touchDeltaX = 0;
        } else {
XhmikosR's avatar
XhmikosR committed
1333
          _this3.touchDeltaX = event.touches[0].clientX - _this3.touchStartX;
XhmikosR's avatar
Dist    
XhmikosR committed
1334
        }
Mark Otto's avatar
dist    
Mark Otto committed
1335
      };
Mark Otto's avatar
dist    
Mark Otto committed
1336

XhmikosR's avatar
Dist    
XhmikosR committed
1337
      var end = function end(event) {
XhmikosR's avatar
XhmikosR committed
1338
1339
        if (_this3._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
          _this3.touchDeltaX = event.clientX - _this3.touchStartX;
XhmikosR's avatar
Dist    
XhmikosR committed
1340
1341
1342
        }

        _this3._handleSwipe();
Mark Otto's avatar
dist    
Mark Otto committed
1343

XhmikosR's avatar
Dist    
XhmikosR committed
1344
1345
1346
1347
1348
1349
1350
1351
1352
        if (_this3._config.pause === 'hover') {
          // 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
          _this3.pause();
Mark Otto's avatar
dist  
Mark Otto committed
1353

XhmikosR's avatar
Dist    
XhmikosR committed
1354
1355
1356
          if (_this3.touchTimeout) {
            clearTimeout(_this3.touchTimeout);
          }
Mark Otto's avatar
dist  
Mark Otto committed
1357

XhmikosR's avatar
Dist    
XhmikosR committed
1358
1359
1360
          _this3.touchTimeout = setTimeout(function (event) {
            return _this3.cycle(event);
          }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
Mark Otto's avatar
dist    
Mark Otto committed
1361
1362
        }
      };
Mark Otto's avatar
dist    
Mark Otto committed
1363

XhmikosR's avatar
XhmikosR committed
1364
1365
      SelectorEngine.find(SELECTOR_ITEM_IMG, this._element).forEach(function (itemImg) {
        EventHandler.on(itemImg, EVENT_DRAG_START, function (e) {
XhmikosR's avatar
XhmikosR committed
1366
1367
          return e.preventDefault();
        });
XhmikosR's avatar
Dist    
XhmikosR committed
1368
      });
Mark Otto's avatar
dist    
Mark Otto committed
1369

XhmikosR's avatar
Dist    
XhmikosR committed
1370
      if (this._pointerEvent) {
XhmikosR's avatar
XhmikosR committed
1371
        EventHandler.on(this._element, EVENT_POINTERDOWN, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1372
1373
          return start(event);
        });
XhmikosR's avatar
XhmikosR committed
1374
        EventHandler.on(this._element, EVENT_POINTERUP, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1375
1376
          return end(event);
        });
Mark Otto's avatar
dist    
Mark Otto committed
1377

XhmikosR's avatar
XhmikosR committed
1378
        this._element.classList.add(CLASS_NAME_POINTER_EVENT);
XhmikosR's avatar
Dist    
XhmikosR committed
1379
      } else {
XhmikosR's avatar
XhmikosR committed
1380
        EventHandler.on(this._element, EVENT_TOUCHSTART, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1381
          return start(event);
Mark Otto's avatar
dist    
Mark Otto committed
1382
        });
XhmikosR's avatar
XhmikosR committed
1383
        EventHandler.on(this._element, EVENT_TOUCHMOVE, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1384
1385
          return move(event);
        });
XhmikosR's avatar
XhmikosR committed
1386
        EventHandler.on(this._element, EVENT_TOUCHEND, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1387
1388
1389
1390
          return end(event);
        });
      }
    };
Mark Otto's avatar
dist  
Mark Otto committed
1391

XhmikosR's avatar
Dist    
XhmikosR committed
1392
1393
1394
1395
    _proto._keydown = function _keydown(event) {
      if (/input|textarea/i.test(event.target.tagName)) {
        return;
      }
Mark Otto's avatar
dist  
Mark Otto committed
1396

XhmikosR's avatar
XhmikosR committed
1397
1398
      switch (event.key) {
        case ARROW_LEFT_KEY:
XhmikosR's avatar
Dist    
XhmikosR committed
1399
1400
1401
          event.preventDefault();
          this.prev();
          break;
Mark Otto's avatar
dist  
Mark Otto committed
1402

XhmikosR's avatar
XhmikosR committed
1403
        case ARROW_RIGHT_KEY:
XhmikosR's avatar
Dist    
XhmikosR committed
1404
1405
1406
1407
1408
          event.preventDefault();
          this.next();
          break;
      }
    };
Mark Otto's avatar
dist  
Mark Otto committed
1409

XhmikosR's avatar
Dist    
XhmikosR committed
1410
    _proto._getItemIndex = function _getItemIndex(element) {
XhmikosR's avatar
XhmikosR committed
1411
      this._items = element && element.parentNode ? SelectorEngine.find(SELECTOR_ITEM, element.parentNode) : [];
XhmikosR's avatar
Dist    
XhmikosR committed
1412
1413
      return this._items.indexOf(element);
    };
Mark Otto's avatar
dist    
Mark Otto committed
1414

XhmikosR's avatar
Dist    
XhmikosR committed
1415
    _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
XhmikosR's avatar
XhmikosR committed
1416
1417
      var isNextDirection = direction === DIRECTION_NEXT;
      var isPrevDirection = direction === DIRECTION_PREV;
Mark Otto's avatar
dist    
Mark Otto committed
1418

XhmikosR's avatar
Dist    
XhmikosR committed
1419
      var activeIndex = this._getItemIndex(activeElement);
Mark Otto's avatar
dist    
Mark Otto committed
1420

XhmikosR's avatar
Dist    
XhmikosR committed
1421
1422
      var lastItemIndex = this._items.length - 1;
      var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
Mark Otto's avatar
dist  
Mark Otto committed
1423

XhmikosR's avatar
Dist    
XhmikosR committed
1424
1425
1426
      if (isGoingToWrap && !this._config.wrap) {
        return activeElement;
      }
Mark Otto's avatar
dist  
Mark Otto committed
1427

XhmikosR's avatar
XhmikosR committed
1428
      var delta = direction === DIRECTION_PREV ? -1 : 1;
XhmikosR's avatar
Dist    
XhmikosR committed
1429
1430
1431
      var itemIndex = (activeIndex + delta) % this._items.length;
      return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
    };
Mark Otto's avatar
dist  
Mark Otto committed
1432

XhmikosR's avatar
Dist    
XhmikosR committed
1433
1434
    _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
      var targetIndex = this._getItemIndex(relatedTarget);
Mark Otto's avatar
dist  
Mark Otto committed
1435

XhmikosR's avatar
XhmikosR committed
1436
      var fromIndex = this._getItemIndex(SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element));
Mark Otto's avatar
dist    
Mark Otto committed
1437

XhmikosR's avatar
XhmikosR committed
1438
      return EventHandler.trigger(this._element, EVENT_SLIDE, {
XhmikosR's avatar
Dist    
XhmikosR committed
1439
1440
1441
1442
1443
1444
        relatedTarget: relatedTarget,
        direction: eventDirectionName,
        from: fromIndex,
        to: targetIndex
      });
    };
Mark Otto's avatar
dist  
Mark Otto committed
1445

XhmikosR's avatar
Dist    
XhmikosR committed
1446
1447
    _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
      if (this._indicatorsElement) {
XhmikosR's avatar
XhmikosR committed
1448
        var indicators = SelectorEngine.find(SELECTOR_ACTIVE, this._indicatorsElement);
XhmikosR's avatar
XhmikosR committed
1449
1450

        for (var i = 0; i < indicators.length; i++) {
XhmikosR's avatar
XhmikosR committed
1451
          indicators[i].classList.remove(CLASS_NAME_ACTIVE$1);
XhmikosR's avatar
XhmikosR committed
1452
        }
Mark Otto's avatar
dist  
Mark Otto committed
1453

XhmikosR's avatar
Dist    
XhmikosR committed
1454
        var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
Mark Otto's avatar
dist  
Mark Otto committed
1455

XhmikosR's avatar
Dist    
XhmikosR committed
1456
        if (nextIndicator) {
XhmikosR's avatar
XhmikosR committed
1457
          nextIndicator.classList.add(CLASS_NAME_ACTIVE$1);
Mark Otto's avatar
dist    
Mark Otto committed
1458
        }
XhmikosR's avatar
Dist    
XhmikosR committed
1459
1460
      }
    };
Mark Otto's avatar
dist  
Mark Otto committed
1461

XhmikosR's avatar
Dist    
XhmikosR committed
1462
1463
    _proto._slide = function _slide(direction, element) {
      var _this4 = this;
Mark Otto's avatar
dist  
Mark Otto committed
1464

XhmikosR's avatar
XhmikosR committed
1465
      var activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
Mark Otto's avatar
dist  
Mark Otto committed
1466

XhmikosR's avatar
Dist    
XhmikosR committed
1467
      var activeElementIndex = this._getItemIndex(activeElement);
Mark Otto's avatar
dist    
Mark Otto committed
1468

XhmikosR's avatar
Dist    
XhmikosR committed
1469
      var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
Mark Otto's avatar
dist    
Mark Otto committed
1470

XhmikosR's avatar
Dist    
XhmikosR committed
1471
      var nextElementIndex = this._getItemIndex(nextElement);
Mark Otto's avatar
dist  
Mark Otto committed
1472

XhmikosR's avatar
Dist    
XhmikosR committed
1473
1474
1475
1476
      var isCycling = Boolean(this._interval);
      var directionalClassName;
      var orderClassName;
      var eventDirectionName;
Mark Otto's avatar
dist  
Mark Otto committed
1477

XhmikosR's avatar
XhmikosR committed
1478
1479
1480
1481
      if (direction === DIRECTION_NEXT) {
        directionalClassName = CLASS_NAME_LEFT;
        orderClassName = CLASS_NAME_NEXT;
        eventDirectionName = DIRECTION_LEFT;
XhmikosR's avatar
Dist    
XhmikosR committed
1482
      } else {
XhmikosR's avatar
XhmikosR committed
1483
1484
1485
        directionalClassName = CLASS_NAME_RIGHT;
        orderClassName = CLASS_NAME_PREV;
        eventDirectionName = DIRECTION_RIGHT;
XhmikosR's avatar
Dist    
XhmikosR committed
1486
      }
Mark Otto's avatar
dist  
Mark Otto committed
1487

XhmikosR's avatar
XhmikosR committed
1488
      if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE$1)) {
XhmikosR's avatar
Dist    
XhmikosR committed
1489
1490
1491
        this._isSliding = false;
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
1492

XhmikosR's avatar
Dist    
XhmikosR committed
1493
      var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
Mark Otto's avatar
dist  
Mark Otto committed
1494

XhmikosR's avatar
XhmikosR committed
1495
      if (slideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
1496
1497
        return;
      }
Mark Otto's avatar
dist  
Mark Otto committed
1498

XhmikosR's avatar
Dist    
XhmikosR committed
1499
1500
1501
1502
      if (!activeElement || !nextElement) {
        // Some weirdness is happening, so we bail
        return;
      }
Mark Otto's avatar
dist  
Mark Otto committed
1503

XhmikosR's avatar
Dist    
XhmikosR committed
1504
      this._isSliding = true;
Mark Otto's avatar
dist    
Mark Otto committed
1505

XhmikosR's avatar
Dist    
XhmikosR committed
1506
1507
1508
      if (isCycling) {
        this.pause();
      }
Mark Otto's avatar
dist  
Mark Otto committed
1509

XhmikosR's avatar
Dist    
XhmikosR committed
1510
      this._setActiveIndicatorElement(nextElement);
Mark Otto's avatar
dist    
Mark Otto committed
1511

XhmikosR's avatar
XhmikosR committed
1512
      if (this._element.classList.contains(CLASS_NAME_SLIDE)) {
XhmikosR's avatar
XhmikosR committed
1513
1514
1515
1516
        nextElement.classList.add(orderClassName);
        reflow(nextElement);
        activeElement.classList.add(directionalClassName);
        nextElement.classList.add(directionalClassName);
XhmikosR's avatar
Dist    
XhmikosR committed
1517
1518
1519
1520
1521
1522
1523
        var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);

        if (nextElementInterval) {
          this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
          this._config.interval = nextElementInterval;
        } else {
          this._config.interval = this._config.defaultInterval || this._config.interval;
Mark Otto's avatar
dist  
Mark Otto committed
1524
1525
        }

XhmikosR's avatar
XhmikosR committed
1526
1527
        var transitionDuration = getTransitionDurationFromElement(activeElement);
        EventHandler.one(activeElement, TRANSITION_END, function () {
XhmikosR's avatar
XhmikosR committed
1528
          nextElement.classList.remove(directionalClassName, orderClassName);
XhmikosR's avatar
XhmikosR committed
1529
          nextElement.classList.add(CLASS_NAME_ACTIVE$1);
XhmikosR's avatar
XhmikosR committed
1530
          activeElement.classList.remove(CLASS_NAME_ACTIVE$1, orderClassName, directionalClassName);
XhmikosR's avatar
Dist    
XhmikosR committed
1531
1532
          _this4._isSliding = false;
          setTimeout(function () {
XhmikosR's avatar
XhmikosR committed
1533
            EventHandler.trigger(_this4._element, EVENT_SLID, {
XhmikosR's avatar
XhmikosR committed
1534
1535
1536
1537
1538
              relatedTarget: nextElement,
              direction: eventDirectionName,
              from: activeElementIndex,
              to: nextElementIndex
            });
XhmikosR's avatar
Dist    
XhmikosR committed
1539
          }, 0);
XhmikosR's avatar
XhmikosR committed
1540
1541
        });
        emulateTransitionEnd(activeElement, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
1542
      } else {
XhmikosR's avatar
XhmikosR committed
1543
1544
        activeElement.classList.remove(CLASS_NAME_ACTIVE$1);
        nextElement.classList.add(CLASS_NAME_ACTIVE$1);
XhmikosR's avatar
Dist    
XhmikosR committed
1545
        this._isSliding = false;
XhmikosR's avatar
XhmikosR committed
1546
        EventHandler.trigger(this._element, EVENT_SLID, {
XhmikosR's avatar
XhmikosR committed
1547
1548
1549
1550
1551
          relatedTarget: nextElement,
          direction: eventDirectionName,
          from: activeElementIndex,
          to: nextElementIndex
        });
XhmikosR's avatar
Dist    
XhmikosR committed
1552
1553
1554
1555
1556
      }

      if (isCycling) {
        this.cycle();
      }
Mark Otto's avatar
Mark Otto committed
1557
1558
    } // Static
    ;
Mark Otto's avatar
dist  
Mark Otto committed
1559

XhmikosR's avatar
XhmikosR committed
1560
    Carousel.carouselInterface = function carouselInterface(element, config) {
XhmikosR's avatar
XhmikosR committed
1561
      var data = Data.getData(element, DATA_KEY$2);
Mark Otto's avatar
dist  
Mark Otto committed
1562

XhmikosR's avatar
XhmikosR committed
1563
      var _config = _extends({}, Default, Manipulator.getDataAttributes(element));
Mark Otto's avatar
dist  
Mark Otto committed
1564

XhmikosR's avatar
XhmikosR committed
1565
      if (typeof config === 'object') {
XhmikosR's avatar
XhmikosR committed
1566
        _config = _extends({}, _config, config);
XhmikosR's avatar
XhmikosR committed
1567
      }
Mark Otto's avatar
dist  
Mark Otto committed
1568

XhmikosR's avatar
XhmikosR committed
1569
      var action = typeof config === 'string' ? config : _config.slide;
Mark Otto's avatar
dist  
Mark Otto committed
1570

XhmikosR's avatar
XhmikosR committed
1571
1572
1573
1574
1575
1576
1577
1578
      if (!data) {
        data = new Carousel(element, _config);
      }

      if (typeof config === 'number') {
        data.to(config);
      } else if (typeof action === 'string') {
        if (typeof data[action] === 'undefined') {
XhmikosR's avatar
Dist.    
XhmikosR committed
1579
          throw new TypeError("No method named \"" + action + "\"");
Mark Otto's avatar
dist    
Mark Otto committed
1580
        }
Mark Otto's avatar
dist  
Mark Otto committed
1581

XhmikosR's avatar
XhmikosR committed
1582
1583
1584
1585
1586
1587
        data[action]();
      } else if (_config.interval && _config.ride) {
        data.pause();
        data.cycle();
      }
    };
Mark Otto's avatar
dist  
Mark Otto committed
1588

XhmikosR's avatar
XhmikosR committed
1589
    Carousel.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
XhmikosR committed
1590
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
1591
        Carousel.carouselInterface(this, config);
XhmikosR's avatar
Dist    
XhmikosR committed
1592
1593
      });
    };
Mark Otto's avatar
dist  
Mark Otto committed
1594

XhmikosR's avatar
XhmikosR committed
1595
1596
    Carousel.dataApiClickHandler = function dataApiClickHandler(event) {
      var target = getElementFromSelector(this);
XhmikosR's avatar
Dist    
XhmikosR committed
1597

XhmikosR's avatar
XhmikosR committed
1598
      if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
XhmikosR's avatar
Dist    
XhmikosR committed
1599
1600
        return;
      }
Mark Otto's avatar
dist  
Mark Otto committed
1601

XhmikosR's avatar
XhmikosR committed
1602
      var config = _extends({}, Manipulator.getDataAttributes(target), Manipulator.getDataAttributes(this));
Mark Otto's avatar
dist    
Mark Otto committed
1603

XhmikosR's avatar
Dist    
XhmikosR committed
1604
      var slideIndex = this.getAttribute('data-slide-to');
Mark Otto's avatar
dist    
Mark Otto committed
1605

XhmikosR's avatar
Dist    
XhmikosR committed
1606
1607
      if (slideIndex) {
        config.interval = false;
Mark Otto's avatar
dist    
Mark Otto committed
1608
      }
Mark Otto's avatar
dist    
Mark Otto committed
1609

XhmikosR's avatar
XhmikosR committed
1610
      Carousel.carouselInterface(target, config);
Mark Otto's avatar
dist  
Mark Otto committed
1611

XhmikosR's avatar
Dist    
XhmikosR committed
1612
      if (slideIndex) {
XhmikosR's avatar
XhmikosR committed
1613
        Data.getData(target, DATA_KEY$2).to(slideIndex);
XhmikosR's avatar
Dist    
XhmikosR committed
1614
1615
1616
      }

      event.preventDefault();
Mark Otto's avatar
dist    
Mark Otto committed
1617
    };
Mark Otto's avatar
dist  
Mark Otto committed
1618

XhmikosR's avatar
XhmikosR committed
1619
    Carousel.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
1620
1621
1622
      return Data.getData(element, DATA_KEY$2);
    };

XhmikosR's avatar
Dist    
XhmikosR committed
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
    _createClass(Carousel, null, [{
      key: "VERSION",
      get: function get() {
        return VERSION$2;
      }
    }, {
      key: "Default",
      get: function get() {
        return Default;
      }
    }]);

Mark Otto's avatar
dist    
Mark Otto committed
1635
    return Carousel;
XhmikosR's avatar
Dist    
XhmikosR committed
1636
1637
1638
1639
1640
1641
1642
1643
  }();
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */


XhmikosR's avatar
XhmikosR committed
1644
1645
1646
  EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler);
  EventHandler.on(window, EVENT_LOAD_DATA_API, function () {
    var carousels = SelectorEngine.find(SELECTOR_DATA_RIDE);
XhmikosR's avatar
Dist    
XhmikosR committed
1647
1648

    for (var i = 0, len = carousels.length; i < len; i++) {
XhmikosR's avatar
XhmikosR committed
1649
      Carousel.carouselInterface(carousels[i], Data.getData(carousels[i], DATA_KEY$2));
XhmikosR's avatar
Dist    
XhmikosR committed
1650
1651
    }
  });
XhmikosR's avatar
XhmikosR committed
1652
  var $$3 = getjQuery();
XhmikosR's avatar
Dist    
XhmikosR committed
1653
1654
1655
1656
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
1657
   * add .carousel to jQuery only if jQuery is present
XhmikosR's avatar
Dist    
XhmikosR committed
1658
1659
   */

1660
1661
  /* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
1662
1663
1664
1665
  if ($$3) {
    var JQUERY_NO_CONFLICT$2 = $$3.fn[NAME$2];
    $$3.fn[NAME$2] = Carousel.jQueryInterface;
    $$3.fn[NAME$2].Constructor = Carousel;
XhmikosR's avatar
Dist    
XhmikosR committed
1666

XhmikosR's avatar
XhmikosR committed
1667
1668
1669
    $$3.fn[NAME$2].noConflict = function () {
      $$3.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
      return Carousel.jQueryInterface;
XhmikosR's avatar
XhmikosR committed
1670
1671
    };
  }
Mark Otto's avatar
dist  
Mark Otto committed
1672

XhmikosR's avatar
Dist    
XhmikosR committed
1673
1674
1675
1676
1677
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */
Mark Otto's avatar
dist  
Mark Otto committed
1678

XhmikosR's avatar
Dist    
XhmikosR committed
1679
  var NAME$3 = 'collapse';
XhmikosR's avatar
XhmikosR committed
1680
  var VERSION$3 = '5.0.0-alpha2';
XhmikosR's avatar
Dist    
XhmikosR committed
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
  var DATA_KEY$3 = 'bs.collapse';
  var EVENT_KEY$3 = "." + DATA_KEY$3;
  var DATA_API_KEY$3 = '.data-api';
  var Default$1 = {
    toggle: true,
    parent: ''
  };
  var DefaultType$1 = {
    toggle: 'boolean',
    parent: '(string|element)'
  };
XhmikosR's avatar
XhmikosR committed
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
  var EVENT_SHOW = "show" + EVENT_KEY$3;
  var EVENT_SHOWN = "shown" + EVENT_KEY$3;
  var EVENT_HIDE = "hide" + EVENT_KEY$3;
  var EVENT_HIDDEN = "hidden" + EVENT_KEY$3;
  var EVENT_CLICK_DATA_API$3 = "click" + EVENT_KEY$3 + DATA_API_KEY$3;
  var CLASS_NAME_SHOW = 'show';
  var CLASS_NAME_COLLAPSE = 'collapse';
  var CLASS_NAME_COLLAPSING = 'collapsing';
  var CLASS_NAME_COLLAPSED = 'collapsed';
  var WIDTH = 'width';
  var HEIGHT = 'height';
  var SELECTOR_ACTIVES = '.show, .collapsing';
  var SELECTOR_DATA_TOGGLE$1 = '[data-toggle="collapse"]';
XhmikosR's avatar
XhmikosR committed
1705
1706
1707
1708
1709
  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */
Mark Otto's avatar
dist    
Mark Otto committed
1710

XhmikosR's avatar
XhmikosR committed
1711
  var Collapse = /*#__PURE__*/function () {
XhmikosR's avatar
Dist    
XhmikosR committed
1712
1713
1714
1715
    function Collapse(element, config) {
      this._isTransitioning = false;
      this._element = element;
      this._config = this._getConfig(config);
XhmikosR's avatar
XhmikosR committed
1716
1717
      this._triggerArray = SelectorEngine.find(SELECTOR_DATA_TOGGLE$1 + "[href=\"#" + element.id + "\"]," + (SELECTOR_DATA_TOGGLE$1 + "[data-target=\"#" + element.id + "\"]"));
      var toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$1);
XhmikosR's avatar
Dist    
XhmikosR committed
1718
1719
1720

      for (var i = 0, len = toggleList.length; i < len; i++) {
        var elem = toggleList[i];
XhmikosR's avatar
XhmikosR committed
1721
        var selector = getSelectorFromElement(elem);
XhmikosR's avatar
XhmikosR committed
1722
        var filterElement = SelectorEngine.find(selector).filter(function (foundElem) {
XhmikosR's avatar
Dist    
XhmikosR committed
1723
1724
          return foundElem === element;
        });
Mark Otto's avatar
dist  
Mark Otto committed
1725

XhmikosR's avatar
XhmikosR committed
1726
        if (selector !== null && filterElement.length) {
XhmikosR's avatar
Dist    
XhmikosR committed
1727
          this._selector = selector;
Mark Otto's avatar
dist  
Mark Otto committed
1728

XhmikosR's avatar
Dist    
XhmikosR committed
1729
          this._triggerArray.push(elem);
Mark Otto's avatar
dist    
Mark Otto committed
1730
        }
XhmikosR's avatar
Dist    
XhmikosR committed
1731
      }
Mark Otto's avatar
dist  
Mark Otto committed
1732

XhmikosR's avatar
Dist    
XhmikosR committed
1733
      this._parent = this._config.parent ? this._getParent() : null;
Mark Otto's avatar
dist  
Mark Otto committed
1734

XhmikosR's avatar
Dist    
XhmikosR committed
1735
1736
1737
      if (!this._config.parent) {
        this._addAriaAndCollapsedClass(this._element, this._triggerArray);
      }
Mark Otto's avatar
dist  
Mark Otto committed
1738

XhmikosR's avatar
Dist    
XhmikosR committed
1739
1740
1741
      if (this._config.toggle) {
        this.toggle();
      }
XhmikosR's avatar
XhmikosR committed
1742
1743

      Data.setData(element, DATA_KEY$3, this);
XhmikosR's avatar
Dist    
XhmikosR committed
1744
    } // Getters
Mark Otto's avatar
dist  
Mark Otto committed
1745
1746


XhmikosR's avatar
Dist    
XhmikosR committed
1747
    var _proto = Collapse.prototype;
Mark Otto's avatar
dist  
Mark Otto committed
1748

XhmikosR's avatar
Dist    
XhmikosR committed
1749
1750
    // Public
    _proto.toggle = function toggle() {
XhmikosR's avatar
XhmikosR committed
1751
      if (this._element.classList.contains(CLASS_NAME_SHOW)) {
XhmikosR's avatar
Dist    
XhmikosR committed
1752
1753
1754
1755
1756
        this.hide();
      } else {
        this.show();
      }
    };
Mark Otto's avatar
dist  
Mark Otto committed
1757

XhmikosR's avatar
Dist    
XhmikosR committed
1758
1759
    _proto.show = function show() {
      var _this = this;
Mark Otto's avatar
dist  
Mark Otto committed
1760

XhmikosR's avatar
XhmikosR committed
1761
      if (this._isTransitioning || this._element.classList.contains(CLASS_NAME_SHOW)) {
XhmikosR's avatar
Dist    
XhmikosR committed
1762
1763
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
1764

XhmikosR's avatar
Dist    
XhmikosR committed
1765
1766
      var actives;
      var activesData;
Mark Otto's avatar
dist    
Mark Otto committed
1767

XhmikosR's avatar
Dist    
XhmikosR committed
1768
      if (this._parent) {
XhmikosR's avatar
XhmikosR committed
1769
        actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent).filter(function (elem) {
XhmikosR's avatar
Dist    
XhmikosR committed
1770
1771
          if (typeof _this._config.parent === 'string') {
            return elem.getAttribute('data-parent') === _this._config.parent;
Mark Otto's avatar
dist    
Mark Otto committed
1772
          }
Mark Otto's avatar
dist  
Mark Otto committed
1773

XhmikosR's avatar
XhmikosR committed
1774
          return elem.classList.contains(CLASS_NAME_COLLAPSE);
XhmikosR's avatar
Dist    
XhmikosR committed
1775
        });
Mark Otto's avatar
dist    
Mark Otto committed
1776

XhmikosR's avatar
Dist    
XhmikosR committed
1777
1778
        if (actives.length === 0) {
          actives = null;
Mark Otto's avatar
dist  
Mark Otto committed
1779
        }
XhmikosR's avatar
Dist    
XhmikosR committed
1780
      }
Mark Otto's avatar
dist  
Mark Otto committed
1781

XhmikosR's avatar
XhmikosR committed
1782
1783
      var container = SelectorEngine.findOne(this._selector);

XhmikosR's avatar
Dist    
XhmikosR committed
1784
      if (actives) {
XhmikosR's avatar
XhmikosR committed
1785
1786
1787
1788
        var tempActiveData = actives.filter(function (elem) {
          return container !== elem;
        });
        activesData = tempActiveData[0] ? Data.getData(tempActiveData[0], DATA_KEY$3) : null;
Mark Otto's avatar
dist    
Mark Otto committed
1789

XhmikosR's avatar
Dist    
XhmikosR committed
1790
        if (activesData && activesData._isTransitioning) {
Mark Otto's avatar
dist    
Mark Otto committed
1791
1792
          return;
        }
XhmikosR's avatar
Dist    
XhmikosR committed
1793
      }
Mark Otto's avatar
dist  
Mark Otto committed
1794

XhmikosR's avatar
XhmikosR committed
1795
      var startEvent = EventHandler.trigger(this._element, EVENT_SHOW);
Mark Otto's avatar
dist  
Mark Otto committed
1796

XhmikosR's avatar
XhmikosR committed
1797
      if (startEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
1798
1799
        return;
      }
Mark Otto's avatar
dist  
Mark Otto committed
1800

XhmikosR's avatar
Dist    
XhmikosR committed
1801
      if (actives) {
XhmikosR's avatar
XhmikosR committed
1802
1803
        actives.forEach(function (elemActive) {
          if (container !== elemActive) {
XhmikosR's avatar
XhmikosR committed
1804
            Collapse.collapseInterface(elemActive, 'hide');
XhmikosR's avatar
XhmikosR committed
1805
          }
Mark Otto's avatar
dist  
Mark Otto committed
1806

XhmikosR's avatar
XhmikosR committed
1807
1808
1809
1810
          if (!activesData) {
            Data.setData(elemActive, DATA_KEY$3, null);
          }
        });
XhmikosR's avatar
Dist    
XhmikosR committed
1811
      }
Mark Otto's avatar
dist  
Mark Otto committed
1812

XhmikosR's avatar
Dist    
XhmikosR committed
1813
      var dimension = this._getDimension();
Mark Otto's avatar
dist  
Mark Otto committed
1814

XhmikosR's avatar
XhmikosR committed
1815
      this._element.classList.remove(CLASS_NAME_COLLAPSE);
XhmikosR's avatar
XhmikosR committed
1816

XhmikosR's avatar
XhmikosR committed
1817
      this._element.classList.add(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
XhmikosR committed
1818

XhmikosR's avatar
Dist    
XhmikosR committed
1819
      this._element.style[dimension] = 0;
Mark Otto's avatar
dist  
Mark Otto committed
1820

XhmikosR's avatar
Dist    
XhmikosR committed
1821
      if (this._triggerArray.length) {
XhmikosR's avatar
XhmikosR committed
1822
        this._triggerArray.forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
1823
          element.classList.remove(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
XhmikosR committed
1824
1825
          element.setAttribute('aria-expanded', true);
        });
XhmikosR's avatar
Dist    
XhmikosR committed
1826
      }
Mark Otto's avatar
dist  
Mark Otto committed
1827

XhmikosR's avatar
Dist    
XhmikosR committed
1828
      this.setTransitioning(true);
Mark Otto's avatar
dist  
Mark Otto committed
1829

XhmikosR's avatar
Dist    
XhmikosR committed
1830
      var complete = function complete() {
XhmikosR's avatar
XhmikosR committed
1831
        _this._element.classList.remove(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
XhmikosR committed
1832

XhmikosR's avatar
XhmikosR committed
1833
        _this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW);
XhmikosR's avatar
XhmikosR committed
1834

XhmikosR's avatar
Dist    
XhmikosR committed
1835
1836
1837
1838
        _this._element.style[dimension] = '';

        _this.setTransitioning(false);

XhmikosR's avatar
XhmikosR committed
1839
        EventHandler.trigger(_this._element, EVENT_SHOWN);
Mark Otto's avatar
dist    
Mark Otto committed
1840
      };
Mark Otto's avatar
dist  
Mark Otto committed
1841

XhmikosR's avatar
Dist    
XhmikosR committed
1842
1843
      var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
      var scrollSize = "scroll" + capitalizedDimension;
XhmikosR's avatar
XhmikosR committed
1844
1845
1846
      var transitionDuration = getTransitionDurationFromElement(this._element);
      EventHandler.one(this._element, TRANSITION_END, complete);
      emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
1847
1848
      this._element.style[dimension] = this._element[scrollSize] + "px";
    };
Mark Otto's avatar
dist  
Mark Otto committed
1849

XhmikosR's avatar
Dist    
XhmikosR committed
1850
1851
1852
    _proto.hide = function hide() {
      var _this2 = this;

XhmikosR's avatar
XhmikosR committed
1853
      if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW)) {
XhmikosR's avatar
Dist    
XhmikosR committed
1854
1855
        return;
      }
Mark Otto's avatar
dist  
Mark Otto committed
1856

XhmikosR's avatar
XhmikosR committed
1857
      var startEvent = EventHandler.trigger(this._element, EVENT_HIDE);
Mark Otto's avatar
dist    
Mark Otto committed
1858

XhmikosR's avatar
XhmikosR committed
1859
      if (startEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
1860
1861
        return;
      }
Mark Otto's avatar
dist  
Mark Otto committed
1862

XhmikosR's avatar
Dist    
XhmikosR committed
1863
      var dimension = this._getDimension();
Mark Otto's avatar
dist  
Mark Otto committed
1864

XhmikosR's avatar
Dist    
XhmikosR committed
1865
      this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
XhmikosR's avatar
XhmikosR committed
1866
1867
      reflow(this._element);

XhmikosR's avatar
XhmikosR committed
1868
      this._element.classList.add(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
XhmikosR committed
1869

XhmikosR's avatar
XhmikosR committed
1870
      this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW);
XhmikosR's avatar
XhmikosR committed
1871

XhmikosR's avatar
Dist    
XhmikosR committed
1872
      var triggerArrayLength = this._triggerArray.length;
Mark Otto's avatar
dist  
Mark Otto committed
1873

XhmikosR's avatar
Dist    
XhmikosR committed
1874
1875
1876
      if (triggerArrayLength > 0) {
        for (var i = 0; i < triggerArrayLength; i++) {
          var trigger = this._triggerArray[i];
XhmikosR's avatar
XhmikosR committed
1877
          var elem = getElementFromSelector(trigger);
Mark Otto's avatar
dist    
Mark Otto committed
1878

XhmikosR's avatar
XhmikosR committed
1879
1880
          if (elem && !elem.classList.contains(CLASS_NAME_SHOW)) {
            trigger.classList.add(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
XhmikosR committed
1881
            trigger.setAttribute('aria-expanded', false);
Mark Otto's avatar
dist  
Mark Otto committed
1882
1883
          }
        }
XhmikosR's avatar
Dist    
XhmikosR committed
1884
      }
Mark Otto's avatar
dist  
Mark Otto committed
1885

XhmikosR's avatar
Dist    
XhmikosR committed
1886
      this.setTransitioning(true);
Mark Otto's avatar
dist  
Mark Otto committed
1887

XhmikosR's avatar
Dist    
XhmikosR committed
1888
1889
      var complete = function complete() {
        _this2.setTransitioning(false);
Mark Otto's avatar
dist  
Mark Otto committed
1890

XhmikosR's avatar
XhmikosR committed
1891
        _this2._element.classList.remove(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
XhmikosR committed
1892

XhmikosR's avatar
XhmikosR committed
1893
        _this2._element.classList.add(CLASS_NAME_COLLAPSE);
XhmikosR's avatar
XhmikosR committed
1894

XhmikosR's avatar
XhmikosR committed
1895
        EventHandler.trigger(_this2._element, EVENT_HIDDEN);
Mark Otto's avatar
dist    
Mark Otto committed
1896
      };
Mark Otto's avatar
dist  
Mark Otto committed
1897

XhmikosR's avatar
Dist    
XhmikosR committed
1898
      this._element.style[dimension] = '';
XhmikosR's avatar
XhmikosR committed
1899
1900
1901
      var transitionDuration = getTransitionDurationFromElement(this._element);
      EventHandler.one(this._element, TRANSITION_END, complete);
      emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
1902
    };
Mark Otto's avatar
dist  
Mark Otto committed
1903

XhmikosR's avatar
Dist    
XhmikosR committed
1904
1905
1906
    _proto.setTransitioning = function setTransitioning(isTransitioning) {
      this._isTransitioning = isTransitioning;
    };
Mark Otto's avatar
dist  
Mark Otto committed
1907

XhmikosR's avatar
Dist    
XhmikosR committed
1908
    _proto.dispose = function dispose() {
XhmikosR's avatar
XhmikosR committed
1909
      Data.removeData(this._element, DATA_KEY$3);
XhmikosR's avatar
Dist    
XhmikosR committed
1910
1911
1912
1913
1914
      this._config = null;
      this._parent = null;
      this._element = null;
      this._triggerArray = null;
      this._isTransitioning = null;
Mark Otto's avatar
Mark Otto committed
1915
1916
    } // Private
    ;
Mark Otto's avatar
dist    
Mark Otto committed
1917

XhmikosR's avatar
Dist    
XhmikosR committed
1918
    _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
1919
      config = _extends({}, Default$1, config);
XhmikosR's avatar
Dist    
XhmikosR committed
1920
      config.toggle = Boolean(config.toggle); // Coerce string values
Mark Otto's avatar
dist  
Mark Otto committed
1921

XhmikosR's avatar
XhmikosR committed
1922
      typeCheckConfig(NAME$3, config, DefaultType$1);
XhmikosR's avatar
Dist    
XhmikosR committed
1923
1924
      return config;
    };
Mark Otto's avatar
dist  
Mark Otto committed
1925

XhmikosR's avatar
Dist    
XhmikosR committed
1926
    _proto._getDimension = function _getDimension() {
XhmikosR's avatar
XhmikosR committed
1927
      return this._element.classList.contains(WIDTH) ? WIDTH : HEIGHT;
XhmikosR's avatar
Dist    
XhmikosR committed
1928
    };
Mark Otto's avatar
dist  
Mark Otto committed
1929

XhmikosR's avatar
Dist    
XhmikosR committed
1930
1931
    _proto._getParent = function _getParent() {
      var _this3 = this;
Mark Otto's avatar
dist  
Mark Otto committed
1932

XhmikosR's avatar
Dist.    
XhmikosR committed
1933
      var parent = this._config.parent;
Mark Otto's avatar
dist    
Mark Otto committed
1934

XhmikosR's avatar
Dist.    
XhmikosR committed
1935
1936
1937
1938
      if (isElement(parent)) {
        // it's a jQuery object
        if (typeof parent.jquery !== 'undefined' || typeof parent[0] !== 'undefined') {
          parent = parent[0];
XhmikosR's avatar
Dist    
XhmikosR committed
1939
1940
        }
      } else {
XhmikosR's avatar
Dist.    
XhmikosR committed
1941
        parent = SelectorEngine.findOne(parent);
XhmikosR's avatar
Dist    
XhmikosR committed
1942
      }
Mark Otto's avatar
dist  
Mark Otto committed
1943

XhmikosR's avatar
XhmikosR committed
1944
1945
      var selector = SELECTOR_DATA_TOGGLE$1 + "[data-parent=\"" + parent + "\"]";
      SelectorEngine.find(selector, parent).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
1946
        var selected = getElementFromSelector(element);
1947
1948

        _this3._addAriaAndCollapsedClass(selected, [element]);
XhmikosR's avatar
Dist    
XhmikosR committed
1949
1950
1951
      });
      return parent;
    };
Mark Otto's avatar
dist  
Mark Otto committed
1952

XhmikosR's avatar
XhmikosR committed
1953
    _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
XhmikosR's avatar
XhmikosR committed
1954
1955
1956
      if (!element || !triggerArray.length) {
        return;
      }
Mark Otto's avatar
dist  
Mark Otto committed
1957

XhmikosR's avatar
XhmikosR committed
1958
1959
1960
1961
1962
1963
      var isOpen = element.classList.contains(CLASS_NAME_SHOW);
      triggerArray.forEach(function (elem) {
        if (isOpen) {
          elem.classList.remove(CLASS_NAME_COLLAPSED);
        } else {
          elem.classList.add(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
XhmikosR committed
1964
        }
XhmikosR's avatar
XhmikosR committed
1965
1966
1967

        elem.setAttribute('aria-expanded', isOpen);
      });
Mark Otto's avatar
Mark Otto committed
1968
1969
    } // Static
    ;
Mark Otto's avatar
dist  
Mark Otto committed
1970

XhmikosR's avatar
XhmikosR committed
1971
    Collapse.collapseInterface = function collapseInterface(element, config) {
XhmikosR's avatar
XhmikosR committed
1972
      var data = Data.getData(element, DATA_KEY$3);
Mark Otto's avatar
dist  
Mark Otto committed
1973

XhmikosR's avatar
XhmikosR committed
1974
      var _config = _extends({}, Default$1, Manipulator.getDataAttributes(element), typeof config === 'object' && config ? config : {});
Mark Otto's avatar
dist  
Mark Otto committed
1975

XhmikosR's avatar
XhmikosR committed
1976
      if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) {
XhmikosR's avatar
XhmikosR committed
1977
1978
        _config.toggle = false;
      }
Mark Otto's avatar
dist    
Mark Otto committed
1979

XhmikosR's avatar
XhmikosR committed
1980
1981
1982
1983
1984
1985
      if (!data) {
        data = new Collapse(element, _config);
      }

      if (typeof config === 'string') {
        if (typeof data[config] === 'undefined') {
XhmikosR's avatar
Dist.    
XhmikosR committed
1986
          throw new TypeError("No method named \"" + config + "\"");
XhmikosR's avatar
Dist    
XhmikosR committed
1987
        }
Mark Otto's avatar
dist  
Mark Otto committed
1988

XhmikosR's avatar
XhmikosR committed
1989
1990
1991
        data[config]();
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
1992

XhmikosR's avatar
XhmikosR committed
1993
    Collapse.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
XhmikosR committed
1994
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
1995
        Collapse.collapseInterface(this, config);
XhmikosR's avatar
Dist    
XhmikosR committed
1996
1997
      });
    };
Mark Otto's avatar
dist  
Mark Otto committed
1998

XhmikosR's avatar
XhmikosR committed
1999
    Collapse.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
2000
      return Data.getData(element, DATA_KEY$3);
For faster browsing, not all history is shown. View entire blame