bootstrap.js 152 KB
Newer Older
XhmikosR's avatar
Dist    
XhmikosR committed
1001
    };
Jacob Thornton's avatar
Jacob Thornton committed
1002

XhmikosR's avatar
Dist    
XhmikosR committed
1003
    _proto.dispose = function dispose() {
XhmikosR's avatar
XhmikosR committed
1004
      Data.removeData(this._element, DATA_KEY$1);
XhmikosR's avatar
Dist    
XhmikosR committed
1005
      this._element = null;
Mark Otto's avatar
Mark Otto committed
1006
1007
    } // Static
    ;
Jacob Thornton's avatar
Jacob Thornton committed
1008

XhmikosR's avatar
XhmikosR committed
1009
    Button.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
Dist    
XhmikosR committed
1010
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
1011
        var data = Data.getData(this, DATA_KEY$1);
Jacob Thornton's avatar
Jacob Thornton committed
1012

XhmikosR's avatar
Dist    
XhmikosR committed
1013
1014
1015
        if (!data) {
          data = new Button(this);
        }
Mark Otto's avatar
grunt    
Mark Otto committed
1016

XhmikosR's avatar
Dist    
XhmikosR committed
1017
1018
        if (config === 'toggle') {
          data[config]();
Mark Otto's avatar
grunt    
Mark Otto committed
1019
        }
XhmikosR's avatar
Dist    
XhmikosR committed
1020
1021
      });
    };
Jacob Thornton's avatar
Jacob Thornton committed
1022

XhmikosR's avatar
XhmikosR committed
1023
    Button.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
1024
1025
1026
      return Data.getData(element, DATA_KEY$1);
    };

XhmikosR's avatar
Dist    
XhmikosR committed
1027
1028
1029
1030
1031
1032
    _createClass(Button, null, [{
      key: "VERSION",
      get: function get() {
        return VERSION$1;
      }
    }]);
Mark Otto's avatar
dist    
Mark Otto committed
1033

XhmikosR's avatar
Dist    
XhmikosR committed
1034
1035
1036
1037
1038
1039
1040
    return Button;
  }();
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
Jacob Thornton's avatar
Jacob Thornton committed
1041
1042


XhmikosR's avatar
XhmikosR committed
1043
  EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE_CARROT, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1044
    event.preventDefault();
XhmikosR's avatar
XhmikosR committed
1045
    var button = event.target.closest(SELECTOR_BUTTON);
XhmikosR's avatar
XhmikosR committed
1046
1047
1048
1049
1050
1051
1052
1053
    var data = Data.getData(button, DATA_KEY$1);

    if (!data) {
      data = new Button(button);
    }

    data.toggle();
  });
XhmikosR's avatar
XhmikosR committed
1054
  EventHandler.on(document, EVENT_FOCUS_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, function (event) {
XhmikosR's avatar
XhmikosR committed
1055
    var button = event.target.closest(SELECTOR_BUTTON);
XhmikosR's avatar
XhmikosR committed
1056
1057

    if (button) {
XhmikosR's avatar
XhmikosR committed
1058
      button.classList.add(CLASS_NAME_FOCUS);
XhmikosR's avatar
XhmikosR committed
1059
    }
XhmikosR's avatar
XhmikosR committed
1060
  });
XhmikosR's avatar
XhmikosR committed
1061
  EventHandler.on(document, EVENT_BLUR_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, function (event) {
XhmikosR's avatar
XhmikosR committed
1062
    var button = event.target.closest(SELECTOR_BUTTON);
XhmikosR's avatar
XhmikosR committed
1063
1064

    if (button) {
XhmikosR's avatar
XhmikosR committed
1065
      button.classList.remove(CLASS_NAME_FOCUS);
XhmikosR's avatar
XhmikosR committed
1066
    }
XhmikosR's avatar
Dist    
XhmikosR committed
1067
  });
XhmikosR's avatar
XhmikosR committed
1068
  var $$2 = getjQuery();
XhmikosR's avatar
Dist    
XhmikosR committed
1069
1070
1071
1072
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
1073
1074
1075
   * add .button to jQuery only if jQuery is present
   */

1076
1077
  /* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
1078
1079
1080
1081
  if ($$2) {
    var JQUERY_NO_CONFLICT$1 = $$2.fn[NAME$1];
    $$2.fn[NAME$1] = Button.jQueryInterface;
    $$2.fn[NAME$1].Constructor = Button;
XhmikosR's avatar
XhmikosR committed
1082

XhmikosR's avatar
XhmikosR committed
1083
1084
1085
    $$2.fn[NAME$1].noConflict = function () {
      $$2.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
      return Button.jQueryInterface;
XhmikosR's avatar
XhmikosR committed
1086
1087
1088
1089
1090
    };
  }

  /**
   * --------------------------------------------------------------------------
1091
   * Bootstrap (v5.0.0-alpha1): dom/manipulator.js
XhmikosR's avatar
XhmikosR committed
1092
1093
   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
   * --------------------------------------------------------------------------
XhmikosR's avatar
Dist    
XhmikosR committed
1094
   */
XhmikosR's avatar
XhmikosR committed
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
  function normalizeData(val) {
    if (val === 'true') {
      return true;
    }

    if (val === 'false') {
      return false;
    }

    if (val === Number(val).toString()) {
      return Number(val);
    }

    if (val === '' || val === 'null') {
      return null;
    }

    return val;
  }
Jacob Thornton's avatar
Jacob Thornton committed
1114

XhmikosR's avatar
XhmikosR committed
1115
1116
  function normalizeDataKey(key) {
    return key.replace(/[A-Z]/g, function (chr) {
XhmikosR's avatar
XhmikosR committed
1117
      return "-" + chr.toLowerCase();
XhmikosR's avatar
XhmikosR committed
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
    });
  }

  var Manipulator = {
    setDataAttribute: function setDataAttribute(element, key, value) {
      element.setAttribute("data-" + normalizeDataKey(key), value);
    },
    removeDataAttribute: function removeDataAttribute(element, key) {
      element.removeAttribute("data-" + normalizeDataKey(key));
    },
    getDataAttributes: function getDataAttributes(element) {
      if (!element) {
        return {};
      }

1133
      var attributes = _objectSpread2({}, element.dataset);
XhmikosR's avatar
XhmikosR committed
1134
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

      Object.keys(attributes).forEach(function (key) {
        attributes[key] = normalizeData(attributes[key]);
      });
      return attributes;
    },
    getDataAttribute: function getDataAttribute(element, key) {
      return normalizeData(element.getAttribute("data-" + normalizeDataKey(key)));
    },
    offset: function offset(element) {
      var rect = element.getBoundingClientRect();
      return {
        top: rect.top + document.body.scrollTop,
        left: rect.left + document.body.scrollLeft
      };
    },
    position: function position(element) {
      return {
        top: element.offsetTop,
        left: element.offsetLeft
      };
    },
    toggleClass: function toggleClass(element, className) {
      if (!element) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
1160

XhmikosR's avatar
XhmikosR committed
1161
1162
1163
1164
1165
1166
      if (element.classList.contains(className)) {
        element.classList.remove(className);
      } else {
        element.classList.add(className);
      }
    }
XhmikosR's avatar
Dist    
XhmikosR committed
1167
  };
