bootstrap.esm.js 142 KB
Newer Older
XhmikosR's avatar
Dist.  
XhmikosR committed
1001
1002
1003
1004
1005
    return {
      top: element.offsetTop,
      left: element.offsetLeft
    };
  },
XhmikosR's avatar
XhmikosR committed
1006
  toggleClass: function toggleClass(element, className) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
    if (!element) {
      return;
    }

    if (element.classList.contains(className)) {
      element.classList.remove(className);
    } else {
      element.classList.add(className);
    }
  }
};

XhmikosR's avatar
XhmikosR committed
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
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
/**
 * --------------------------------------------------------------------------
 * Bootstrap (v5.0.0-alpha1): dom/selector-engine.js
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
 * --------------------------------------------------------------------------
 */
/**
 * ------------------------------------------------------------------------
 * Constants
 * ------------------------------------------------------------------------
 */

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 [];
  }
};

XhmikosR's avatar
Dist.  
XhmikosR committed
1103
1104
1105
1106
1107
1108
/**
 * ------------------------------------------------------------------------
 * Constants
 * ------------------------------------------------------------------------
 */

XhmikosR's avatar
XhmikosR committed
1109
var NAME$2 = 'carousel';
1110
var VERSION$2 = '5.0.0-alpha1';
XhmikosR's avatar
XhmikosR committed
1111
1112
1113
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
1114
1115
var ARROW_LEFT_KEY = 'ArrowLeft';
var ARROW_RIGHT_KEY = 'ArrowRight';
XhmikosR's avatar
XhmikosR committed
1116
var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
XhmikosR's avatar
Dist.  
XhmikosR committed
1117

XhmikosR's avatar
XhmikosR committed
1118
1119
var SWIPE_THRESHOLD = 40;
var Default = {
XhmikosR's avatar
Dist.  
XhmikosR committed
1120
1121
1122
1123
1124
1125
1126
  interval: 5000,
  keyboard: true,
  slide: false,
  pause: 'hover',
  wrap: true,
  touch: true
};
XhmikosR's avatar
XhmikosR committed
1127
var DefaultType = {
XhmikosR's avatar
Dist.  
XhmikosR committed
1128
1129
1130
1131
1132
1133
1134
  interval: '(number|boolean)',
  keyboard: 'boolean',
  slide: '(boolean|string)',
  pause: '(string|boolean)',
  wrap: 'boolean',
  touch: 'boolean'
};
XhmikosR's avatar
XhmikosR committed
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
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
1160
var SELECTOR_ACTIVE = '.active';
XhmikosR's avatar
XhmikosR committed
1161
1162
1163
1164
1165
1166
1167
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
XhmikosR committed
1168
var PointerType = {
XhmikosR's avatar
Dist.  
XhmikosR committed
1169
1170
1171
  TOUCH: 'touch',
  PEN: 'pen'
};
XhmikosR's avatar
XhmikosR committed
1172
1173
1174
1175
1176
/**
 * ------------------------------------------------------------------------
 * Class Definition
 * ------------------------------------------------------------------------
 */
XhmikosR's avatar
Dist.  
XhmikosR committed
1177

