bootstrap.esm.js 140 KB
Newer Older
XhmikosR's avatar
Dist.  
XhmikosR committed
1001

XhmikosR's avatar
XhmikosR committed
1002
var NAME$2 = 'carousel';
XhmikosR's avatar
XhmikosR committed
1003
var VERSION$2 = '5.0.0-alpha3';
XhmikosR's avatar
XhmikosR committed
1004
1005
1006
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
1007
1008
var ARROW_LEFT_KEY = 'ArrowLeft';
var ARROW_RIGHT_KEY = 'ArrowRight';
XhmikosR's avatar
XhmikosR committed
1009
var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
XhmikosR's avatar
Dist.  
XhmikosR committed
1010

XhmikosR's avatar
XhmikosR committed
1011
1012
var SWIPE_THRESHOLD = 40;
var Default = {
XhmikosR's avatar
Dist.  
XhmikosR committed
1013
1014
1015
1016
1017
1018
1019
  interval: 5000,
  keyboard: true,
  slide: false,
  pause: 'hover',
  wrap: true,
  touch: true
};
XhmikosR's avatar
XhmikosR committed
1020
var DefaultType = {
XhmikosR's avatar
Dist.  
XhmikosR committed
1021
1022
1023
1024
1025
1026
1027
  interval: '(number|boolean)',
  keyboard: 'boolean',
  slide: '(boolean|string)',
  pause: '(string|boolean)',
  wrap: 'boolean',
  touch: 'boolean'
};
XhmikosR's avatar
XhmikosR committed
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
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
1053
var SELECTOR_ACTIVE = '.active';
XhmikosR's avatar
XhmikosR committed
1054
1055
1056
1057
1058
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';
XhmikosR's avatar
XhmikosR committed
1059
1060
var SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]';
var SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]';
XhmikosR's avatar
XhmikosR committed
1061
var PointerType = {
XhmikosR's avatar
Dist.  
XhmikosR committed
1062
1063
1064
  TOUCH: 'touch',
  PEN: 'pen'
};
XhmikosR's avatar
XhmikosR committed
1065
1066
1067
1068
1069
/**
 * ------------------------------------------------------------------------
 * Class Definition
 * ------------------------------------------------------------------------
 */
XhmikosR's avatar
Dist.  
XhmikosR committed
1070