Jacob Thornton's avatar
Jacob Thornton committed
1168
1169

  /**
XhmikosR's avatar
Dist    
XhmikosR committed
1170
1171
1172
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
Jacob Thornton's avatar
Jacob Thornton committed
1173
   */
Mark Otto's avatar
dist    
Mark Otto committed
1174

XhmikosR's avatar
Dist    
XhmikosR committed
1175
  var NAME$2 = 'carousel';
1176
  var VERSION$2 = '5.0.0-alpha1';
XhmikosR's avatar
Dist    
XhmikosR committed
1177
1178
1179
  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
1180
1181
  var ARROW_LEFT_KEY = 'ArrowLeft';
  var ARROW_RIGHT_KEY = 'ArrowRight';
XhmikosR's avatar
Dist    
XhmikosR committed
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
  var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch

  var SWIPE_THRESHOLD = 40;
  var Default = {
    interval: 5000,
    keyboard: true,
    slide: false,
    pause: 'hover',
    wrap: true,
    touch: true
  };
  var DefaultType = {
    interval: '(number|boolean)',
    keyboard: 'boolean',
    slide: '(boolean|string)',
    pause: '(string|boolean)',
    wrap: 'boolean',
    touch: 'boolean'
  };
XhmikosR's avatar
XhmikosR committed
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
  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';
  var SELECTOR_ACTIVE$1 = '.active';
  var SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
  var SELECTOR_ITEM = '.carousel-item';
  var SELECTOR_ITEM_IMG = '.carousel-item img';
  var SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
  var SELECTOR_INDICATORS = '.carousel-indicators';
  var SELECTOR_DATA_SLIDE = '[data-slide], [data-slide-to]';
  var SELECTOR_DATA_RIDE = '[data-ride="carousel"]';
XhmikosR's avatar
Dist    
XhmikosR committed
1234
1235
1236
1237
  var PointerType = {
    TOUCH: 'touch',
    PEN: 'pen'
  };
XhmikosR's avatar
XhmikosR committed
1238
1239
1240
1241
1242
  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */
XhmikosR's avatar
Dist    
XhmikosR committed
1243

XhmikosR's avatar
XhmikosR committed
1244
  var Carousel = /*#__PURE__*/function () {
XhmikosR's avatar
Dist    
XhmikosR committed
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
    function Carousel(element, config) {
      this._items = null;
      this._interval = null;
      this._activeElement = null;
      this._isPaused = false;
      this._isSliding = false;
      this.touchTimeout = null;
      this.touchStartX = 0;
      this.touchDeltaX = 0;
      this._config = this._getConfig(config);
      this._element = element;
XhmikosR's avatar
XhmikosR committed
1256
      this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element);
XhmikosR's avatar
Dist    
XhmikosR committed
1257
      this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
XhmikosR's avatar
XhmikosR committed
1258
      this._pointerEvent = Boolean(window.PointerEvent);
XhmikosR's avatar
Dist    
XhmikosR committed
1259
1260

      this._addEventListeners();
XhmikosR's avatar
XhmikosR committed
1261
1262

      Data.setData(element, DATA_KEY$2, this);
XhmikosR's avatar
Dist    
XhmikosR committed
1263
1264
1265
1266
1267
1268
1269
1270
    } // Getters


    var _proto = Carousel.prototype;

    // Public
    _proto.next = function next() {
      if (!this._isSliding) {
XhmikosR's avatar
XhmikosR committed
1271
        this._slide(DIRECTION_NEXT);
XhmikosR's avatar
Dist    
XhmikosR committed
1272
      }
Mark Otto's avatar
dist    
Mark Otto committed
1273
    };
Jacob Thornton's avatar
Jacob Thornton committed
1274

XhmikosR's avatar
Dist    
XhmikosR committed
1275
1276
1277
    _proto.nextWhenVisible = function nextWhenVisible() {
      // Don't call next when the page isn't visible
      // or the carousel or its parent isn't visible
XhmikosR's avatar
XhmikosR committed
1278
      if (!document.hidden && isVisible(this._element)) {
XhmikosR's avatar
Dist    
XhmikosR committed
1279
1280
        this.next();
      }
Mark Otto's avatar
grunt    
Mark Otto committed
1281
1282
    };

XhmikosR's avatar
Dist    
XhmikosR committed
1283
1284
    _proto.prev = function prev() {
      if (!this._isSliding) {
XhmikosR's avatar
XhmikosR committed
1285
        this._slide(DIRECTION_PREV);
XhmikosR's avatar
Dist    
XhmikosR committed
1286
1287
      }
    };
Mark Otto's avatar
grunt    
Mark Otto committed
1288

XhmikosR's avatar
Dist    
XhmikosR committed
1289
1290
1291
1292
    _proto.pause = function pause(event) {
      if (!event) {
        this._isPaused = true;
      }
Jacob Thornton's avatar
Jacob Thornton committed
1293

XhmikosR's avatar
XhmikosR committed
1294
      if (SelectorEngine.findOne(SELECTOR_NEXT_PREV, this._element)) {
XhmikosR's avatar
XhmikosR committed
1295
        triggerTransitionEnd(this._element);
XhmikosR's avatar
Dist    
XhmikosR committed
1296
1297
        this.cycle(true);
      }
Mark Otto's avatar
grunt    
Mark Otto committed
1298

XhmikosR's avatar
Dist    
XhmikosR committed
1299
1300
1301
      clearInterval(this._interval);
      this._interval = null;
    };
Mark Otto's avatar
grunt    
Mark Otto committed
1302