XhmikosR's avatar
XhmikosR committed
1178
var Carousel = /*#__PURE__*/function () {
XhmikosR's avatar
XhmikosR committed
1179
  function Carousel(element, config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
    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
1190
    this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
XhmikosR's avatar
Dist.  
XhmikosR committed
1191
    this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
XhmikosR's avatar
XhmikosR committed
1192
    this._pointerEvent = Boolean(window.PointerEvent);
XhmikosR's avatar
Dist.  
XhmikosR committed
1193
1194
1195
1196
1197
1198
1199

    this._addEventListeners();

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


XhmikosR's avatar
XhmikosR committed
1200
  var _proto = Carousel.prototype;
XhmikosR's avatar
Dist.  
XhmikosR committed
1201

XhmikosR's avatar
XhmikosR committed
1202
1203
  // Public
  _proto.next = function next() {
XhmikosR's avatar
Dist.  
XhmikosR committed
1204
    if (!this._isSliding) {
XhmikosR's avatar
XhmikosR committed
1205
      this._slide(DIRECTION_NEXT);
XhmikosR's avatar
Dist.  
XhmikosR committed
1206
    }
XhmikosR's avatar
XhmikosR committed
1207
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1208

XhmikosR's avatar
XhmikosR committed
1209
  _proto.nextWhenVisible = function nextWhenVisible() {
XhmikosR's avatar
Dist.  
XhmikosR committed
1210
1211
1212
1213
1214
    // 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
1215
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1216

XhmikosR's avatar
XhmikosR committed
1217
  _proto.prev = function prev() {
XhmikosR's avatar
Dist.  
XhmikosR committed
1218
    if (!this._isSliding) {
XhmikosR's avatar
XhmikosR committed
1219
      this._slide(DIRECTION_PREV);
XhmikosR's avatar
Dist.  
XhmikosR committed
1220
    }
XhmikosR's avatar
XhmikosR committed
1221
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1222

XhmikosR's avatar
XhmikosR committed
1223
  _proto.pause = function pause(event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1224
1225
1226
1227
    if (!event) {
      this._isPaused = true;
    }

XhmikosR's avatar
XhmikosR committed
1228
    if (SelectorEngine.findOne(SELECTOR_NEXT_PREV, this._element)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1229
1230
1231
1232
1233
1234
      triggerTransitionEnd(this._element);
      this.cycle(true);
    }

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

XhmikosR's avatar
XhmikosR committed
1237
  _proto.cycle = function cycle(event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
    if (!event) {
      this._isPaused = false;
    }

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

    if (this._config && this._config.interval && !this._isPaused) {
      this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
    }
XhmikosR's avatar
XhmikosR committed
1250
1251
1252
1253
  };

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

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

XhmikosR's avatar
XhmikosR committed
1257
    var activeIndex = this._getItemIndex(this._activeElement);
XhmikosR's avatar
Dist.  
XhmikosR committed
1258
1259
1260
1261
1262
1263

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

    if (this._isSliding) {
XhmikosR's avatar
XhmikosR committed
1264
      EventHandler.one(this._element, EVENT_SLID, function () {
XhmikosR's avatar
XhmikosR committed
1265
1266
        return _this.to(index);
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
1267
1268
1269
1270
1271
1272
1273
1274
1275
      return;
    }

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

XhmikosR's avatar
XhmikosR committed
1276
    var direction = index > activeIndex ? DIRECTION_NEXT : DIRECTION_PREV;
XhmikosR's avatar
Dist.  
XhmikosR committed
1277
1278

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

XhmikosR's avatar
XhmikosR committed
1281
  _proto.dispose = function dispose() {
XhmikosR's avatar
Dist.  
XhmikosR committed
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
    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
1293
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
1294

XhmikosR's avatar
XhmikosR committed
1295
  _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
1296
    config = _objectSpread2(_objectSpread2({}, Default), config);
XhmikosR's avatar
Dist.  
XhmikosR committed
1297
1298
    typeCheckConfig(NAME$2, config, DefaultType);
    return config;
XhmikosR's avatar
XhmikosR committed
1299
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1300

XhmikosR's avatar
XhmikosR committed
1301
1302
  _proto._handleSwipe = function _handleSwipe() {
    var absDeltax = Math.abs(this.touchDeltaX);
XhmikosR's avatar
Dist.  
XhmikosR committed
1303
1304
1305
1306
1307

    if (absDeltax <= SWIPE_THRESHOLD) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
1308
1309
    var direction = absDeltax / this.touchDeltaX;
    this.touchDeltaX = 0; // swipe left
XhmikosR's avatar
Dist.  
XhmikosR committed
1310
1311
1312
1313
1314
1315
1316
1317
1318

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


    if (direction < 0) {
      this.next();
    }
XhmikosR's avatar
XhmikosR committed
1319
1320
1321
1322
  };

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

    if (this._config.keyboard) {
XhmikosR's avatar
XhmikosR committed
1325
      EventHandler.on(this._element, EVENT_KEYDOWN, function (event) {
XhmikosR's avatar
XhmikosR committed
1326
1327
        return _this2._keydown(event);
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
1328
1329
1330
    }

    if (this._config.pause === 'hover') {
XhmikosR's avatar
XhmikosR committed
1331
      EventHandler.on(this._element, EVENT_MOUSEENTER, function (event) {
XhmikosR's avatar
XhmikosR committed
1332
1333
        return _this2.pause(event);
      });
XhmikosR's avatar
XhmikosR committed
1334
      EventHandler.on(this._element, EVENT_MOUSELEAVE, function (event) {
XhmikosR's avatar
XhmikosR committed
1335
1336
        return _this2.cycle(event);
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
1337
1338
    }

1339
    if (this._config.touch && this._touchSupported) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1340
1341
      this._addTouchEventListeners();
    }
XhmikosR's avatar
XhmikosR committed
1342
1343
1344
1345
  };

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

XhmikosR's avatar
XhmikosR committed
1347
1348
1349
1350
1351
    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
1352
1353
1354
      }
    };

XhmikosR's avatar
XhmikosR committed
1355
    var move = function move(event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1356
1357
      // ensure swiping with one touch and not pinching
      if (event.touches && event.touches.length > 1) {
XhmikosR's avatar
XhmikosR committed
1358
        _this3.touchDeltaX = 0;
XhmikosR's avatar
Dist.  
XhmikosR committed
1359
      } else {
XhmikosR's avatar
XhmikosR committed
1360
        _this3.touchDeltaX = event.touches[0].clientX - _this3.touchStartX;
XhmikosR's avatar
Dist.  
XhmikosR committed
1361
1362
1363
      }
    };

XhmikosR's avatar
XhmikosR committed
1364
1365
1366
    var end = function end(event) {
      if (_this3._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
        _this3.touchDeltaX = event.clientX - _this3.touchStartX;
XhmikosR's avatar
Dist.  
XhmikosR committed
1367
1368
      }

XhmikosR's avatar
XhmikosR committed
1369
      _this3._handleSwipe();
XhmikosR's avatar
Dist.  
XhmikosR committed
1370

XhmikosR's avatar
XhmikosR committed
1371
      if (_this3._config.pause === 'hover') {
XhmikosR's avatar
Dist.  
XhmikosR committed
1372
1373
1374
1375
1376
1377
1378
        // 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
1379
        _this3.pause();
XhmikosR's avatar
Dist.  
XhmikosR committed
1380

XhmikosR's avatar
XhmikosR committed
1381
1382
        if (_this3.touchTimeout) {
          clearTimeout(_this3.touchTimeout);
XhmikosR's avatar
Dist.  
XhmikosR committed
1383
1384
        }

XhmikosR's avatar
XhmikosR committed
1385
1386
1387
        _this3.touchTimeout = setTimeout(function (event) {
          return _this3.cycle(event);
        }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
XhmikosR's avatar
Dist.  
XhmikosR committed
1388
1389
1390
      }
    };

XhmikosR's avatar
XhmikosR committed
1391
1392
    SelectorEngine.find(SELECTOR_ITEM_IMG, this._element).forEach(function (itemImg) {
      EventHandler.on(itemImg, EVENT_DRAG_START, function (e) {
XhmikosR's avatar
XhmikosR committed
1393
1394
        return e.preventDefault();
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
1395
1396
1397
    });

    if (this._pointerEvent) {
XhmikosR's avatar
XhmikosR committed
1398
      EventHandler.on(this._element, EVENT_POINTERDOWN, function (event) {
XhmikosR's avatar
XhmikosR committed
1399
1400
        return start(event);
      });
XhmikosR's avatar
XhmikosR committed
1401
      EventHandler.on(this._element, EVENT_POINTERUP, function (event) {
XhmikosR's avatar
XhmikosR committed
1402
1403
        return end(event);
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
1404

XhmikosR's avatar
XhmikosR committed
1405
      this._element.classList.add(CLASS_NAME_POINTER_EVENT);
XhmikosR's avatar
Dist.  
XhmikosR committed
1406
    } else {
XhmikosR's avatar
XhmikosR committed
1407
      EventHandler.on(this._element, EVENT_TOUCHSTART, function (event) {
XhmikosR's avatar
XhmikosR committed
1408
1409
        return start(event);
      });
XhmikosR's avatar
XhmikosR committed
1410
      EventHandler.on(this._element, EVENT_TOUCHMOVE, function (event) {
XhmikosR's avatar
XhmikosR committed
1411
1412
        return move(event);
      });
XhmikosR's avatar
XhmikosR committed
1413
      EventHandler.on(this._element, EVENT_TOUCHEND, function (event) {
XhmikosR's avatar
XhmikosR committed
1414
1415
        return end(event);
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
1416
    }
XhmikosR's avatar
XhmikosR committed
1417
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1418

XhmikosR's avatar
XhmikosR committed
1419
  _proto._keydown = function _keydown(event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1420
1421
1422
1423
    if (/input|textarea/i.test(event.target.tagName)) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
1424
1425
    switch (event.key) {
      case ARROW_LEFT_KEY:
XhmikosR's avatar
Dist.  
XhmikosR committed
1426
1427
1428
1429
        event.preventDefault();
        this.prev();
        break;

XhmikosR's avatar
XhmikosR committed
1430
      case ARROW_RIGHT_KEY:
XhmikosR's avatar
Dist.  
XhmikosR committed
1431
1432
1433
1434
        event.preventDefault();
        this.next();
        break;
    }
XhmikosR's avatar
XhmikosR committed
1435
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1436

XhmikosR's avatar
XhmikosR committed
1437
  _proto._getItemIndex = function _getItemIndex(element) {
XhmikosR's avatar
XhmikosR committed
1438
    this._items = element && element.parentNode ? SelectorEngine.find(SELECTOR_ITEM, element.parentNode) : [];
XhmikosR's avatar
Dist.  
XhmikosR committed
1439
    return this._items.indexOf(element);
XhmikosR's avatar
XhmikosR committed
1440
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1441

XhmikosR's avatar
XhmikosR committed
1442
  _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
XhmikosR's avatar
XhmikosR committed
1443
1444
    var isNextDirection = direction === DIRECTION_NEXT;
    var isPrevDirection = direction === DIRECTION_PREV;
XhmikosR's avatar
Dist.  
XhmikosR committed
1445

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

XhmikosR's avatar
XhmikosR committed
1448
1449
    var lastItemIndex = this._items.length - 1;
    var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
XhmikosR's avatar
Dist.  
XhmikosR committed
1450
1451
1452
1453
1454

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

XhmikosR's avatar
XhmikosR committed
1455
    var delta = direction === DIRECTION_PREV ? -1 : 1;
XhmikosR's avatar
XhmikosR committed
1456
    var itemIndex = (activeIndex + delta) % this._items.length;
XhmikosR's avatar
Dist.  
XhmikosR committed
1457
    return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
XhmikosR's avatar
XhmikosR committed
1458
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1459

XhmikosR's avatar
XhmikosR committed
1460
1461
  _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
    var targetIndex = this._getItemIndex(relatedTarget);
XhmikosR's avatar
Dist.  
XhmikosR committed
1462

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

XhmikosR's avatar
XhmikosR committed
1465
    return EventHandler.trigger(this._element, EVENT_SLIDE, {
XhmikosR's avatar
XhmikosR committed
1466
      relatedTarget: relatedTarget,
XhmikosR's avatar
Dist.  
XhmikosR committed
1467
1468
1469
1470
      direction: eventDirectionName,
      from: fromIndex,
      to: targetIndex
    });
XhmikosR's avatar
XhmikosR committed
1471
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1472

XhmikosR's avatar
XhmikosR committed
1473
  _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1474
    if (this._indicatorsElement) {
XhmikosR's avatar
XhmikosR committed
1475
      var indicators = SelectorEngine.find(SELECTOR_ACTIVE, this._indicatorsElement);
XhmikosR's avatar
Dist.  
XhmikosR committed
1476

XhmikosR's avatar
XhmikosR committed
1477
      for (var i = 0; i < indicators.length; i++) {
XhmikosR's avatar
XhmikosR committed
1478
        indicators[i].classList.remove(CLASS_NAME_ACTIVE$1);
XhmikosR's avatar
Dist.  
XhmikosR committed
1479
1480
      }

XhmikosR's avatar
XhmikosR committed
1481
      var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
XhmikosR's avatar
Dist.  
XhmikosR committed
1482
1483

      if (nextIndicator) {
XhmikosR's avatar
XhmikosR committed
1484
        nextIndicator.classList.add(CLASS_NAME_ACTIVE$1);
XhmikosR's avatar
Dist.  
XhmikosR committed
1485
1486
      }
    }
XhmikosR's avatar
XhmikosR committed
1487
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1488

XhmikosR's avatar
XhmikosR committed
1489
1490
  _proto._slide = function _slide(direction, element) {
    var _this4 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
1491

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

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

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

XhmikosR's avatar
XhmikosR committed
1498
1499
1500
1501
1502
1503
    var nextElementIndex = this._getItemIndex(nextElement);

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

XhmikosR's avatar
XhmikosR committed
1505
1506
1507
1508
    if (direction === DIRECTION_NEXT) {
      directionalClassName = CLASS_NAME_LEFT;
      orderClassName = CLASS_NAME_NEXT;
      eventDirectionName = DIRECTION_LEFT;
XhmikosR's avatar
Dist.  
XhmikosR committed
1509
    } else {
XhmikosR's avatar
XhmikosR committed
1510
1511
1512
      directionalClassName = CLASS_NAME_RIGHT;
      orderClassName = CLASS_NAME_PREV;
      eventDirectionName = DIRECTION_RIGHT;
XhmikosR's avatar
Dist.  
XhmikosR committed
1513
1514
    }

XhmikosR's avatar
XhmikosR committed
1515
    if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE$1)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1516
1517
1518
1519
      this._isSliding = false;
      return;
    }

XhmikosR's avatar
XhmikosR committed
1520
    var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
XhmikosR's avatar
Dist.  
XhmikosR committed
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538

    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
1539
    if (this._element.classList.contains(CLASS_NAME_SLIDE)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1540
1541
1542
1543
      nextElement.classList.add(orderClassName);
      reflow(nextElement);
      activeElement.classList.add(directionalClassName);
      nextElement.classList.add(directionalClassName);
XhmikosR's avatar
XhmikosR committed
1544
      var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
XhmikosR's avatar
Dist.  
XhmikosR committed
1545
1546
1547
1548
1549
1550
1551
1552

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

XhmikosR's avatar
XhmikosR committed
1553
1554
      var transitionDuration = getTransitionDurationFromElement(activeElement);
      EventHandler.one(activeElement, TRANSITION_END, function () {
XhmikosR's avatar
XhmikosR committed
1555
        nextElement.classList.remove(directionalClassName, orderClassName);
XhmikosR's avatar
XhmikosR committed
1556
        nextElement.classList.add(CLASS_NAME_ACTIVE$1);
XhmikosR's avatar
XhmikosR committed
1557
        activeElement.classList.remove(CLASS_NAME_ACTIVE$1, orderClassName, directionalClassName);
XhmikosR's avatar
XhmikosR committed
1558
1559
        _this4._isSliding = false;
        setTimeout(function () {
XhmikosR's avatar
XhmikosR committed
1560
          EventHandler.trigger(_this4._element, EVENT_SLID, {
XhmikosR's avatar
Dist.  
XhmikosR committed
1561
1562
1563
1564
1565
1566
1567
1568
1569
            relatedTarget: nextElement,
            direction: eventDirectionName,
            from: activeElementIndex,
            to: nextElementIndex
          });
        }, 0);
      });
      emulateTransitionEnd(activeElement, transitionDuration);
    } else {
XhmikosR's avatar
XhmikosR committed
1570
1571
      activeElement.classList.remove(CLASS_NAME_ACTIVE$1);
      nextElement.classList.add(CLASS_NAME_ACTIVE$1);
XhmikosR's avatar
Dist.  
XhmikosR committed
1572
      this._isSliding = false;
XhmikosR's avatar
XhmikosR committed
1573
      EventHandler.trigger(this._element, EVENT_SLID, {
XhmikosR's avatar
Dist.  
XhmikosR committed
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
        relatedTarget: nextElement,
        direction: eventDirectionName,
        from: activeElementIndex,
        to: nextElementIndex
      });
    }

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

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

XhmikosR's avatar
XhmikosR committed
1590
    var _config = _objectSpread2(_objectSpread2({}, Default), Manipulator.getDataAttributes(element));
XhmikosR's avatar
Dist.  
XhmikosR committed
1591
1592

    if (typeof config === 'object') {
XhmikosR's avatar
XhmikosR committed
1593
      _config = _objectSpread2(_objectSpread2({}, _config), config);
XhmikosR's avatar
Dist.  
XhmikosR committed
1594
1595
    }

XhmikosR's avatar
XhmikosR committed
1596
    var action = typeof config === 'string' ? config : _config.slide;
XhmikosR's avatar
Dist.  
XhmikosR committed
1597
1598
1599
1600
1601
1602
1603
1604
1605

    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
1606
        throw new TypeError("No method named \"" + action + "\"");
XhmikosR's avatar
Dist.  
XhmikosR committed
1607
1608
1609
1610
1611
1612
1613
      }

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

XhmikosR's avatar
XhmikosR committed
1616
  Carousel.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1617
    return this.each(function () {
XhmikosR's avatar
XhmikosR committed
1618
      Carousel.carouselInterface(this, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
1619
    });
XhmikosR's avatar
XhmikosR committed
1620
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1621

XhmikosR's avatar
XhmikosR committed
1622
1623
  Carousel.dataApiClickHandler = function dataApiClickHandler(event) {
    var target = getElementFromSelector(this);
XhmikosR's avatar
Dist.  
XhmikosR committed
1624

XhmikosR's avatar
XhmikosR committed
1625
    if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1626
1627
1628
      return;
    }

XhmikosR's avatar
XhmikosR committed
1629
    var config = _objectSpread2(_objectSpread2({}, Manipulator.getDataAttributes(target)), Manipulator.getDataAttributes(this));
XhmikosR's avatar
Dist.  
XhmikosR committed
1630

XhmikosR's avatar
XhmikosR committed
1631
    var slideIndex = this.getAttribute('data-slide-to');
XhmikosR's avatar
Dist.  
XhmikosR committed
1632
1633
1634
1635
1636

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

XhmikosR's avatar
XhmikosR committed
1637
    Carousel.carouselInterface(target, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
1638
1639
1640
1641
1642
1643

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

    event.preventDefault();
XhmikosR's avatar
XhmikosR committed
1644
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1645

XhmikosR's avatar
XhmikosR committed
1646
  Carousel.getInstance = function getInstance(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1647
    return Data.getData(element, DATA_KEY$2);
XhmikosR's avatar
XhmikosR committed
1648
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1649

XhmikosR's avatar
XhmikosR committed
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
  _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
1664
1665
1666
1667
1668
1669
1670
/**
 * ------------------------------------------------------------------------
 * Data Api implementation
 * ------------------------------------------------------------------------
 */


XhmikosR's avatar
XhmikosR committed
1671
1672
1673
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
1674

XhmikosR's avatar
XhmikosR committed
1675
  for (var i = 0, len = carousels.length; i < len; i++) {
XhmikosR's avatar
XhmikosR committed
1676
    Carousel.carouselInterface(carousels[i], Data.getData(carousels[i], DATA_KEY$2));
XhmikosR's avatar
Dist.  
XhmikosR committed
1677
1678
  }
});
XhmikosR's avatar
XhmikosR committed
1679
var $$3 = getjQuery();
XhmikosR's avatar
Dist.  
XhmikosR committed
1680
1681
1682
1683
1684
1685
1686
/**
 * ------------------------------------------------------------------------
 * jQuery
 * ------------------------------------------------------------------------
 * add .carousel to jQuery only if jQuery is present
 */

1687
1688
/* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
1689
1690
1691
1692
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
1693

XhmikosR's avatar
XhmikosR committed
1694
1695
1696
  $$3.fn[NAME$2].noConflict = function () {
    $$3.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
    return Carousel.jQueryInterface;
XhmikosR's avatar
Dist.  
XhmikosR committed
1697
1698
1699
1700
1701
1702
1703
1704
1705
  };
}

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

XhmikosR's avatar
XhmikosR committed
1706
var NAME$3 = 'collapse';
1707
var VERSION$3 = '5.0.0-alpha1';
XhmikosR's avatar
XhmikosR committed
1708
1709
1710
1711
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
1712
1713
1714
  toggle: true,
  parent: ''
};
XhmikosR's avatar
XhmikosR committed
1715
var DefaultType$1 = {
XhmikosR's avatar
Dist.  
XhmikosR committed
1716
1717
1718
  toggle: 'boolean',
  parent: '(string|element)'
};
XhmikosR's avatar
XhmikosR committed
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
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
1732
1733
1734
1735
1736
/**
 * ------------------------------------------------------------------------
 * Class Definition
 * ------------------------------------------------------------------------
 */
XhmikosR's avatar
Dist.  
XhmikosR committed
1737

XhmikosR's avatar
XhmikosR committed
1738
var Collapse = /*#__PURE__*/function () {
XhmikosR's avatar
XhmikosR committed
1739
  function Collapse(element, config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1740
1741
1742
    this._isTransitioning = false;
    this._element = element;
    this._config = this._getConfig(config);
XhmikosR's avatar
XhmikosR committed
1743
1744
    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
XhmikosR committed
1745
1746
1747
1748

    for (var i = 0, len = toggleList.length; i < len; i++) {
      var elem = toggleList[i];
      var selector = getSelectorFromElement(elem);
XhmikosR's avatar
XhmikosR committed
1749
      var filterElement = SelectorEngine.find(selector).filter(function (foundElem) {
XhmikosR's avatar
XhmikosR committed
1750
1751
        return foundElem === element;
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773

      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
1774
  var _proto = Collapse.prototype;
XhmikosR's avatar
Dist.  
XhmikosR committed
1775

XhmikosR's avatar
XhmikosR committed
1776
1777
  // Public
  _proto.toggle = function toggle() {
XhmikosR's avatar
XhmikosR committed
1778
    if (this._element.classList.contains(CLASS_NAME_SHOW)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1779
1780
1781
1782
      this.hide();
    } else {
      this.show();
    }
XhmikosR's avatar
XhmikosR committed
1783
1784
1785
1786
  };

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

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

XhmikosR's avatar
XhmikosR committed
1792
1793
    var actives;
    var activesData;
XhmikosR's avatar
Dist.  
XhmikosR committed
1794
1795

    if (this._parent) {
XhmikosR's avatar
XhmikosR committed
1796
      actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent).filter(function (elem) {
XhmikosR's avatar
XhmikosR committed
1797
1798
        if (typeof _this._config.parent === 'string') {
          return elem.getAttribute('data-parent') === _this._config.parent;
XhmikosR's avatar
Dist.  
XhmikosR committed
1799
1800
        }

XhmikosR's avatar
XhmikosR committed
1801
        return elem.classList.contains(CLASS_NAME_COLLAPSE);
XhmikosR's avatar
Dist.  
XhmikosR committed
1802
1803
1804
1805
1806
1807
1808
      });

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

XhmikosR's avatar
XhmikosR committed
1809
    var container = SelectorEngine.findOne(this._selector);
XhmikosR's avatar
Dist.  
XhmikosR committed
1810
1811

    if (actives) {
XhmikosR's avatar
XhmikosR committed
1812
1813
1814
      var tempActiveData = actives.filter(function (elem) {
        return container !== elem;
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
1815
1816
1817
1818
1819
1820
1821
      activesData = tempActiveData[0] ? Data.getData(tempActiveData[0], DATA_KEY$3) : null;

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

XhmikosR's avatar
XhmikosR committed
1822
    var startEvent = EventHandler.trigger(this._element, EVENT_SHOW);
XhmikosR's avatar
Dist.  
XhmikosR committed
1823
1824
1825
1826
1827
1828

    if (startEvent.defaultPrevented) {
      return;
    }

    if (actives) {
XhmikosR's avatar
XhmikosR committed
1829
      actives.forEach(function (elemActive) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1830
        if (container !== elemActive) {
XhmikosR's avatar
XhmikosR committed
1831
          Collapse.collapseInterface(elemActive, 'hide');
XhmikosR's avatar
Dist.  
XhmikosR committed
1832
1833
1834
1835
1836
1837
1838
1839
        }

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

XhmikosR's avatar
XhmikosR committed
1840
    var dimension = this._getDimension();
XhmikosR's avatar
Dist.  
XhmikosR committed
1841

XhmikosR's avatar
XhmikosR committed
1842
    this._element.classList.remove(CLASS_NAME_COLLAPSE);
XhmikosR's avatar
Dist.  
XhmikosR committed
1843

XhmikosR's avatar
XhmikosR committed
1844
    this._element.classList.add(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
Dist.  
XhmikosR committed
1845
1846
1847
1848

    this._element.style[dimension] = 0;

    if (this._triggerArray.length) {
XhmikosR's avatar
XhmikosR committed
1849
      this._triggerArray.forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
1850
        element.classList.remove(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
Dist.  
XhmikosR committed
1851
1852
1853
1854
1855
1856
        element.setAttribute('aria-expanded', true);
      });
    }

    this.setTransitioning(true);

XhmikosR's avatar
XhmikosR committed
1857
    var complete = function complete() {
XhmikosR's avatar
XhmikosR committed
1858
      _this._element.classList.remove(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
XhmikosR committed
1859

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

XhmikosR's avatar
XhmikosR committed
1862
      _this._element.style[dimension] = '';
XhmikosR's avatar
Dist.  
XhmikosR committed
1863

XhmikosR's avatar
XhmikosR committed
1864
      _this.setTransitioning(false);
XhmikosR's avatar
Dist.  
XhmikosR committed
1865

XhmikosR's avatar
XhmikosR committed
1866
      EventHandler.trigger(_this._element, EVENT_SHOWN);
XhmikosR's avatar
Dist.  
XhmikosR committed
1867
1868
    };

XhmikosR's avatar
XhmikosR committed
1869
1870
1871
    var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
    var scrollSize = "scroll" + capitalizedDimension;
    var transitionDuration = getTransitionDurationFromElement(this._element);
XhmikosR's avatar
Dist.  
XhmikosR committed
1872
1873
    EventHandler.one(this._element, TRANSITION_END, complete);
    emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
XhmikosR committed
1874
1875
1876
1877
1878
    this._element.style[dimension] = this._element[scrollSize] + "px";
  };

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

XhmikosR's avatar
XhmikosR committed
1880
    if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1881
1882
1883
      return;
    }

XhmikosR's avatar
XhmikosR committed
1884
    var startEvent = EventHandler.trigger(this._element, EVENT_HIDE);
XhmikosR's avatar
Dist.  
XhmikosR committed
1885
1886
1887
1888
1889

    if (startEvent.defaultPrevented) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
1890
    var dimension = this._getDimension();
XhmikosR's avatar
Dist.  
XhmikosR committed
1891

XhmikosR's avatar
XhmikosR committed
1892
    this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
XhmikosR's avatar
Dist.  
XhmikosR committed
1893
1894
    reflow(this._element);

XhmikosR's avatar
XhmikosR committed
1895
    this._element.classList.add(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
Dist.  
XhmikosR committed
1896

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

XhmikosR's avatar
XhmikosR committed
1899
    var triggerArrayLength = this._triggerArray.length;
XhmikosR's avatar
Dist.  
XhmikosR committed
1900
1901

    if (triggerArrayLength > 0) {
XhmikosR's avatar
XhmikosR committed
1902
1903
      for (var i = 0; i < triggerArrayLength; i++) {
        var trigger = this._triggerArray[i];
XhmikosR's avatar
XhmikosR committed
1904
        var elem = getElementFromSelector(trigger);
XhmikosR's avatar
Dist.  
XhmikosR committed
1905

XhmikosR's avatar
XhmikosR committed
1906
1907
        if (elem && !elem.classList.contains(CLASS_NAME_SHOW)) {
          trigger.classList.add(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
XhmikosR committed
1908
          trigger.setAttribute('aria-expanded', false);
XhmikosR's avatar
Dist.  
XhmikosR committed
1909
1910
1911
1912
1913
1914
        }
      }
    }

    this.setTransitioning(true);

XhmikosR's avatar
XhmikosR committed
1915
1916
    var complete = function complete() {
      _this2.setTransitioning(false);
XhmikosR's avatar
Dist.  
XhmikosR committed
1917

XhmikosR's avatar
XhmikosR committed
1918
      _this2._element.classList.remove(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
Dist.  
XhmikosR committed
1919

XhmikosR's avatar
XhmikosR committed
1920
      _this2._element.classList.add(CLASS_NAME_COLLAPSE);
XhmikosR's avatar
Dist.  
XhmikosR committed
1921

XhmikosR's avatar
XhmikosR committed
1922
      EventHandler.trigger(_this2._element, EVENT_HIDDEN);
XhmikosR's avatar
Dist.  
XhmikosR committed
1923
1924
1925
    };

    this._element.style[dimension] = '';
XhmikosR's avatar
XhmikosR committed
1926
    var transitionDuration = getTransitionDurationFromElement(this._element);
XhmikosR's avatar
Dist.  
XhmikosR committed
1927
1928
    EventHandler.one(this._element, TRANSITION_END, complete);
    emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
XhmikosR committed
1929
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1930

XhmikosR's avatar
XhmikosR committed
1931
  _proto.setTransitioning = function setTransitioning(isTransitioning) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1932
    this._isTransitioning = isTransitioning;
XhmikosR's avatar
XhmikosR committed
1933
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1934

XhmikosR's avatar
XhmikosR committed
1935
  _proto.dispose = function dispose() {
XhmikosR's avatar
Dist.  
XhmikosR committed
1936
1937
1938
1939
1940
1941
1942
    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
1943
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
1944

XhmikosR's avatar
XhmikosR committed
1945
  _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
1946
    config = _objectSpread2(_objectSpread2({}, Default$1), config);
XhmikosR's avatar
Dist.  
XhmikosR committed
1947
1948
1949
1950
    config.toggle = Boolean(config.toggle); // Coerce string values

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

XhmikosR's avatar
XhmikosR committed
1953
  _proto._getDimension = function _getDimension() {
XhmikosR's avatar
XhmikosR committed
1954
    var hasWidth = this._element.classList.contains(WIDTH);
XhmikosR's avatar
Dist.  
XhmikosR committed
1955

XhmikosR's avatar
XhmikosR committed
1956
    return hasWidth ? WIDTH : HEIGHT;
XhmikosR's avatar
XhmikosR committed
1957
1958
1959
1960
  };

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

XhmikosR's avatar
XhmikosR committed
1962
    var parent = this._config.parent;
XhmikosR's avatar
Dist.  
XhmikosR committed
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972

    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
1973
1974
    var selector = SELECTOR_DATA_TOGGLE$1 + "[data-parent=\"" + parent + "\"]";
    SelectorEngine.find(selector, parent).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
1975
      var selected = getElementFromSelector(element);
1976
1977

      _this3._addAriaAndCollapsedClass(selected, [element]);
XhmikosR's avatar
Dist.  
XhmikosR committed
1978
1979
    });
    return parent;
XhmikosR's avatar
XhmikosR committed
1980
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
1981

XhmikosR's avatar
XhmikosR committed
1982
  _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1983
    if (element) {
XhmikosR's avatar
XhmikosR committed
1984
      var isOpen = element.classList.contains(CLASS_NAME_SHOW);
XhmikosR's avatar
Dist.  
XhmikosR committed
1985
1986

      if (triggerArray.length) {
XhmikosR's avatar
XhmikosR committed
1987
        triggerArray.forEach(function (elem) {
XhmikosR's avatar
Dist.  
XhmikosR committed
1988
          if (isOpen) {
XhmikosR's avatar
XhmikosR committed
1989
            elem.classList.remove(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
Dist.  
XhmikosR committed
1990
          } else {
XhmikosR's avatar
XhmikosR committed
1991
            elem.classList.add(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
Dist.  
XhmikosR committed
1992
1993
1994
1995
1996
1997
1998
          }

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

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