XhmikosR's avatar
XhmikosR committed
1071
var Carousel = /*#__PURE__*/function () {
XhmikosR's avatar
XhmikosR committed
1072
  function Carousel(element, config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
    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
1083
    this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
XhmikosR's avatar
Dist.  
XhmikosR committed
1084
    this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
XhmikosR's avatar
XhmikosR committed
1085
    this._pointerEvent = Boolean(window.PointerEvent);
XhmikosR's avatar
Dist.  
XhmikosR committed
1086
1087
1088
1089
1090
1091
1092

    this._addEventListeners();

    Data.setData(element, DATA_KEY$2, this);
  } // Getters


XhmikosR's avatar
XhmikosR committed
1093
  var _proto = Carousel.prototype;
XhmikosR's avatar
Dist.  
XhmikosR committed
1094

XhmikosR's avatar
XhmikosR committed
1095
1096
  // Public
  _proto.next = function next() {
XhmikosR's avatar
Dist.  
XhmikosR committed
1097
    if (!this._isSliding) {
XhmikosR's avatar
XhmikosR committed
1098
      this._slide(DIRECTION_NEXT);
XhmikosR's avatar
Dist.  
XhmikosR committed
1099
    }
XhmikosR's avatar
XhmikosR committed
1100
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1101

XhmikosR's avatar
XhmikosR committed
1102
  _proto.nextWhenVisible = function nextWhenVisible() {
XhmikosR's avatar
Dist.  
XhmikosR committed
1103
1104
1105
1106
1107
    // Don't call next when the page isn't visible
    // or the carousel or its parent isn't visible
    if (!document.hidden && isVisible(this._element)) {
      this.next();
    }
XhmikosR's avatar
XhmikosR committed
1108
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1109

XhmikosR's avatar
XhmikosR committed
1110
  _proto.prev = function prev() {
XhmikosR's avatar
Dist.  
XhmikosR committed
1111
    if (!this._isSliding) {
XhmikosR's avatar
XhmikosR committed
1112
      this._slide(DIRECTION_PREV);
XhmikosR's avatar
Dist.  
XhmikosR committed
1113
    }
XhmikosR's avatar
XhmikosR committed
1114
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1115

XhmikosR's avatar
XhmikosR committed
1116
  _proto.pause = function pause(event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1117
1118
1119
1120
    if (!event) {
      this._isPaused = true;
    }

XhmikosR's avatar
XhmikosR committed
1121
    if (SelectorEngine.findOne(SELECTOR_NEXT_PREV, this._element)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1122
1123
1124
1125
1126
1127
      triggerTransitionEnd(this._element);
      this.cycle(true);
    }

    clearInterval(this._interval);
    this._interval = null;
XhmikosR's avatar
XhmikosR committed
1128
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1129

XhmikosR's avatar
XhmikosR committed
1130
  _proto.cycle = function cycle(event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
    if (!event) {
      this._isPaused = false;
    }

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

    if (this._config && this._config.interval && !this._isPaused) {
XhmikosR's avatar
XhmikosR committed
1141
1142
      this._updateInterval();

XhmikosR's avatar
Dist.  
XhmikosR committed
1143
1144
      this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
    }
XhmikosR's avatar
XhmikosR committed
1145
1146
1147
1148
  };

  _proto.to = function to(index) {
    var _this = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
1149

XhmikosR's avatar
XhmikosR committed
1150
    this._activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
XhmikosR's avatar
Dist.  
XhmikosR committed
1151

XhmikosR's avatar
XhmikosR committed
1152
    var activeIndex = this._getItemIndex(this._activeElement);
XhmikosR's avatar
Dist.  
XhmikosR committed
1153
1154
1155
1156
1157
1158

    if (index > this._items.length - 1 || index < 0) {
      return;
    }

    if (this._isSliding) {
XhmikosR's avatar
XhmikosR committed
1159
      EventHandler.one(this._element, EVENT_SLID, function () {
XhmikosR's avatar
XhmikosR committed
1160
1161
        return _this.to(index);
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
1162
1163
1164
1165
1166
1167
1168
1169
1170
      return;
    }

    if (activeIndex === index) {
      this.pause();
      this.cycle();
      return;
    }

XhmikosR's avatar
XhmikosR committed
1171
    var direction = index > activeIndex ? DIRECTION_NEXT : DIRECTION_PREV;
XhmikosR's avatar
Dist.  
XhmikosR committed
1172
1173

    this._slide(direction, this._items[index]);
XhmikosR's avatar
XhmikosR committed
1174
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1175

XhmikosR's avatar
XhmikosR committed
1176
  _proto.dispose = function dispose() {
XhmikosR's avatar
Dist.  
XhmikosR committed
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
    EventHandler.off(this._element, EVENT_KEY$2);
    Data.removeData(this._element, DATA_KEY$2);
    this._items = null;
    this._config = null;
    this._element = null;
    this._interval = null;
    this._isPaused = null;
    this._isSliding = null;
    this._activeElement = null;
    this._indicatorsElement = null;
  } // Private
XhmikosR's avatar
XhmikosR committed
1188
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
1189

XhmikosR's avatar
XhmikosR committed
1190
  _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
1191
    config = _extends({}, Default, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
1192
1193
    typeCheckConfig(NAME$2, config, DefaultType);
    return config;
XhmikosR's avatar
XhmikosR committed
1194
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1195

XhmikosR's avatar
XhmikosR committed
1196
1197
  _proto._handleSwipe = function _handleSwipe() {
    var absDeltax = Math.abs(this.touchDeltaX);
XhmikosR's avatar
Dist.  
XhmikosR committed
1198
1199
1200
1201
1202

    if (absDeltax <= SWIPE_THRESHOLD) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
1203
1204
    var direction = absDeltax / this.touchDeltaX;
    this.touchDeltaX = 0; // swipe left
XhmikosR's avatar
Dist.  
XhmikosR committed
1205
1206
1207
1208
1209
1210
1211
1212
1213

    if (direction > 0) {
      this.prev();
    } // swipe right


    if (direction < 0) {
      this.next();
    }
XhmikosR's avatar
XhmikosR committed
1214
1215
1216
1217
  };

  _proto._addEventListeners = function _addEventListeners() {
    var _this2 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
1218
1219

    if (this._config.keyboard) {
XhmikosR's avatar
XhmikosR committed
1220
      EventHandler.on(this._element, EVENT_KEYDOWN, function (event) {
XhmikosR's avatar
XhmikosR committed
1221
1222
        return _this2._keydown(event);
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
1223
1224
1225
    }

    if (this._config.pause === 'hover') {
XhmikosR's avatar
XhmikosR committed
1226
      EventHandler.on(this._element, EVENT_MOUSEENTER, function (event) {
XhmikosR's avatar
XhmikosR committed
1227
1228
        return _this2.pause(event);
      });
XhmikosR's avatar
XhmikosR committed
1229
      EventHandler.on(this._element, EVENT_MOUSELEAVE, function (event) {
XhmikosR's avatar
XhmikosR committed
1230
1231
        return _this2.cycle(event);
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
1232
1233
    }

1234
    if (this._config.touch && this._touchSupported) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1235
1236
      this._addTouchEventListeners();
    }
XhmikosR's avatar
XhmikosR committed
1237
1238
1239
1240
  };

  _proto._addTouchEventListeners = function _addTouchEventListeners() {
    var _this3 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
1241

XhmikosR's avatar
XhmikosR committed
1242
1243
1244
1245
1246
    var start = function start(event) {
      if (_this3._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
        _this3.touchStartX = event.clientX;
      } else if (!_this3._pointerEvent) {
        _this3.touchStartX = event.touches[0].clientX;
XhmikosR's avatar
Dist.  
XhmikosR committed
1247
1248
1249
      }
    };

XhmikosR's avatar
XhmikosR committed
1250
    var move = function move(event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1251
1252
      // ensure swiping with one touch and not pinching
      if (event.touches && event.touches.length > 1) {
XhmikosR's avatar
XhmikosR committed
1253
        _this3.touchDeltaX = 0;
XhmikosR's avatar
Dist.  
XhmikosR committed
1254
      } else {
XhmikosR's avatar
XhmikosR committed
1255
        _this3.touchDeltaX = event.touches[0].clientX - _this3.touchStartX;
XhmikosR's avatar
Dist.  
XhmikosR committed
1256
1257
1258
      }
    };

XhmikosR's avatar
XhmikosR committed
1259
1260
1261
    var end = function end(event) {
      if (_this3._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
        _this3.touchDeltaX = event.clientX - _this3.touchStartX;
XhmikosR's avatar
Dist.  
XhmikosR committed
1262
1263
      }

XhmikosR's avatar
XhmikosR committed
1264
      _this3._handleSwipe();
XhmikosR's avatar
Dist.  
XhmikosR committed
1265

XhmikosR's avatar
XhmikosR committed
1266
      if (_this3._config.pause === 'hover') {
XhmikosR's avatar
Dist.  
XhmikosR committed
1267
1268
1269
1270
1271
1272
1273
        // 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
XhmikosR's avatar
XhmikosR committed
1274
        _this3.pause();
XhmikosR's avatar
Dist.  
XhmikosR committed
1275

XhmikosR's avatar
XhmikosR committed
1276
1277
        if (_this3.touchTimeout) {
          clearTimeout(_this3.touchTimeout);
XhmikosR's avatar
Dist.  
XhmikosR committed
1278
1279
        }

XhmikosR's avatar
XhmikosR committed
1280
1281
1282
        _this3.touchTimeout = setTimeout(function (event) {
          return _this3.cycle(event);
        }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
XhmikosR's avatar
Dist.  
XhmikosR committed
1283
1284
1285
      }
    };

XhmikosR's avatar
XhmikosR committed
1286
1287
    SelectorEngine.find(SELECTOR_ITEM_IMG, this._element).forEach(function (itemImg) {
      EventHandler.on(itemImg, EVENT_DRAG_START, function (e) {
XhmikosR's avatar
XhmikosR committed
1288
1289
        return e.preventDefault();
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
1290
1291
1292
    });

    if (this._pointerEvent) {
XhmikosR's avatar
XhmikosR committed
1293
      EventHandler.on(this._element, EVENT_POINTERDOWN, function (event) {
XhmikosR's avatar
XhmikosR committed
1294
1295
        return start(event);
      });
XhmikosR's avatar
XhmikosR committed
1296
      EventHandler.on(this._element, EVENT_POINTERUP, function (event) {
XhmikosR's avatar
XhmikosR committed
1297
1298
        return end(event);
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
1299

XhmikosR's avatar
XhmikosR committed
1300
      this._element.classList.add(CLASS_NAME_POINTER_EVENT);
XhmikosR's avatar
Dist.  
XhmikosR committed
1301
    } else {
XhmikosR's avatar
XhmikosR committed
1302
      EventHandler.on(this._element, EVENT_TOUCHSTART, function (event) {
XhmikosR's avatar
XhmikosR committed
1303
1304
        return start(event);
      });
XhmikosR's avatar
XhmikosR committed
1305
      EventHandler.on(this._element, EVENT_TOUCHMOVE, function (event) {
XhmikosR's avatar
XhmikosR committed
1306
1307
        return move(event);
      });
XhmikosR's avatar
XhmikosR committed
1308
      EventHandler.on(this._element, EVENT_TOUCHEND, function (event) {
XhmikosR's avatar
XhmikosR committed
1309
1310
        return end(event);
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
1311
    }
XhmikosR's avatar
XhmikosR committed
1312
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1313

XhmikosR's avatar
XhmikosR committed
1314
  _proto._keydown = function _keydown(event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1315
1316
1317
1318
    if (/input|textarea/i.test(event.target.tagName)) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
1319
1320
    switch (event.key) {
      case ARROW_LEFT_KEY:
XhmikosR's avatar
Dist.  
XhmikosR committed
1321
1322
1323
1324
        event.preventDefault();
        this.prev();
        break;

XhmikosR's avatar
XhmikosR committed
1325
      case ARROW_RIGHT_KEY:
XhmikosR's avatar
Dist.  
XhmikosR committed
1326
1327
1328
1329
        event.preventDefault();
        this.next();
        break;
    }
XhmikosR's avatar
XhmikosR committed
1330
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1331

XhmikosR's avatar
XhmikosR committed
1332
  _proto._getItemIndex = function _getItemIndex(element) {
XhmikosR's avatar
XhmikosR committed
1333
    this._items = element && element.parentNode ? SelectorEngine.find(SELECTOR_ITEM, element.parentNode) : [];
XhmikosR's avatar
Dist.  
XhmikosR committed
1334
    return this._items.indexOf(element);
XhmikosR's avatar
XhmikosR committed
1335
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1336

XhmikosR's avatar
XhmikosR committed
1337
  _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
XhmikosR's avatar
XhmikosR committed
1338
1339
    var isNextDirection = direction === DIRECTION_NEXT;
    var isPrevDirection = direction === DIRECTION_PREV;
XhmikosR's avatar
Dist.  
XhmikosR committed
1340

XhmikosR's avatar
XhmikosR committed
1341
    var activeIndex = this._getItemIndex(activeElement);
XhmikosR's avatar
Dist.  
XhmikosR committed
1342

XhmikosR's avatar
XhmikosR committed
1343
1344
    var lastItemIndex = this._items.length - 1;
    var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
XhmikosR's avatar
Dist.  
XhmikosR committed
1345
1346
1347
1348
1349

    if (isGoingToWrap && !this._config.wrap) {
      return activeElement;
    }

XhmikosR's avatar
XhmikosR committed
1350
    var delta = direction === DIRECTION_PREV ? -1 : 1;
XhmikosR's avatar
XhmikosR committed
1351
    var itemIndex = (activeIndex + delta) % this._items.length;
XhmikosR's avatar
Dist.  
XhmikosR committed
1352
    return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
XhmikosR's avatar
XhmikosR committed
1353
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1354

XhmikosR's avatar
XhmikosR committed
1355
1356
  _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
    var targetIndex = this._getItemIndex(relatedTarget);
XhmikosR's avatar
Dist.  
XhmikosR committed
1357

XhmikosR's avatar
XhmikosR committed
1358
    var fromIndex = this._getItemIndex(SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element));
XhmikosR's avatar
Dist.  
XhmikosR committed
1359

XhmikosR's avatar
XhmikosR committed
1360
    return EventHandler.trigger(this._element, EVENT_SLIDE, {
XhmikosR's avatar
XhmikosR committed
1361
      relatedTarget: relatedTarget,
XhmikosR's avatar
Dist.  
XhmikosR committed
1362
1363
1364
1365
      direction: eventDirectionName,
      from: fromIndex,
      to: targetIndex
    });
XhmikosR's avatar
XhmikosR committed
1366
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1367

XhmikosR's avatar
XhmikosR committed
1368
  _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1369
    if (this._indicatorsElement) {
XhmikosR's avatar
XhmikosR committed
1370
      var indicators = SelectorEngine.find(SELECTOR_ACTIVE, this._indicatorsElement);
XhmikosR's avatar
Dist.  
XhmikosR committed
1371

XhmikosR's avatar
XhmikosR committed
1372
      for (var i = 0; i < indicators.length; i++) {
XhmikosR's avatar
XhmikosR committed
1373
        indicators[i].classList.remove(CLASS_NAME_ACTIVE$1);
XhmikosR's avatar
Dist.  
XhmikosR committed
1374
1375
      }

XhmikosR's avatar
XhmikosR committed
1376
      var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
XhmikosR's avatar
Dist.  
XhmikosR committed
1377
1378

      if (nextIndicator) {
XhmikosR's avatar
XhmikosR committed
1379
        nextIndicator.classList.add(CLASS_NAME_ACTIVE$1);
XhmikosR's avatar
Dist.  
XhmikosR committed
1380
1381
      }
    }
XhmikosR's avatar
XhmikosR committed
1382
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1383

XhmikosR's avatar
XhmikosR committed
1384
1385
1386
1387
1388
1389
1390
  _proto._updateInterval = function _updateInterval() {
    var element = this._activeElement || SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);

    if (!element) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
1391
    var elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10);
XhmikosR's avatar
XhmikosR committed
1392
1393
1394
1395
1396
1397
1398
1399
1400

    if (elementInterval) {
      this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
      this._config.interval = elementInterval;
    } else {
      this._config.interval = this._config.defaultInterval || this._config.interval;
    }
  };

XhmikosR's avatar
XhmikosR committed
1401
1402
  _proto._slide = function _slide(direction, element) {
    var _this4 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
1403

XhmikosR's avatar
XhmikosR committed
1404
    var activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
XhmikosR's avatar
Dist.  
XhmikosR committed
1405

XhmikosR's avatar
XhmikosR committed
1406
    var activeElementIndex = this._getItemIndex(activeElement);
XhmikosR's avatar
Dist.  
XhmikosR committed
1407

XhmikosR's avatar
XhmikosR committed
1408
    var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
XhmikosR's avatar
Dist.  
XhmikosR committed
1409

XhmikosR's avatar
XhmikosR committed
1410
1411
1412
1413
1414
1415
    var nextElementIndex = this._getItemIndex(nextElement);

    var isCycling = Boolean(this._interval);
    var directionalClassName;
    var orderClassName;
    var eventDirectionName;
XhmikosR's avatar
Dist.  
XhmikosR committed
1416

XhmikosR's avatar
XhmikosR committed
1417
1418
1419
1420
    if (direction === DIRECTION_NEXT) {
      directionalClassName = CLASS_NAME_LEFT;
      orderClassName = CLASS_NAME_NEXT;
      eventDirectionName = DIRECTION_LEFT;
XhmikosR's avatar
Dist.  
XhmikosR committed
1421
    } else {
XhmikosR's avatar
XhmikosR committed
1422
1423
1424
      directionalClassName = CLASS_NAME_RIGHT;
      orderClassName = CLASS_NAME_PREV;
      eventDirectionName = DIRECTION_RIGHT;
XhmikosR's avatar
Dist.  
XhmikosR committed
1425
1426
    }

XhmikosR's avatar
XhmikosR committed
1427
    if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE$1)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1428
1429
1430
1431
      this._isSliding = false;
      return;
    }

XhmikosR's avatar
XhmikosR committed
1432
    var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
XhmikosR's avatar
Dist.  
XhmikosR committed
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450

    if (slideEvent.defaultPrevented) {
      return;
    }

    if (!activeElement || !nextElement) {
      // Some weirdness is happening, so we bail
      return;
    }

    this._isSliding = true;

    if (isCycling) {
      this.pause();
    }

    this._setActiveIndicatorElement(nextElement);

XhmikosR's avatar
XhmikosR committed
1451
1452
    this._activeElement = nextElement;

XhmikosR's avatar
XhmikosR committed
1453
    if (this._element.classList.contains(CLASS_NAME_SLIDE)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1454
1455
1456
1457
      nextElement.classList.add(orderClassName);
      reflow(nextElement);
      activeElement.classList.add(directionalClassName);
      nextElement.classList.add(directionalClassName);
XhmikosR's avatar
XhmikosR committed
1458
1459
      var transitionDuration = getTransitionDurationFromElement(activeElement);
      EventHandler.one(activeElement, TRANSITION_END, function () {
XhmikosR's avatar
XhmikosR committed
1460
        nextElement.classList.remove(directionalClassName, orderClassName);
XhmikosR's avatar
XhmikosR committed
1461
        nextElement.classList.add(CLASS_NAME_ACTIVE$1);
XhmikosR's avatar
XhmikosR committed
1462
        activeElement.classList.remove(CLASS_NAME_ACTIVE$1, orderClassName, directionalClassName);
XhmikosR's avatar
XhmikosR committed
1463
1464
        _this4._isSliding = false;
        setTimeout(function () {
XhmikosR's avatar
XhmikosR committed
1465
          EventHandler.trigger(_this4._element, EVENT_SLID, {
XhmikosR's avatar
Dist.  
XhmikosR committed
1466
1467
1468
1469
1470
1471
1472
1473
1474
            relatedTarget: nextElement,
            direction: eventDirectionName,
            from: activeElementIndex,
            to: nextElementIndex
          });
        }, 0);
      });
      emulateTransitionEnd(activeElement, transitionDuration);
    } else {
XhmikosR's avatar
XhmikosR committed
1475
1476
      activeElement.classList.remove(CLASS_NAME_ACTIVE$1);
      nextElement.classList.add(CLASS_NAME_ACTIVE$1);
XhmikosR's avatar
Dist.  
XhmikosR committed
1477
      this._isSliding = false;
XhmikosR's avatar
XhmikosR committed
1478
      EventHandler.trigger(this._element, EVENT_SLID, {
XhmikosR's avatar
Dist.  
XhmikosR committed
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
        relatedTarget: nextElement,
        direction: eventDirectionName,
        from: activeElementIndex,
        to: nextElementIndex
      });
    }

    if (isCycling) {
      this.cycle();
    }
  } // Static
XhmikosR's avatar
XhmikosR committed
1490
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
1491

XhmikosR's avatar
XhmikosR committed
1492
  Carousel.carouselInterface = function carouselInterface(element, config) {
XhmikosR's avatar
XhmikosR committed
1493
    var data = Data.getData(element, DATA_KEY$2);
XhmikosR's avatar
Dist.  
XhmikosR committed
1494

XhmikosR's avatar
XhmikosR committed
1495
    var _config = _extends({}, Default, Manipulator.getDataAttributes(element));
XhmikosR's avatar
Dist.  
XhmikosR committed
1496
1497

    if (typeof config === 'object') {
XhmikosR's avatar
XhmikosR committed
1498
      _config = _extends({}, _config, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
1499
1500
    }

XhmikosR's avatar
XhmikosR committed
1501
    var action = typeof config === 'string' ? config : _config.slide;
XhmikosR's avatar
Dist.  
XhmikosR committed
1502
1503
1504
1505
1506
1507
1508
1509
1510

    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
XhmikosR committed
1511
        throw new TypeError("No method named \"" + action + "\"");
XhmikosR's avatar
Dist.  
XhmikosR committed
1512
1513
1514
1515
1516
1517
1518
      }

      data[action]();
    } else if (_config.interval && _config.ride) {
      data.pause();
      data.cycle();
    }
XhmikosR's avatar
XhmikosR committed
1519
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1520

XhmikosR's avatar
XhmikosR committed
1521
  Carousel.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1522
    return this.each(function () {
XhmikosR's avatar
XhmikosR committed
1523
      Carousel.carouselInterface(this, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
1524
    });
XhmikosR's avatar
XhmikosR committed
1525
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1526

XhmikosR's avatar
XhmikosR committed
1527
1528
  Carousel.dataApiClickHandler = function dataApiClickHandler(event) {
    var target = getElementFromSelector(this);
XhmikosR's avatar
Dist.  
XhmikosR committed
1529

XhmikosR's avatar
XhmikosR committed
1530
    if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1531
1532
1533
      return;
    }

XhmikosR's avatar
XhmikosR committed
1534
    var config = _extends({}, Manipulator.getDataAttributes(target), Manipulator.getDataAttributes(this));
XhmikosR's avatar
Dist.  
XhmikosR committed
1535

XhmikosR's avatar
XhmikosR committed
1536
    var slideIndex = this.getAttribute('data-bs-slide-to');
XhmikosR's avatar
Dist.  
XhmikosR committed
1537
1538
1539
1540
1541

    if (slideIndex) {
      config.interval = false;
    }

XhmikosR's avatar
XhmikosR committed
1542
    Carousel.carouselInterface(target, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
1543
1544
1545
1546
1547
1548

    if (slideIndex) {
      Data.getData(target, DATA_KEY$2).to(slideIndex);
    }

    event.preventDefault();
XhmikosR's avatar
XhmikosR committed
1549
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1550

XhmikosR's avatar
XhmikosR committed
1551
  Carousel.getInstance = function getInstance(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1552
    return Data.getData(element, DATA_KEY$2);
XhmikosR's avatar
XhmikosR committed
1553
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1554

XhmikosR's avatar
XhmikosR committed
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
  _createClass(Carousel, null, [{
    key: "VERSION",
    get: function get() {
      return VERSION$2;
    }
  }, {
    key: "Default",
    get: function get() {
      return Default;
    }
  }]);

  return Carousel;
}();
XhmikosR's avatar
Dist.  
XhmikosR committed
1569
1570
1571
1572
1573
1574
1575
/**
 * ------------------------------------------------------------------------
 * Data Api implementation
 * ------------------------------------------------------------------------
 */


XhmikosR's avatar
XhmikosR committed
1576
1577
1578
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
1579

XhmikosR's avatar
XhmikosR committed
1580
  for (var i = 0, len = carousels.length; i < len; i++) {
XhmikosR's avatar
XhmikosR committed
1581
    Carousel.carouselInterface(carousels[i], Data.getData(carousels[i], DATA_KEY$2));
XhmikosR's avatar
Dist.  
XhmikosR committed
1582
1583
1584
1585
1586
1587
  }
});
/**
 * ------------------------------------------------------------------------
 * jQuery
 * ------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
1588
 * add .Carousel to jQuery only if jQuery is present
XhmikosR's avatar
Dist.  
XhmikosR committed
1589
1590
 */

XhmikosR's avatar
XhmikosR committed
1591
1592
1593
onDOMContentLoaded(function () {
  var $ = getjQuery();
  /* istanbul ignore if */
1594

XhmikosR's avatar
XhmikosR committed
1595
1596
1597
1598
  if ($) {
    var JQUERY_NO_CONFLICT = $.fn[NAME$2];
    $.fn[NAME$2] = Carousel.jQueryInterface;
    $.fn[NAME$2].Constructor = Carousel;
XhmikosR's avatar
Dist.  
XhmikosR committed
1599

XhmikosR's avatar
XhmikosR committed
1600
1601
1602
1603
1604
1605
    $.fn[NAME$2].noConflict = function () {
      $.fn[NAME$2] = JQUERY_NO_CONFLICT;
      return Carousel.jQueryInterface;
    };
  }
});
XhmikosR's avatar
Dist.  
XhmikosR committed
1606
1607
1608
1609
1610
1611
1612

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

XhmikosR's avatar
XhmikosR committed
1613
var NAME$3 = 'collapse';
XhmikosR's avatar
XhmikosR committed
1614
var VERSION$3 = '5.0.0-alpha3';
XhmikosR's avatar
XhmikosR committed
1615
1616
1617
1618
var DATA_KEY$3 = 'bs.collapse';
var EVENT_KEY$3 = "." + DATA_KEY$3;
var DATA_API_KEY$3 = '.data-api';
var Default$1 = {
XhmikosR's avatar
Dist.  
XhmikosR committed
1619
1620
1621
  toggle: true,
  parent: ''
};
XhmikosR's avatar
XhmikosR committed
1622
var DefaultType$1 = {
XhmikosR's avatar
Dist.  
XhmikosR committed
1623
1624
1625
  toggle: 'boolean',
  parent: '(string|element)'
};
XhmikosR's avatar
XhmikosR committed
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
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';
XhmikosR's avatar
XhmikosR committed
1638
var SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="collapse"]';
XhmikosR's avatar
XhmikosR committed
1639
1640
1641
1642
1643
/**
 * ------------------------------------------------------------------------
 * Class Definition
 * ------------------------------------------------------------------------
 */
XhmikosR's avatar
Dist.  
XhmikosR committed
1644

XhmikosR's avatar
XhmikosR committed
1645
var Collapse = /*#__PURE__*/function () {
XhmikosR's avatar
XhmikosR committed
1646
  function Collapse(element, config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1647
1648
1649
    this._isTransitioning = false;
    this._element = element;
    this._config = this._getConfig(config);
XhmikosR's avatar
XhmikosR committed
1650
    this._triggerArray = SelectorEngine.find(SELECTOR_DATA_TOGGLE$1 + "[href=\"#" + element.id + "\"]," + (SELECTOR_DATA_TOGGLE$1 + "[data-bs-target=\"#" + element.id + "\"]"));
XhmikosR's avatar
XhmikosR committed
1651
    var toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$1);
XhmikosR's avatar
XhmikosR committed
1652
1653
1654
1655

    for (var i = 0, len = toggleList.length; i < len; i++) {
      var elem = toggleList[i];
      var selector = getSelectorFromElement(elem);
XhmikosR's avatar
XhmikosR committed
1656
      var filterElement = SelectorEngine.find(selector).filter(function (foundElem) {
XhmikosR's avatar
XhmikosR committed
1657
1658
        return foundElem === element;
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680

      if (selector !== null && filterElement.length) {
        this._selector = selector;

        this._triggerArray.push(elem);
      }
    }

    this._parent = this._config.parent ? this._getParent() : null;

    if (!this._config.parent) {
      this._addAriaAndCollapsedClass(this._element, this._triggerArray);
    }

    if (this._config.toggle) {
      this.toggle();
    }

    Data.setData(element, DATA_KEY$3, this);
  } // Getters


XhmikosR's avatar
XhmikosR committed
1681
  var _proto = Collapse.prototype;
XhmikosR's avatar
Dist.  
XhmikosR committed
1682

XhmikosR's avatar
XhmikosR committed
1683
1684
  // Public
  _proto.toggle = function toggle() {
XhmikosR's avatar
XhmikosR committed
1685
    if (this._element.classList.contains(CLASS_NAME_SHOW)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1686
1687
1688
1689
      this.hide();
    } else {
      this.show();
    }
XhmikosR's avatar
XhmikosR committed
1690
1691
1692
1693
  };

  _proto.show = function show() {
    var _this = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
1694

XhmikosR's avatar
XhmikosR committed
1695
    if (this._isTransitioning || this._element.classList.contains(CLASS_NAME_SHOW)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1696
1697
1698
      return;
    }

XhmikosR's avatar
XhmikosR committed
1699
1700
    var actives;
    var activesData;
XhmikosR's avatar
Dist.  
XhmikosR committed
1701
1702

    if (this._parent) {
XhmikosR's avatar
XhmikosR committed
1703
      actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent).filter(function (elem) {
XhmikosR's avatar
XhmikosR committed
1704
        if (typeof _this._config.parent === 'string') {
XhmikosR's avatar
XhmikosR committed
1705
          return elem.getAttribute('data-bs-parent') === _this._config.parent;
XhmikosR's avatar
Dist.  
XhmikosR committed
1706
1707
        }

XhmikosR's avatar
XhmikosR committed
1708
        return elem.classList.contains(CLASS_NAME_COLLAPSE);
XhmikosR's avatar
Dist.  
XhmikosR committed
1709
1710
1711
1712
1713
1714
1715
      });

      if (actives.length === 0) {
        actives = null;
      }
    }

XhmikosR's avatar
XhmikosR committed
1716
    var container = SelectorEngine.findOne(this._selector);
XhmikosR's avatar
Dist.  
XhmikosR committed
1717
1718

    if (actives) {
XhmikosR's avatar
XhmikosR committed
1719
      var tempActiveData = actives.find(function (elem) {
XhmikosR's avatar
XhmikosR committed
1720
1721
        return container !== elem;
      });
XhmikosR's avatar
XhmikosR committed
1722
      activesData = tempActiveData ? Data.getData(tempActiveData, DATA_KEY$3) : null;
XhmikosR's avatar
Dist.  
XhmikosR committed
1723
1724
1725
1726
1727
1728

      if (activesData && activesData._isTransitioning) {
        return;
      }
    }

XhmikosR's avatar
XhmikosR committed
1729
    var startEvent = EventHandler.trigger(this._element, EVENT_SHOW);
XhmikosR's avatar
Dist.  
XhmikosR committed
1730
1731
1732
1733
1734
1735

    if (startEvent.defaultPrevented) {
      return;
    }

    if (actives) {
XhmikosR's avatar
XhmikosR committed
1736
      actives.forEach(function (elemActive) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1737
        if (container !== elemActive) {
XhmikosR's avatar
XhmikosR committed
1738
          Collapse.collapseInterface(elemActive, 'hide');
XhmikosR's avatar
Dist.  
XhmikosR committed
1739
1740
1741
1742
1743
1744
1745
1746
        }

        if (!activesData) {
          Data.setData(elemActive, DATA_KEY$3, null);
        }
      });
    }

XhmikosR's avatar
XhmikosR committed
1747
    var dimension = this._getDimension();
XhmikosR's avatar
Dist.  
XhmikosR committed
1748

XhmikosR's avatar
XhmikosR committed
1749
    this._element.classList.remove(CLASS_NAME_COLLAPSE);
XhmikosR's avatar
Dist.  
XhmikosR committed
1750

XhmikosR's avatar
XhmikosR committed
1751
    this._element.classList.add(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
Dist.  
XhmikosR committed
1752
1753
1754
1755

    this._element.style[dimension] = 0;

    if (this._triggerArray.length) {
XhmikosR's avatar
XhmikosR committed
1756
      this._triggerArray.forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
1757
        element.classList.remove(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
Dist.  
XhmikosR committed
1758
1759
1760
1761
1762
1763
        element.setAttribute('aria-expanded', true);
      });
    }

    this.setTransitioning(true);

XhmikosR's avatar
XhmikosR committed
1764
    var complete = function complete() {
XhmikosR's avatar
XhmikosR committed
1765
      _this._element.classList.remove(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
XhmikosR committed
1766

XhmikosR's avatar
XhmikosR committed
1767
      _this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW);
XhmikosR's avatar
Dist.  
XhmikosR committed
1768

XhmikosR's avatar
XhmikosR committed
1769
      _this._element.style[dimension] = '';
XhmikosR's avatar
Dist.  
XhmikosR committed
1770

XhmikosR's avatar
XhmikosR committed
1771
      _this.setTransitioning(false);
XhmikosR's avatar
Dist.  
XhmikosR committed
1772

XhmikosR's avatar
XhmikosR committed
1773
      EventHandler.trigger(_this._element, EVENT_SHOWN);
XhmikosR's avatar
Dist.  
XhmikosR committed
1774
1775
    };

XhmikosR's avatar
XhmikosR committed
1776
1777
1778
    var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
    var scrollSize = "scroll" + capitalizedDimension;
    var transitionDuration = getTransitionDurationFromElement(this._element);
XhmikosR's avatar
Dist.  
XhmikosR committed
1779
1780
    EventHandler.one(this._element, TRANSITION_END, complete);
    emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
XhmikosR committed
1781
1782
1783
1784
1785
    this._element.style[dimension] = this._element[scrollSize] + "px";
  };

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

XhmikosR's avatar
XhmikosR committed
1787
    if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1788
1789
1790
      return;
    }

XhmikosR's avatar
XhmikosR committed
1791
    var startEvent = EventHandler.trigger(this._element, EVENT_HIDE);
XhmikosR's avatar
Dist.  
XhmikosR committed
1792
1793
1794
1795
1796

    if (startEvent.defaultPrevented) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
1797
    var dimension = this._getDimension();
XhmikosR's avatar
Dist.  
XhmikosR committed
1798

XhmikosR's avatar
XhmikosR committed
1799
    this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
1800
1801
    reflow(this._element);

XhmikosR's avatar
XhmikosR committed
1802
    this._element.classList.add(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
Dist.  
XhmikosR committed
1803

XhmikosR's avatar
XhmikosR committed
1804
    this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW);
XhmikosR's avatar
Dist.  
XhmikosR committed
1805

XhmikosR's avatar
XhmikosR committed
1806
    var triggerArrayLength = this._triggerArray.length;
XhmikosR's avatar
Dist.  
XhmikosR committed
1807
1808

    if (triggerArrayLength > 0) {
XhmikosR's avatar
XhmikosR committed
1809
1810
      for (var i = 0; i < triggerArrayLength; i++) {
        var trigger = this._triggerArray[i];
XhmikosR's avatar
XhmikosR committed
1811
        var elem = getElementFromSelector(trigger);
XhmikosR's avatar
Dist.  
XhmikosR committed
1812

XhmikosR's avatar
XhmikosR committed
1813
1814
        if (elem && !elem.classList.contains(CLASS_NAME_SHOW)) {
          trigger.classList.add(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
XhmikosR committed
1815
          trigger.setAttribute('aria-expanded', false);
XhmikosR's avatar
Dist.  
XhmikosR committed
1816
1817
1818
1819
1820
1821
        }
      }
    }

    this.setTransitioning(true);

XhmikosR's avatar
XhmikosR committed
1822
1823
    var complete = function complete() {
      _this2.setTransitioning(false);
XhmikosR's avatar
Dist.  
XhmikosR committed
1824

XhmikosR's avatar
XhmikosR committed
1825
      _this2._element.classList.remove(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
Dist.  
XhmikosR committed
1826

XhmikosR's avatar
XhmikosR committed
1827
      _this2._element.classList.add(CLASS_NAME_COLLAPSE);
XhmikosR's avatar
Dist.  
XhmikosR committed
1828

XhmikosR's avatar
XhmikosR committed
1829
      EventHandler.trigger(_this2._element, EVENT_HIDDEN);
XhmikosR's avatar
Dist.  
XhmikosR committed
1830
1831
1832
    };

    this._element.style[dimension] = '';
XhmikosR's avatar
XhmikosR committed
1833
    var transitionDuration = getTransitionDurationFromElement(this._element);
XhmikosR's avatar
Dist.  
XhmikosR committed
1834
1835
    EventHandler.one(this._element, TRANSITION_END, complete);
    emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
XhmikosR committed
1836
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1837

XhmikosR's avatar
XhmikosR committed
1838
  _proto.setTransitioning = function setTransitioning(isTransitioning) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1839
    this._isTransitioning = isTransitioning;
XhmikosR's avatar
XhmikosR committed
1840
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1841

XhmikosR's avatar
XhmikosR committed
1842
  _proto.dispose = function dispose() {
XhmikosR's avatar
Dist.  
XhmikosR committed
1843
1844
1845
1846
1847
1848
1849
    Data.removeData(this._element, DATA_KEY$3);
    this._config = null;
    this._parent = null;
    this._element = null;
    this._triggerArray = null;
    this._isTransitioning = null;
  } // Private
XhmikosR's avatar
XhmikosR committed
1850
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
1851

XhmikosR's avatar
XhmikosR committed
1852
  _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
1853
    config = _extends({}, Default$1, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
1854
1855
1856
1857
    config.toggle = Boolean(config.toggle); // Coerce string values

    typeCheckConfig(NAME$3, config, DefaultType$1);
    return config;
XhmikosR's avatar
XhmikosR committed
1858
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1859

XhmikosR's avatar
XhmikosR committed
1860
  _proto._getDimension = function _getDimension() {
XhmikosR's avatar
XhmikosR committed
1861
    return this._element.classList.contains(WIDTH) ? WIDTH : HEIGHT;
XhmikosR's avatar
XhmikosR committed
1862
1863
1864
1865
  };

  _proto._getParent = function _getParent() {
    var _this3 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
1866

XhmikosR's avatar
XhmikosR committed
1867
    var parent = this._config.parent;
XhmikosR's avatar
Dist.  
XhmikosR committed
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877

    if (isElement(parent)) {
      // it's a jQuery object
      if (typeof parent.jquery !== 'undefined' || typeof parent[0] !== 'undefined') {
        parent = parent[0];
      }
    } else {
      parent = SelectorEngine.findOne(parent);
    }

XhmikosR's avatar
XhmikosR committed
1878
    var selector = SELECTOR_DATA_TOGGLE$1 + "[data-bs-parent=\"" + parent + "\"]";
XhmikosR's avatar
XhmikosR committed
1879
    SelectorEngine.find(selector, parent).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
1880
      var selected = getElementFromSelector(element);
1881
1882

      _this3._addAriaAndCollapsedClass(selected, [element]);
XhmikosR's avatar
Dist.  
XhmikosR committed
1883
1884
    });
    return parent;
XhmikosR's avatar
XhmikosR committed
1885
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1886

XhmikosR's avatar
XhmikosR committed
1887
  _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
XhmikosR's avatar
XhmikosR committed
1888
1889
1890
    if (!element || !triggerArray.length) {
      return;
    }
XhmikosR's avatar
Dist.  
XhmikosR committed
1891

XhmikosR's avatar
XhmikosR committed
1892
1893
1894
1895
1896
1897
    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
Dist.  
XhmikosR committed
1898
      }
XhmikosR's avatar
XhmikosR committed
1899
1900
1901

      elem.setAttribute('aria-expanded', isOpen);
    });
XhmikosR's avatar
Dist.  
XhmikosR committed
1902
  } // Static
XhmikosR's avatar
XhmikosR committed
1903
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
1904

XhmikosR's avatar
XhmikosR committed
1905
  Collapse.collapseInterface = function collapseInterface(element, config) {
XhmikosR's avatar
XhmikosR committed
1906
    var data = Data.getData(element, DATA_KEY$3);
XhmikosR's avatar
Dist.  
XhmikosR committed
1907

XhmikosR's avatar
XhmikosR committed
1908
    var _config = _extends({}, Default$1, Manipulator.getDataAttributes(element), typeof config === 'object' && config ? config : {});
XhmikosR's avatar
Dist.  
XhmikosR committed
1909

XhmikosR's avatar
XhmikosR committed
1910
    if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1911
1912
1913
1914
1915
1916
1917
1918
1919
      _config.toggle = false;
    }

    if (!data) {
      data = new Collapse(element, _config);
    }

    if (typeof config === 'string') {
      if (typeof data[config] === 'undefined') {
XhmikosR's avatar
XhmikosR committed
1920
        throw new TypeError("No method named \"" + config + "\"");
XhmikosR's avatar
Dist.  
XhmikosR committed
1921
1922
1923
1924
      }

      data[config]();
    }
XhmikosR's avatar
XhmikosR committed
1925
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1926

XhmikosR's avatar
XhmikosR committed
1927
  Collapse.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1928
    return this.each(function () {
XhmikosR's avatar
XhmikosR committed
1929
      Collapse.collapseInterface(this, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
1930
    });
XhmikosR's avatar
XhmikosR committed
1931
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1932

XhmikosR's avatar
XhmikosR committed
1933
  Collapse.getInstance = function getInstance(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1934
    return Data.getData(element, DATA_KEY$3);
XhmikosR's avatar
XhmikosR committed
1935
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1936

XhmikosR's avatar
XhmikosR committed
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
  _createClass(Collapse, null, [{
    key: "VERSION",
    get: function get() {
      return VERSION$3;
    }
  }, {
    key: "Default",
    get: function get() {
      return Default$1;
    }
  }]);

  return Collapse;
}();
XhmikosR's avatar
Dist.  
XhmikosR committed
1951
1952
1953
1954
1955
1956
1957
/**
 * ------------------------------------------------------------------------
 * Data Api implementation
 * ------------------------------------------------------------------------
 */


XhmikosR's avatar
XhmikosR committed
1958
EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$1, function (event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1959
1960
1961
1962
1963
  // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  if (event.target.tagName === 'A') {
    event.preventDefault();
  }

XhmikosR's avatar
XhmikosR committed
1964
1965
  var triggerData = Manipulator.getDataAttributes(this);
  var selector = getSelectorFromElement(this);
XhmikosR's avatar
XhmikosR committed
1966
  var selectorElements = SelectorEngine.find(selector);
XhmikosR's avatar
XhmikosR committed
1967
1968
1969
  selectorElements.forEach(function (element) {
    var data = Data.getData(element, DATA_KEY$3);
    var config;
XhmikosR's avatar
Dist.  
XhmikosR committed
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982

    if (data) {
      // update parent attribute
      if (data._parent === null && typeof triggerData.parent === 'string') {
        data._config.parent = triggerData.parent;
        data._parent = data._getParent();
      }

      config = 'toggle';
    } else {
      config = triggerData;
    }

XhmikosR's avatar
XhmikosR committed
1983
    Collapse.collapseInterface(element, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
1984
1985
1986
1987
1988
1989
  });
});
/**
 * ------------------------------------------------------------------------
 * jQuery
 * ------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
1990
 * add .Collapse to jQuery only if jQuery is present
XhmikosR's avatar
Dist.  
XhmikosR committed
1991
1992
 */

XhmikosR's avatar
XhmikosR committed
1993
1994
1995
onDOMContentLoaded(function () {
  var $ = getjQuery();
  /* istanbul ignore if */
1996

XhmikosR's avatar
XhmikosR committed
1997
1998
1999
2000
  if ($) {
    var JQUERY_NO_CONFLICT = $.fn[NAME$3];
    $.fn[NAME$3] = Collapse.jQueryInterface;
    $.fn[NAME$3].Constructor = Collapse;
For faster browsing, not all history is shown. View entire blame