XhmikosR's avatar
Dist    
XhmikosR committed
1303
1304
1305
1306
    _proto.cycle = function cycle(event) {
      if (!event) {
        this._isPaused = false;
      }
Mark Otto's avatar
grunt    
Mark Otto committed
1307

XhmikosR's avatar
Dist    
XhmikosR committed
1308
      if (this._interval) {
Mark Otto's avatar
dist    
Mark Otto committed
1309
1310
        clearInterval(this._interval);
        this._interval = null;
XhmikosR's avatar
Dist    
XhmikosR committed
1311
      }
Mark Otto's avatar
grunt    
Mark Otto committed
1312

XhmikosR's avatar
XhmikosR committed
1313
      if (this._config && this._config.interval && !this._isPaused) {
XhmikosR's avatar
Dist    
XhmikosR committed
1314
1315
1316
        this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
1317

XhmikosR's avatar
Dist    
XhmikosR committed
1318
1319
    _proto.to = function to(index) {
      var _this = this;
Jacob Thornton's avatar
Jacob Thornton committed
1320

XhmikosR's avatar
XhmikosR committed
1321
      this._activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element);
Jacob Thornton's avatar
Jacob Thornton committed
1322

XhmikosR's avatar
Dist    
XhmikosR committed
1323
      var activeIndex = this._getItemIndex(this._activeElement);
Jacob Thornton's avatar
Jacob Thornton committed
1324

XhmikosR's avatar
Dist    
XhmikosR committed
1325
1326
1327
      if (index > this._items.length - 1 || index < 0) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
1328

XhmikosR's avatar
Dist    
XhmikosR committed
1329
      if (this._isSliding) {
XhmikosR's avatar
XhmikosR committed
1330
        EventHandler.one(this._element, EVENT_SLID, function () {
XhmikosR's avatar
Dist    
XhmikosR committed
1331
1332
1333
1334
          return _this.to(index);
        });
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
1335

XhmikosR's avatar
Dist    
XhmikosR committed
1336
1337
1338
1339
1340
      if (activeIndex === index) {
        this.pause();
        this.cycle();
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
1341

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

XhmikosR's avatar
Dist    
XhmikosR committed
1344
1345
      this._slide(direction, this._items[index]);
    };
Mark Otto's avatar
dist    
Mark Otto committed
1346

XhmikosR's avatar
Dist    
XhmikosR committed
1347
    _proto.dispose = function dispose() {
XhmikosR's avatar
XhmikosR committed
1348
1349
      EventHandler.off(this._element, EVENT_KEY$2);
      Data.removeData(this._element, DATA_KEY$2);
XhmikosR's avatar
Dist    
XhmikosR committed
1350
1351
1352
1353
1354
1355
1356
1357
      this._items = null;
      this._config = null;
      this._element = null;
      this._interval = null;
      this._isPaused = null;
      this._isSliding = null;
      this._activeElement = null;
      this._indicatorsElement = null;
Mark Otto's avatar
Mark Otto committed
1358
1359
    } // Private
    ;
XhmikosR's avatar
Dist    
XhmikosR committed
1360
1361

    _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
1362
      config = _objectSpread2(_objectSpread2({}, Default), config);
XhmikosR's avatar
XhmikosR committed
1363
      typeCheckConfig(NAME$2, config, DefaultType);
XhmikosR's avatar
Dist    
XhmikosR committed
1364
1365
      return config;
    };
Mark Otto's avatar
dist    
Mark Otto committed
1366

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

XhmikosR's avatar
Dist    
XhmikosR committed
1370
1371
1372
      if (absDeltax <= SWIPE_THRESHOLD) {
        return;
      }
Mark Otto's avatar
grunt    
Mark Otto committed
1373

XhmikosR's avatar
XhmikosR committed
1374
1375
      var direction = absDeltax / this.touchDeltaX;
      this.touchDeltaX = 0; // swipe left
Jacob Thornton's avatar
Jacob Thornton committed
1376

XhmikosR's avatar
Dist    
XhmikosR committed
1377
1378
1379
      if (direction > 0) {
        this.prev();
      } // swipe right
Mark Otto's avatar
dist    
Mark Otto committed
1380
1381


XhmikosR's avatar
Dist    
XhmikosR committed
1382
1383
1384
1385
      if (direction < 0) {
        this.next();
      }
    };
Mark Otto's avatar
grunt    
Mark Otto committed
1386

XhmikosR's avatar
Dist    
XhmikosR committed
1387
1388
    _proto._addEventListeners = function _addEventListeners() {
      var _this2 = this;
Mark Otto's avatar
dist    
Mark Otto committed
1389

XhmikosR's avatar
Dist    
XhmikosR committed
1390
      if (this._config.keyboard) {
XhmikosR's avatar
XhmikosR committed
1391
        EventHandler.on(this._element, EVENT_KEYDOWN, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1392
1393
1394
          return _this2._keydown(event);
        });
      }
Mark Otto's avatar
dist    
Mark Otto committed
1395

XhmikosR's avatar
Dist    
XhmikosR committed
1396
      if (this._config.pause === 'hover') {
XhmikosR's avatar
XhmikosR committed
1397
        EventHandler.on(this._element, EVENT_MOUSEENTER, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1398
          return _this2.pause(event);
XhmikosR's avatar
XhmikosR committed
1399
        });
XhmikosR's avatar
XhmikosR committed
1400
        EventHandler.on(this._element, EVENT_MOUSELEAVE, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1401
1402
1403
          return _this2.cycle(event);
        });
      }
Jacob Thornton's avatar
Jacob Thornton committed
1404

1405
      if (this._config.touch && this._touchSupported) {
Mark Otto's avatar
Mark Otto committed
1406
1407
        this._addTouchEventListeners();
      }
XhmikosR's avatar
Dist    
XhmikosR committed
1408
    };
Jacob Thornton's avatar
Jacob Thornton committed
1409

XhmikosR's avatar
Dist    
XhmikosR committed
1410
1411
    _proto._addTouchEventListeners = function _addTouchEventListeners() {
      var _this3 = this;
Mark Otto's avatar
dist    
Mark Otto committed
1412

XhmikosR's avatar
Dist    
XhmikosR committed
1413
      var start = function start(event) {
XhmikosR's avatar
XhmikosR committed
1414
1415
        if (_this3._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
          _this3.touchStartX = event.clientX;
XhmikosR's avatar
Dist    
XhmikosR committed
1416
        } else if (!_this3._pointerEvent) {
XhmikosR's avatar
XhmikosR committed
1417
          _this3.touchStartX = event.touches[0].clientX;
Mark Otto's avatar
dist    
Mark Otto committed
1418
1419
        }
      };
Jacob Thornton's avatar
Jacob Thornton committed
1420

XhmikosR's avatar
Dist    
XhmikosR committed
1421
1422
      var move = function move(event) {
        // ensure swiping with one touch and not pinching
XhmikosR's avatar
XhmikosR committed
1423
        if (event.touches && event.touches.length > 1) {
XhmikosR's avatar
Dist    
XhmikosR committed
1424
1425
          _this3.touchDeltaX = 0;
        } else {
XhmikosR's avatar
XhmikosR committed
1426
          _this3.touchDeltaX = event.touches[0].clientX - _this3.touchStartX;
XhmikosR's avatar
Dist    
XhmikosR committed
1427
        }
Mark Otto's avatar
dist    
Mark Otto committed
1428
      };
Jacob Thornton's avatar
Jacob Thornton committed
1429

XhmikosR's avatar
Dist    
XhmikosR committed
1430
      var end = function end(event) {
XhmikosR's avatar
XhmikosR committed
1431
1432
        if (_this3._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
          _this3.touchDeltaX = event.clientX - _this3.touchStartX;
XhmikosR's avatar
Dist    
XhmikosR committed
1433
        }
Jacob Thornton's avatar
Jacob Thornton committed
1434

XhmikosR's avatar
Dist    
XhmikosR committed
1435
        _this3._handleSwipe();
Mark Otto's avatar
dist    
Mark Otto committed
1436

XhmikosR's avatar
Dist    
XhmikosR committed
1437
1438
1439
1440
1441
1442
1443
1444
1445
        if (_this3._config.pause === 'hover') {
          // If it's a touch-enabled device, mouseenter/leave are fired as
          // part of the mouse compatibility events on first tap - the carousel
          // would stop cycling until user tapped out of it;
          // here, we listen for touchend, explicitly pause the carousel
          // (as if it's the second time we tap on it, mouseenter compat event
          // is NOT fired) and after a timeout (to allow for mouse compatibility
          // events to fire) we explicitly restart cycling
          _this3.pause();
Mark Otto's avatar
dist    
Mark Otto committed
1446

XhmikosR's avatar
Dist    
XhmikosR committed
1447
1448
1449
          if (_this3.touchTimeout) {
            clearTimeout(_this3.touchTimeout);
          }
Jacob Thornton's avatar
Jacob Thornton committed
1450

XhmikosR's avatar
Dist    
XhmikosR committed
1451
1452
1453
1454
          _this3.touchTimeout = setTimeout(function (event) {
            return _this3.cycle(event);
          }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
        }
Mark Otto's avatar
dist    
Mark Otto committed
1455
      };
Jacob Thornton's avatar
Jacob Thornton committed
1456

XhmikosR's avatar
XhmikosR committed
1457
1458
      SelectorEngine.find(SELECTOR_ITEM_IMG, this._element).forEach(function (itemImg) {
        EventHandler.on(itemImg, EVENT_DRAG_START, function (e) {
XhmikosR's avatar
XhmikosR committed
1459
1460
          return e.preventDefault();
        });
XhmikosR's avatar
Dist    
XhmikosR committed
1461
      });
Jacob Thornton's avatar
Jacob Thornton committed
1462

XhmikosR's avatar
Dist    
XhmikosR committed
1463
      if (this._pointerEvent) {
XhmikosR's avatar
XhmikosR committed
1464
        EventHandler.on(this._element, EVENT_POINTERDOWN, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1465
1466
          return start(event);
        });
XhmikosR's avatar
XhmikosR committed
1467
        EventHandler.on(this._element, EVENT_POINTERUP, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1468
1469
          return end(event);
        });
Jacob Thornton's avatar
Jacob Thornton committed
1470

XhmikosR's avatar
XhmikosR committed
1471
        this._element.classList.add(CLASS_NAME_POINTER_EVENT);
XhmikosR's avatar
Dist    
XhmikosR committed
1472
      } else {
XhmikosR's avatar
XhmikosR committed
1473
        EventHandler.on(this._element, EVENT_TOUCHSTART, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1474
          return start(event);
Mark Otto's avatar
dist    
Mark Otto committed
1475
        });
XhmikosR's avatar
XhmikosR committed
1476
        EventHandler.on(this._element, EVENT_TOUCHMOVE, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1477
1478
          return move(event);
        });
XhmikosR's avatar
XhmikosR committed
1479
        EventHandler.on(this._element, EVENT_TOUCHEND, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
1480
1481
1482
1483
          return end(event);
        });
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
1484

XhmikosR's avatar
Dist    
XhmikosR committed
1485
1486
1487
1488
    _proto._keydown = function _keydown(event) {
      if (/input|textarea/i.test(event.target.tagName)) {
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
1489

XhmikosR's avatar
XhmikosR committed
1490
1491
      switch (event.key) {
        case ARROW_LEFT_KEY:
XhmikosR's avatar
Dist    
XhmikosR committed
1492
1493
1494
          event.preventDefault();
          this.prev();
          break;
Mark Otto's avatar
dist    
Mark Otto committed
1495

XhmikosR's avatar
XhmikosR committed
1496
        case ARROW_RIGHT_KEY:
XhmikosR's avatar
Dist    
XhmikosR committed
1497
1498
1499
1500
1501
          event.preventDefault();
          this.next();
          break;
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
1502

XhmikosR's avatar
Dist    
XhmikosR committed
1503
    _proto._getItemIndex = function _getItemIndex(element) {
XhmikosR's avatar
XhmikosR committed
1504
      this._items = element && element.parentNode ? SelectorEngine.find(SELECTOR_ITEM, element.parentNode) : [];
XhmikosR's avatar
Dist    
XhmikosR committed
1505
1506
      return this._items.indexOf(element);
    };
Mark Otto's avatar
grunt    
Mark Otto committed
1507

XhmikosR's avatar
Dist    
XhmikosR committed
1508
    _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
XhmikosR's avatar
XhmikosR committed
1509
1510
      var isNextDirection = direction === DIRECTION_NEXT;
      var isPrevDirection = direction === DIRECTION_PREV;
Mark Otto's avatar
grunt    
Mark Otto committed
1511

XhmikosR's avatar
Dist    
XhmikosR committed
1512
      var activeIndex = this._getItemIndex(activeElement);
Jacob Thornton's avatar
Jacob Thornton committed
1513

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

XhmikosR's avatar
Dist    
XhmikosR committed
1517
1518
1519
      if (isGoingToWrap && !this._config.wrap) {
        return activeElement;
      }
Jacob Thornton's avatar
Jacob Thornton committed
1520

XhmikosR's avatar
XhmikosR committed
1521
      var delta = direction === DIRECTION_PREV ? -1 : 1;
XhmikosR's avatar
Dist    
XhmikosR committed
1522
1523
1524
      var itemIndex = (activeIndex + delta) % this._items.length;
      return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
    };
Jacob Thornton's avatar
Jacob Thornton committed
1525

XhmikosR's avatar
Dist    
XhmikosR committed
1526
1527
    _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
      var targetIndex = this._getItemIndex(relatedTarget);
Mark Otto's avatar
grunt    
Mark Otto committed
1528

XhmikosR's avatar
XhmikosR committed
1529
      var fromIndex = this._getItemIndex(SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element));
Jacob Thornton's avatar
Jacob Thornton committed
1530

XhmikosR's avatar
XhmikosR committed
1531
      return EventHandler.trigger(this._element, EVENT_SLIDE, {
XhmikosR's avatar
Dist    
XhmikosR committed
1532
1533
1534
1535
1536
1537
        relatedTarget: relatedTarget,
        direction: eventDirectionName,
        from: fromIndex,
        to: targetIndex
      });
    };
Jacob Thornton's avatar
Jacob Thornton committed
1538

XhmikosR's avatar
Dist    
XhmikosR committed
1539
1540
    _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
      if (this._indicatorsElement) {
XhmikosR's avatar
XhmikosR committed
1541
        var indicators = SelectorEngine.find(SELECTOR_ACTIVE$1, this._indicatorsElement);
XhmikosR's avatar
XhmikosR committed
1542
1543

        for (var i = 0; i < indicators.length; i++) {
XhmikosR's avatar
XhmikosR committed
1544
          indicators[i].classList.remove(CLASS_NAME_ACTIVE$1);
XhmikosR's avatar
XhmikosR committed
1545
        }
Jacob Thornton's avatar
Jacob Thornton committed
1546

XhmikosR's avatar
Dist    
XhmikosR committed
1547
        var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
Jacob Thornton's avatar
Jacob Thornton committed
1548

XhmikosR's avatar
Dist    
XhmikosR committed
1549
        if (nextIndicator) {
XhmikosR's avatar
XhmikosR committed
1550
          nextIndicator.classList.add(CLASS_NAME_ACTIVE$1);
Mark Otto's avatar
dist    
Mark Otto committed
1551
        }
XhmikosR's avatar
Dist    
XhmikosR committed
1552
1553
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
1554

XhmikosR's avatar
Dist    
XhmikosR committed
1555
1556
    _proto._slide = function _slide(direction, element) {
      var _this4 = this;
Jacob Thornton's avatar
Jacob Thornton committed
1557

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

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

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

XhmikosR's avatar
Dist    
XhmikosR committed
1564
      var nextElementIndex = this._getItemIndex(nextElement);
Jacob Thornton's avatar
Jacob Thornton committed
1565

XhmikosR's avatar
Dist    
XhmikosR committed
1566
1567
1568
1569
      var isCycling = Boolean(this._interval);
      var directionalClassName;
      var orderClassName;
      var eventDirectionName;
Jacob Thornton's avatar
Jacob Thornton committed
1570

XhmikosR's avatar
XhmikosR committed
1571
1572
1573
1574
      if (direction === DIRECTION_NEXT) {
        directionalClassName = CLASS_NAME_LEFT;
        orderClassName = CLASS_NAME_NEXT;
        eventDirectionName = DIRECTION_LEFT;
XhmikosR's avatar
Dist    
XhmikosR committed
1575
      } else {
XhmikosR's avatar
XhmikosR committed
1576
1577
1578
        directionalClassName = CLASS_NAME_RIGHT;
        orderClassName = CLASS_NAME_PREV;
        eventDirectionName = DIRECTION_RIGHT;
XhmikosR's avatar
Dist    
XhmikosR committed
1579
      }
Jacob Thornton's avatar
Jacob Thornton committed
1580

XhmikosR's avatar
XhmikosR committed
1581
      if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE$1)) {
XhmikosR's avatar
Dist    
XhmikosR committed
1582
1583
1584
        this._isSliding = false;
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
1585

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

XhmikosR's avatar
XhmikosR committed
1588
      if (slideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
1589
1590
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
1591

XhmikosR's avatar
Dist    
XhmikosR committed
1592
1593
1594
1595
      if (!activeElement || !nextElement) {
        // Some weirdness is happening, so we bail
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
1596

XhmikosR's avatar
Dist    
XhmikosR committed
1597
      this._isSliding = true;
Jacob Thornton's avatar
Jacob Thornton committed
1598

XhmikosR's avatar
Dist    
XhmikosR committed
1599
1600
1601
      if (isCycling) {
        this.pause();
      }
Mark Otto's avatar
dist    
Mark Otto committed
1602

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

XhmikosR's avatar
XhmikosR committed
1605
      if (this._element.classList.contains(CLASS_NAME_SLIDE)) {
XhmikosR's avatar
XhmikosR committed
1606
1607
1608
1609
        nextElement.classList.add(orderClassName);
        reflow(nextElement);
        activeElement.classList.add(directionalClassName);
        nextElement.classList.add(directionalClassName);
XhmikosR's avatar
Dist    
XhmikosR committed
1610
1611
1612
1613
1614
1615
1616
        var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);

        if (nextElementInterval) {
          this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
          this._config.interval = nextElementInterval;
        } else {
          this._config.interval = this._config.defaultInterval || this._config.interval;
Jacob Thornton's avatar
Jacob Thornton committed
1617
1618
        }

XhmikosR's avatar
XhmikosR committed
1619
1620
        var transitionDuration = getTransitionDurationFromElement(activeElement);
        EventHandler.one(activeElement, TRANSITION_END, function () {
XhmikosR's avatar
XhmikosR committed
1621
          nextElement.classList.remove(directionalClassName, orderClassName);
XhmikosR's avatar
XhmikosR committed
1622
          nextElement.classList.add(CLASS_NAME_ACTIVE$1);
XhmikosR's avatar
XhmikosR committed
1623
          activeElement.classList.remove(CLASS_NAME_ACTIVE$1, orderClassName, directionalClassName);
XhmikosR's avatar
Dist    
XhmikosR committed
1624
1625
          _this4._isSliding = false;
          setTimeout(function () {
XhmikosR's avatar
XhmikosR committed
1626
            EventHandler.trigger(_this4._element, EVENT_SLID, {
XhmikosR's avatar
XhmikosR committed
1627
1628
1629
1630
1631
              relatedTarget: nextElement,
              direction: eventDirectionName,
              from: activeElementIndex,
              to: nextElementIndex
            });
XhmikosR's avatar
Dist    
XhmikosR committed
1632
          }, 0);
XhmikosR's avatar
XhmikosR committed
1633
1634
        });
        emulateTransitionEnd(activeElement, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
1635
      } else {
XhmikosR's avatar
XhmikosR committed
1636
1637
        activeElement.classList.remove(CLASS_NAME_ACTIVE$1);
        nextElement.classList.add(CLASS_NAME_ACTIVE$1);
XhmikosR's avatar
Dist    
XhmikosR committed
1638
        this._isSliding = false;
XhmikosR's avatar
XhmikosR committed
1639
        EventHandler.trigger(this._element, EVENT_SLID, {
XhmikosR's avatar
XhmikosR committed
1640
1641
1642
1643
1644
          relatedTarget: nextElement,
          direction: eventDirectionName,
          from: activeElementIndex,
          to: nextElementIndex
        });
XhmikosR's avatar
Dist    
XhmikosR committed
1645
1646
1647
1648
1649
      }

      if (isCycling) {
        this.cycle();
      }
Mark Otto's avatar
Mark Otto committed
1650
1651
    } // Static
    ;
Jacob Thornton's avatar
Jacob Thornton committed
1652

XhmikosR's avatar
XhmikosR committed
1653
    Carousel.carouselInterface = function carouselInterface(element, config) {
XhmikosR's avatar
XhmikosR committed
1654
      var data = Data.getData(element, DATA_KEY$2);
Jacob Thornton's avatar
Jacob Thornton committed
1655

XhmikosR's avatar
XhmikosR committed
1656
      var _config = _objectSpread2(_objectSpread2({}, Default), Manipulator.getDataAttributes(element));
Jacob Thornton's avatar
Jacob Thornton committed
1657

XhmikosR's avatar
XhmikosR committed
1658
      if (typeof config === 'object') {
XhmikosR's avatar
XhmikosR committed
1659
        _config = _objectSpread2(_objectSpread2({}, _config), config);
XhmikosR's avatar
XhmikosR committed
1660
      }
Jacob Thornton's avatar
Jacob Thornton committed
1661

XhmikosR's avatar
XhmikosR committed
1662
      var action = typeof config === 'string' ? config : _config.slide;
Jacob Thornton's avatar
Jacob Thornton committed
1663

XhmikosR's avatar
XhmikosR committed
1664
1665
1666
1667
1668
1669
1670
1671
      if (!data) {
        data = new Carousel(element, _config);
      }

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

XhmikosR's avatar
XhmikosR committed
1675
1676
1677
1678
1679
1680
        data[action]();
      } else if (_config.interval && _config.ride) {
        data.pause();
        data.cycle();
      }
    };
Mark Otto's avatar
grunt    
Mark Otto committed
1681

XhmikosR's avatar
XhmikosR committed
1682
    Carousel.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
XhmikosR committed
1683
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
1684
        Carousel.carouselInterface(this, config);
XhmikosR's avatar
Dist    
XhmikosR committed
1685
1686
      });
    };
Mark Otto's avatar
grunt    
Mark Otto committed
1687

XhmikosR's avatar
XhmikosR committed
1688
1689
    Carousel.dataApiClickHandler = function dataApiClickHandler(event) {
      var target = getElementFromSelector(this);
Jacob Thornton's avatar
Jacob Thornton committed
1690

XhmikosR's avatar
XhmikosR committed
1691
      if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) {
XhmikosR's avatar
Dist    
XhmikosR committed
1692
1693
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
1694

XhmikosR's avatar
XhmikosR committed
1695
      var config = _objectSpread2(_objectSpread2({}, Manipulator.getDataAttributes(target)), Manipulator.getDataAttributes(this));
Mark Otto's avatar
dist    
Mark Otto committed
1696

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

XhmikosR's avatar
Dist    
XhmikosR committed
1699
1700
      if (slideIndex) {
        config.interval = false;
Mark Otto's avatar
dist    
Mark Otto committed
1701
      }
Mark Otto's avatar
dist    
Mark Otto committed
1702

XhmikosR's avatar
XhmikosR committed
1703
      Carousel.carouselInterface(target, config);
Jacob Thornton's avatar
Jacob Thornton committed
1704

XhmikosR's avatar
Dist    
XhmikosR committed
1705
      if (slideIndex) {
XhmikosR's avatar
XhmikosR committed
1706
        Data.getData(target, DATA_KEY$2).to(slideIndex);
XhmikosR's avatar
Dist    
XhmikosR committed
1707
1708
1709
      }

      event.preventDefault();
Mark Otto's avatar
dist    
Mark Otto committed
1710
    };
Jacob Thornton's avatar
Jacob Thornton committed
1711

XhmikosR's avatar
XhmikosR committed
1712
    Carousel.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
1713
1714
1715
      return Data.getData(element, DATA_KEY$2);
    };

XhmikosR's avatar
Dist    
XhmikosR committed
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
    _createClass(Carousel, null, [{
      key: "VERSION",
      get: function get() {
        return VERSION$2;
      }
    }, {
      key: "Default",
      get: function get() {
        return Default;
      }
    }]);

Mark Otto's avatar
dist    
Mark Otto committed
1728
    return Carousel;
XhmikosR's avatar
Dist    
XhmikosR committed
1729
1730
1731
1732
1733
1734
1735
1736
  }();
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */


XhmikosR's avatar
XhmikosR committed
1737
1738
1739
  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
1740
1741

    for (var i = 0, len = carousels.length; i < len; i++) {
XhmikosR's avatar
XhmikosR committed
1742
      Carousel.carouselInterface(carousels[i], Data.getData(carousels[i], DATA_KEY$2));
XhmikosR's avatar
Dist    
XhmikosR committed
1743
1744
    }
  });
XhmikosR's avatar
XhmikosR committed
1745
  var $$3 = getjQuery();
XhmikosR's avatar
Dist    
XhmikosR committed
1746
1747
1748
1749
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
1750
   * add .carousel to jQuery only if jQuery is present
XhmikosR's avatar
Dist    
XhmikosR committed
1751
1752
   */

1753
1754
  /* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
1755
1756
1757
1758
  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
1759

XhmikosR's avatar
XhmikosR committed
1760
1761
1762
    $$3.fn[NAME$2].noConflict = function () {
      $$3.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
      return Carousel.jQueryInterface;
XhmikosR's avatar
XhmikosR committed
1763
1764
    };
  }
Jacob Thornton's avatar
Jacob Thornton committed
1765

XhmikosR's avatar
Dist    
XhmikosR committed
1766
1767
1768
1769
1770
1771
1772
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME$3 = 'collapse';
1773
  var VERSION$3 = '5.0.0-alpha1';
XhmikosR's avatar
Dist    
XhmikosR committed
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
  var DATA_KEY$3 = 'bs.collapse';
  var EVENT_KEY$3 = "." + DATA_KEY$3;
  var DATA_API_KEY$3 = '.data-api';
  var Default$1 = {
    toggle: true,
    parent: ''
  };
  var DefaultType$1 = {
    toggle: 'boolean',
    parent: '(string|element)'
  };
XhmikosR's avatar
XhmikosR committed
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
  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
1798
1799
1800
1801
1802
  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */
XhmikosR's avatar
Dist    
XhmikosR committed
1803

XhmikosR's avatar
XhmikosR committed
1804
  var Collapse = /*#__PURE__*/function () {
XhmikosR's avatar
Dist    
XhmikosR committed
1805
1806
1807
1808
    function Collapse(element, config) {
      this._isTransitioning = false;
      this._element = element;
      this._config = this._getConfig(config);
XhmikosR's avatar
XhmikosR committed
1809
1810
      this._triggerArray = SelectorEngine.find(SELECTOR_DATA_TOGGLE$1 + "[href=\"#" + element.id + "\"]," + (SELECTOR_DATA_TOGGLE$1 + "[data-target=\"#" + element.id + "\"]"));
      var toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$1);
XhmikosR's avatar
Dist    
XhmikosR committed
1811
1812
1813

      for (var i = 0, len = toggleList.length; i < len; i++) {
        var elem = toggleList[i];
XhmikosR's avatar
XhmikosR committed
1814
        var selector = getSelectorFromElement(elem);
XhmikosR's avatar
XhmikosR committed
1815
        var filterElement = SelectorEngine.find(selector).filter(function (foundElem) {
XhmikosR's avatar
Dist    
XhmikosR committed
1816
1817
          return foundElem === element;
        });
Johann-S's avatar
build    
Johann-S committed
1818

XhmikosR's avatar
XhmikosR committed
1819
        if (selector !== null && filterElement.length) {
XhmikosR's avatar
Dist    
XhmikosR committed
1820
          this._selector = selector;
Jacob Thornton's avatar
Jacob Thornton committed
1821

XhmikosR's avatar
Dist    
XhmikosR committed
1822
          this._triggerArray.push(elem);
Mark Otto's avatar
dist    
Mark Otto committed
1823
        }
XhmikosR's avatar
Dist    
XhmikosR committed
1824
      }
Jacob Thornton's avatar
Jacob Thornton committed
1825

XhmikosR's avatar
Dist    
XhmikosR committed
1826
      this._parent = this._config.parent ? this._getParent() : null;
Jacob Thornton's avatar
Jacob Thornton committed
1827

XhmikosR's avatar
Dist    
XhmikosR committed
1828
1829
1830
      if (!this._config.parent) {
        this._addAriaAndCollapsedClass(this._element, this._triggerArray);
      }
Jacob Thornton's avatar
Jacob Thornton committed
1831

XhmikosR's avatar
Dist    
XhmikosR committed
1832
1833
1834
      if (this._config.toggle) {
        this.toggle();
      }
XhmikosR's avatar
XhmikosR committed
1835
1836

      Data.setData(element, DATA_KEY$3, this);
XhmikosR's avatar
Dist    
XhmikosR committed
1837
    } // Getters
Jacob Thornton's avatar
Jacob Thornton committed
1838
1839


XhmikosR's avatar
Dist    
XhmikosR committed
1840
    var _proto = Collapse.prototype;
Jacob Thornton's avatar
Jacob Thornton committed
1841

XhmikosR's avatar
Dist    
XhmikosR committed
1842
1843
    // Public
    _proto.toggle = function toggle() {
XhmikosR's avatar
XhmikosR committed
1844
      if (this._element.classList.contains(CLASS_NAME_SHOW)) {
XhmikosR's avatar
Dist    
XhmikosR committed
1845
1846
1847
1848
1849
        this.hide();
      } else {
        this.show();
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
1850

XhmikosR's avatar
Dist    
XhmikosR committed
1851
1852
    _proto.show = function show() {
      var _this = this;
Jacob Thornton's avatar
Jacob Thornton committed
1853

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

XhmikosR's avatar
Dist    
XhmikosR committed
1858
1859
      var actives;
      var activesData;
Mark Otto's avatar
dist    
Mark Otto committed
1860

XhmikosR's avatar
Dist    
XhmikosR committed
1861
      if (this._parent) {
XhmikosR's avatar
XhmikosR committed
1862
        actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent).filter(function (elem) {
XhmikosR's avatar
Dist    
XhmikosR committed
1863
1864
          if (typeof _this._config.parent === 'string') {
            return elem.getAttribute('data-parent') === _this._config.parent;
Mark Otto's avatar
dist    
Mark Otto committed
1865
          }
Jacob Thornton's avatar
Jacob Thornton committed
1866

XhmikosR's avatar
XhmikosR committed
1867
          return elem.classList.contains(CLASS_NAME_COLLAPSE);
XhmikosR's avatar
Dist    
XhmikosR committed
1868
        });
Mark Otto's avatar
dist    
Mark Otto committed
1869

XhmikosR's avatar
Dist    
XhmikosR committed
1870
1871
        if (actives.length === 0) {
          actives = null;
Jacob Thornton's avatar
Jacob Thornton committed
1872
        }
XhmikosR's avatar
Dist    
XhmikosR committed
1873
      }
Jacob Thornton's avatar
Jacob Thornton committed
1874

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

XhmikosR's avatar
Dist    
XhmikosR committed
1877
      if (actives) {
XhmikosR's avatar
XhmikosR committed
1878
1879
1880
1881
        var tempActiveData = actives.filter(function (elem) {
          return container !== elem;
        });
        activesData = tempActiveData[0] ? Data.getData(tempActiveData[0], DATA_KEY$3) : null;
Mark Otto's avatar
dist    
Mark Otto committed
1882

XhmikosR's avatar
Dist    
XhmikosR committed
1883
        if (activesData && activesData._isTransitioning) {
Mark Otto's avatar
dist    
Mark Otto committed
1884
1885
          return;
        }
XhmikosR's avatar
Dist    
XhmikosR committed
1886
      }
Mark Otto's avatar
grunt    
Mark Otto committed
1887

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

XhmikosR's avatar
XhmikosR committed
1890
      if (startEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
1891
1892
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
1893

XhmikosR's avatar
Dist    
XhmikosR committed
1894
      if (actives) {
XhmikosR's avatar
XhmikosR committed
1895
1896
        actives.forEach(function (elemActive) {
          if (container !== elemActive) {
XhmikosR's avatar
XhmikosR committed
1897
            Collapse.collapseInterface(elemActive, 'hide');
XhmikosR's avatar
XhmikosR committed
1898
          }
Jacob Thornton's avatar
Jacob Thornton committed
1899

XhmikosR's avatar
XhmikosR committed
1900
1901
1902
1903
          if (!activesData) {
            Data.setData(elemActive, DATA_KEY$3, null);
          }
        });
XhmikosR's avatar
Dist    
XhmikosR committed
1904
      }
Jacob Thornton's avatar
Jacob Thornton committed
1905

XhmikosR's avatar
Dist    
XhmikosR committed
1906
      var dimension = this._getDimension();
Jacob Thornton's avatar
Jacob Thornton committed
1907

XhmikosR's avatar
XhmikosR committed
1908
      this._element.classList.remove(CLASS_NAME_COLLAPSE);
XhmikosR's avatar
XhmikosR committed
1909

XhmikosR's avatar
XhmikosR committed
1910
      this._element.classList.add(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
XhmikosR committed
1911

XhmikosR's avatar
Dist    
XhmikosR committed
1912
1913
1914
      this._element.style[dimension] = 0;

      if (this._triggerArray.length) {
XhmikosR's avatar
XhmikosR committed
1915
        this._triggerArray.forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
1916
          element.classList.remove(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
XhmikosR committed
1917
1918
          element.setAttribute('aria-expanded', true);
        });
XhmikosR's avatar
Dist    
XhmikosR committed
1919
      }
Jacob Thornton's avatar
Jacob Thornton committed
1920

XhmikosR's avatar
Dist    
XhmikosR committed
1921
      this.setTransitioning(true);
Jacob Thornton's avatar
Jacob Thornton committed
1922

XhmikosR's avatar
Dist    
XhmikosR committed
1923
      var complete = function complete() {
XhmikosR's avatar
XhmikosR committed
1924
        _this._element.classList.remove(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
XhmikosR committed
1925

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

XhmikosR's avatar
Dist    
XhmikosR committed
1928
        _this._element.style[dimension] = '';
Jacob Thornton's avatar
Jacob Thornton committed
1929

XhmikosR's avatar
Dist    
XhmikosR committed
1930
1931
        _this.setTransitioning(false);

XhmikosR's avatar
XhmikosR committed
1932
        EventHandler.trigger(_this._element, EVENT_SHOWN);
Mark Otto's avatar
dist    
Mark Otto committed
1933
      };
Jacob Thornton's avatar
Jacob Thornton committed
1934

XhmikosR's avatar
Dist    
XhmikosR committed
1935
1936
      var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
      var scrollSize = "scroll" + capitalizedDimension;
XhmikosR's avatar
XhmikosR committed
1937
1938
1939
      var transitionDuration = getTransitionDurationFromElement(this._element);
      EventHandler.one(this._element, TRANSITION_END, complete);
      emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
1940
1941
      this._element.style[dimension] = this._element[scrollSize] + "px";
    };
Jacob Thornton's avatar
Jacob Thornton committed
1942

XhmikosR's avatar
Dist    
XhmikosR committed
1943
1944
    _proto.hide = function hide() {
      var _this2 = this;
Jacob Thornton's avatar
Jacob Thornton committed
1945

XhmikosR's avatar
XhmikosR committed
1946
      if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW)) {
XhmikosR's avatar
Dist    
XhmikosR committed
1947
1948
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
1949

XhmikosR's avatar
XhmikosR committed
1950
      var startEvent = EventHandler.trigger(this._element, EVENT_HIDE);
Jacob Thornton's avatar
Jacob Thornton committed
1951

XhmikosR's avatar
XhmikosR committed
1952
      if (startEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
1953
1954
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
1955

XhmikosR's avatar
Dist    
XhmikosR committed
1956
      var dimension = this._getDimension();
Jacob Thornton's avatar
Jacob Thornton committed
1957

XhmikosR's avatar
Dist    
XhmikosR committed
1958
      this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
XhmikosR's avatar
XhmikosR committed
1959
1960
      reflow(this._element);

XhmikosR's avatar
XhmikosR committed
1961
      this._element.classList.add(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
XhmikosR committed
1962

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

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

XhmikosR's avatar
Dist    
XhmikosR committed
1967
1968
1969
      if (triggerArrayLength > 0) {
        for (var i = 0; i < triggerArrayLength; i++) {
          var trigger = this._triggerArray[i];
XhmikosR's avatar
XhmikosR committed
1970
          var elem = getElementFromSelector(trigger);
XhmikosR's avatar
Dist    
XhmikosR committed
1971

XhmikosR's avatar
XhmikosR committed
1972
1973
          if (elem && !elem.classList.contains(CLASS_NAME_SHOW)) {
            trigger.classList.add(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
XhmikosR committed
1974
            trigger.setAttribute('aria-expanded', false);
Mark Otto's avatar
build    
Mark Otto committed
1975
1976
          }
        }
XhmikosR's avatar
Dist    
XhmikosR committed
1977
      }
Mark Otto's avatar
dist    
Mark Otto committed
1978

XhmikosR's avatar
Dist    
XhmikosR committed
1979
      this.setTransitioning(true);
Jacob Thornton's avatar
Jacob Thornton committed
1980

XhmikosR's avatar
Dist    
XhmikosR committed
1981
1982
      var complete = function complete() {
        _this2.setTransitioning(false);
Jacob Thornton's avatar
Jacob Thornton committed
1983

XhmikosR's avatar
XhmikosR committed
1984
        _this2._element.classList.remove(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
XhmikosR committed
1985

XhmikosR's avatar
XhmikosR committed
1986
        _this2._element.classList.add(CLASS_NAME_COLLAPSE);
XhmikosR's avatar
XhmikosR committed
1987

XhmikosR's avatar
XhmikosR committed
1988
        EventHandler.trigger(_this2._element, EVENT_HIDDEN);
Mark Otto's avatar
dist    
Mark Otto committed
1989
      };
Jacob Thornton's avatar
Jacob Thornton committed
1990

XhmikosR's avatar
Dist    
XhmikosR committed
1991
      this._element.style[dimension] = '';
XhmikosR's avatar
XhmikosR committed
1992
1993
1994
      var transitionDuration = getTransitionDurationFromElement(this._element);
      EventHandler.one(this._element, TRANSITION_END, complete);
      emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
1995
    };
Jacob Thornton's avatar
Jacob Thornton committed
1996

XhmikosR's avatar
Dist    
XhmikosR committed
1997
1998
1999
    _proto.setTransitioning = function setTransitioning(isTransitioning) {
      this._isTransitioning = isTransitioning;
    };
Jacob Thornton's avatar
Jacob Thornton committed
2000

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