bootstrap.js 152 KB
Newer Older
XhmikosR's avatar
Dist    
XhmikosR committed
2001
    _proto.dispose = function dispose() {
XhmikosR's avatar
XhmikosR committed
2002
      Data.removeData(this._element, DATA_KEY$3);
XhmikosR's avatar
Dist    
XhmikosR committed
2003
2004
2005
2006
2007
      this._config = null;
      this._parent = null;
      this._element = null;
      this._triggerArray = null;
      this._isTransitioning = null;
Mark Otto's avatar
Mark Otto committed
2008
2009
    } // Private
    ;
Mark Otto's avatar
dist    
Mark Otto committed
2010

XhmikosR's avatar
Dist    
XhmikosR committed
2011
    _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
2012
      config = _objectSpread2(_objectSpread2({}, Default$1), config);
XhmikosR's avatar
Dist    
XhmikosR committed
2013
      config.toggle = Boolean(config.toggle); // Coerce string values
Mark Otto's avatar
grunt    
Mark Otto committed
2014

XhmikosR's avatar
XhmikosR committed
2015
      typeCheckConfig(NAME$3, config, DefaultType$1);
XhmikosR's avatar
Dist    
XhmikosR committed
2016
2017
      return config;
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2018

XhmikosR's avatar
Dist    
XhmikosR committed
2019
    _proto._getDimension = function _getDimension() {
XhmikosR's avatar
XhmikosR committed
2020
      var hasWidth = this._element.classList.contains(WIDTH);
XhmikosR's avatar
XhmikosR committed
2021

XhmikosR's avatar
XhmikosR committed
2022
      return hasWidth ? WIDTH : HEIGHT;
XhmikosR's avatar
Dist    
XhmikosR committed
2023
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2024

XhmikosR's avatar
Dist    
XhmikosR committed
2025
2026
    _proto._getParent = function _getParent() {
      var _this3 = this;
Mark Otto's avatar
grunt    
Mark Otto committed
2027

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

XhmikosR's avatar
Dist.    
XhmikosR committed
2030
2031
2032
2033
      if (isElement(parent)) {
        // it's a jQuery object
        if (typeof parent.jquery !== 'undefined' || typeof parent[0] !== 'undefined') {
          parent = parent[0];
XhmikosR's avatar
Dist    
XhmikosR committed
2034
2035
        }
      } else {
XhmikosR's avatar
Dist.    
XhmikosR committed
2036
        parent = SelectorEngine.findOne(parent);
XhmikosR's avatar
Dist    
XhmikosR committed
2037
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2038

XhmikosR's avatar
XhmikosR committed
2039
2040
      var selector = SELECTOR_DATA_TOGGLE$1 + "[data-parent=\"" + parent + "\"]";
      SelectorEngine.find(selector, parent).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
2041
        var selected = getElementFromSelector(element);
2042
2043

        _this3._addAriaAndCollapsedClass(selected, [element]);
XhmikosR's avatar
Dist    
XhmikosR committed
2044
2045
2046
      });
      return parent;
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2047

XhmikosR's avatar
Dist    
XhmikosR committed
2048
    _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
XhmikosR's avatar
XhmikosR committed
2049
      if (element) {
XhmikosR's avatar
XhmikosR committed
2050
        var isOpen = element.classList.contains(CLASS_NAME_SHOW);
XhmikosR's avatar
XhmikosR committed
2051
2052
2053

        if (triggerArray.length) {
          triggerArray.forEach(function (elem) {
XhmikosR's avatar
Dist.    
XhmikosR committed
2054
            if (isOpen) {
XhmikosR's avatar
XhmikosR committed
2055
              elem.classList.remove(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
Dist.    
XhmikosR committed
2056
            } else {
XhmikosR's avatar
XhmikosR committed
2057
              elem.classList.add(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
XhmikosR committed
2058
            }
Jacob Thornton's avatar
Jacob Thornton committed
2059

XhmikosR's avatar
XhmikosR committed
2060
2061
2062
            elem.setAttribute('aria-expanded', isOpen);
          });
        }
XhmikosR's avatar
Dist    
XhmikosR committed
2063
      }
Mark Otto's avatar
Mark Otto committed
2064
2065
    } // Static
    ;
Jacob Thornton's avatar
Jacob Thornton committed
2066

XhmikosR's avatar
XhmikosR committed
2067
    Collapse.collapseInterface = function collapseInterface(element, config) {
XhmikosR's avatar
XhmikosR committed
2068
      var data = Data.getData(element, DATA_KEY$3);
Jacob Thornton's avatar
Jacob Thornton committed
2069

XhmikosR's avatar
XhmikosR committed
2070
      var _config = _objectSpread2(_objectSpread2(_objectSpread2({}, Default$1), Manipulator.getDataAttributes(element)), typeof config === 'object' && config ? config : {});
Mark Otto's avatar
grunt    
Mark Otto committed
2071

XhmikosR's avatar
XhmikosR committed
2072
      if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) {
XhmikosR's avatar
XhmikosR committed
2073
2074
        _config.toggle = false;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2075

XhmikosR's avatar
XhmikosR committed
2076
2077
2078
2079
2080
2081
      if (!data) {
        data = new Collapse(element, _config);
      }

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

XhmikosR's avatar
XhmikosR committed
2085
2086
2087
        data[config]();
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
2088

XhmikosR's avatar
XhmikosR committed
2089
    Collapse.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
XhmikosR committed
2090
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
2091
        Collapse.collapseInterface(this, config);
XhmikosR's avatar
Dist    
XhmikosR committed
2092
2093
      });
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2094

XhmikosR's avatar
XhmikosR committed
2095
    Collapse.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
2096
2097
2098
      return Data.getData(element, DATA_KEY$3);
    };

XhmikosR's avatar
Dist    
XhmikosR committed
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
    _createClass(Collapse, null, [{
      key: "VERSION",
      get: function get() {
        return VERSION$3;
      }
    }, {
      key: "Default",
      get: function get() {
        return Default$1;
      }
    }]);
Jacob Thornton's avatar
Jacob Thornton committed
2110

XhmikosR's avatar
Dist    
XhmikosR committed
2111
2112
2113
2114
2115
2116
2117
    return Collapse;
  }();
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
Mark Otto's avatar
dist    
Mark Otto committed
2118

Jacob Thornton's avatar
Jacob Thornton committed
2119

XhmikosR's avatar
XhmikosR committed
2120
  EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$1, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2121
    // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
XhmikosR's avatar
XhmikosR committed
2122
    if (event.target.tagName === 'A') {
XhmikosR's avatar
Dist    
XhmikosR committed
2123
2124
      event.preventDefault();
    }
Mark Otto's avatar
dist    
Mark Otto committed
2125

XhmikosR's avatar
XhmikosR committed
2126
2127
    var triggerData = Manipulator.getDataAttributes(this);
    var selector = getSelectorFromElement(this);
XhmikosR's avatar
XhmikosR committed
2128
    var selectorElements = SelectorEngine.find(selector);
XhmikosR's avatar
XhmikosR committed
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
    selectorElements.forEach(function (element) {
      var data = Data.getData(element, DATA_KEY$3);
      var config;

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

        config = 'toggle';
      } else {
        config = triggerData;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2144

XhmikosR's avatar
XhmikosR committed
2145
      Collapse.collapseInterface(element, config);
XhmikosR's avatar
Dist    
XhmikosR committed
2146
2147
    });
  });
XhmikosR's avatar
XhmikosR committed
2148
  var $$4 = getjQuery();
XhmikosR's avatar
Dist    
XhmikosR committed
2149
2150
2151
2152
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
2153
   * add .collapse to jQuery only if jQuery is present
XhmikosR's avatar
Dist    
XhmikosR committed
2154
   */
Jacob Thornton's avatar
Jacob Thornton committed
2155

2156
2157
  /* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
2158
2159
2160
2161
  if ($$4) {
    var JQUERY_NO_CONFLICT$3 = $$4.fn[NAME$3];
    $$4.fn[NAME$3] = Collapse.jQueryInterface;
    $$4.fn[NAME$3].Constructor = Collapse;
Jacob Thornton's avatar
Jacob Thornton committed
2162

XhmikosR's avatar
XhmikosR committed
2163
2164
2165
    $$4.fn[NAME$3].noConflict = function () {
      $$4.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
      return Collapse.jQueryInterface;
XhmikosR's avatar
XhmikosR committed
2166
2167
    };
  }
Jacob Thornton's avatar
Jacob Thornton committed
2168

XhmikosR's avatar
Dist    
XhmikosR committed
2169
2170
2171
2172
2173
2174
2175
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME$4 = 'dropdown';
2176
  var VERSION$4 = '5.0.0-alpha1';
XhmikosR's avatar
Dist    
XhmikosR committed
2177
2178
2179
  var DATA_KEY$4 = 'bs.dropdown';
  var EVENT_KEY$4 = "." + DATA_KEY$4;
  var DATA_API_KEY$4 = '.data-api';
XhmikosR's avatar
XhmikosR committed
2180
2181
2182
2183
2184
2185
2186
2187
  var ESCAPE_KEY = 'Escape';
  var SPACE_KEY = 'Space';
  var TAB_KEY = 'Tab';
  var ARROW_UP_KEY = 'ArrowUp';
  var ARROW_DOWN_KEY = 'ArrowDown';
  var RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button

  var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEY + "|" + ARROW_DOWN_KEY + "|" + ESCAPE_KEY);
XhmikosR's avatar
XhmikosR committed
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
  var EVENT_HIDE$1 = "hide" + EVENT_KEY$4;
  var EVENT_HIDDEN$1 = "hidden" + EVENT_KEY$4;
  var EVENT_SHOW$1 = "show" + EVENT_KEY$4;
  var EVENT_SHOWN$1 = "shown" + EVENT_KEY$4;
  var EVENT_CLICK = "click" + EVENT_KEY$4;
  var EVENT_CLICK_DATA_API$4 = "click" + EVENT_KEY$4 + DATA_API_KEY$4;
  var EVENT_KEYDOWN_DATA_API = "keydown" + EVENT_KEY$4 + DATA_API_KEY$4;
  var EVENT_KEYUP_DATA_API = "keyup" + EVENT_KEY$4 + DATA_API_KEY$4;
  var CLASS_NAME_DISABLED$1 = 'disabled';
  var CLASS_NAME_SHOW$1 = 'show';
  var CLASS_NAME_DROPUP = 'dropup';
  var CLASS_NAME_DROPRIGHT = 'dropright';
  var CLASS_NAME_DROPLEFT = 'dropleft';
  var CLASS_NAME_MENURIGHT = 'dropdown-menu-right';
  var CLASS_NAME_NAVBAR = 'navbar';
  var CLASS_NAME_POSITION_STATIC = 'position-static';
  var SELECTOR_DATA_TOGGLE$2 = '[data-toggle="dropdown"]';
  var SELECTOR_FORM_CHILD = '.dropdown form';
  var SELECTOR_MENU = '.dropdown-menu';
  var SELECTOR_NAVBAR_NAV = '.navbar-nav';
  var SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
  var PLACEMENT_TOP = 'top-start';
  var PLACEMENT_TOPEND = 'top-end';
  var PLACEMENT_BOTTOM = 'bottom-start';
  var PLACEMENT_BOTTOMEND = 'bottom-end';
  var PLACEMENT_RIGHT = 'right-start';
  var PLACEMENT_LEFT = 'left-start';
XhmikosR's avatar
Dist    
XhmikosR committed
2215
2216
2217
2218
2219
  var Default$2 = {
    offset: 0,
    flip: true,
    boundary: 'scrollParent',
    reference: 'toggle',
XhmikosR's avatar
XhmikosR committed
2220
2221
    display: 'dynamic',
    popperConfig: null
XhmikosR's avatar
Dist    
XhmikosR committed
2222
2223
2224
2225
2226
2227
  };
  var DefaultType$2 = {
    offset: '(number|string|function)',
    flip: 'boolean',
    boundary: '(string|element)',
    reference: '(string|element)',
XhmikosR's avatar
XhmikosR committed
2228
2229
    display: 'string',
    popperConfig: '(null|object)'
XhmikosR's avatar
Dist    
XhmikosR committed
2230
  };
XhmikosR's avatar
XhmikosR committed
2231
2232
2233
2234
2235
  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */
Mark Otto's avatar
dist    
Mark Otto committed
2236

XhmikosR's avatar
XhmikosR committed
2237
  var Dropdown = /*#__PURE__*/function () {
XhmikosR's avatar
Dist    
XhmikosR committed
2238
2239
2240
2241
2242
2243
    function Dropdown(element, config) {
      this._element = element;
      this._popper = null;
      this._config = this._getConfig(config);
      this._menu = this._getMenuElement();
      this._inNavbar = this._detectNavbar();
Mark Otto's avatar
dist    
Mark Otto committed
2244

XhmikosR's avatar
Dist    
XhmikosR committed
2245
      this._addEventListeners();
XhmikosR's avatar
XhmikosR committed
2246
2247

      Data.setData(element, DATA_KEY$4, this);
XhmikosR's avatar
Dist    
XhmikosR committed
2248
    } // Getters
Mark Otto's avatar
dist    
Mark Otto committed
2249

Jacob Thornton's avatar
Jacob Thornton committed
2250

XhmikosR's avatar
Dist    
XhmikosR committed
2251
    var _proto = Dropdown.prototype;
Jacob Thornton's avatar
Jacob Thornton committed
2252

XhmikosR's avatar
Dist    
XhmikosR committed
2253
2254
    // Public
    _proto.toggle = function toggle() {
XhmikosR's avatar
XhmikosR committed
2255
      if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED$1)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2256
2257
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2258

XhmikosR's avatar
XhmikosR committed
2259
      var isActive = this._element.classList.contains(CLASS_NAME_SHOW$1);
Jacob Thornton's avatar
Jacob Thornton committed
2260

XhmikosR's avatar
XhmikosR committed
2261
      Dropdown.clearMenus();
Jacob Thornton's avatar
Jacob Thornton committed
2262

XhmikosR's avatar
Dist    
XhmikosR committed
2263
2264
2265
      if (isActive) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2266

XhmikosR's avatar
XhmikosR committed
2267
2268
2269
2270
      this.show();
    };

    _proto.show = function show() {
XhmikosR's avatar
XhmikosR committed
2271
      if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED$1) || this._menu.classList.contains(CLASS_NAME_SHOW$1)) {
XhmikosR's avatar
XhmikosR committed
2272
2273
2274
2275
        return;
      }

      var parent = Dropdown.getParentFromElement(this._element);
XhmikosR's avatar
Dist    
XhmikosR committed
2276
2277
2278
      var relatedTarget = {
        relatedTarget: this._element
      };
XhmikosR's avatar
XhmikosR committed
2279
      var showEvent = EventHandler.trigger(this._element, EVENT_SHOW$1, relatedTarget);
Mark Otto's avatar
dist    
Mark Otto committed
2280

XhmikosR's avatar
XhmikosR committed
2281
      if (showEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2282
2283
        return;
      } // Disable totally Popper.js for Dropdown in Navbar
Jacob Thornton's avatar
Jacob Thornton committed
2284
2285


XhmikosR's avatar
Dist    
XhmikosR committed
2286
2287
      if (!this._inNavbar) {
        if (typeof Popper === 'undefined') {
XhmikosR's avatar
XhmikosR committed
2288
          throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org)');
Mark Otto's avatar
dist    
Mark Otto committed
2289
        }
Jacob Thornton's avatar
Jacob Thornton committed
2290

XhmikosR's avatar
Dist    
XhmikosR committed
2291
        var referenceElement = this._element;
Mark Otto's avatar
dist    
Mark Otto committed
2292

XhmikosR's avatar
Dist    
XhmikosR committed
2293
2294
        if (this._config.reference === 'parent') {
          referenceElement = parent;
XhmikosR's avatar
XhmikosR committed
2295
        } else if (isElement(this._config.reference)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2296
          referenceElement = this._config.reference; // Check if it's jQuery element
Mark Otto's avatar
dist    
Mark Otto committed
2297

XhmikosR's avatar
Dist    
XhmikosR committed
2298
2299
          if (typeof this._config.reference.jquery !== 'undefined') {
            referenceElement = this._config.reference[0];
Mark Otto's avatar
dist    
Mark Otto committed
2300
          }
XhmikosR's avatar
Dist    
XhmikosR committed
2301
2302
2303
        } // If boundary is not `scrollParent`, then set position to `static`
        // to allow the menu to "escape" the scroll parent's boundaries
        // https://github.com/twbs/bootstrap/issues/24251
Jacob Thornton's avatar
Jacob Thornton committed
2304

Mark Otto's avatar
dist    
Mark Otto committed
2305

XhmikosR's avatar
Dist    
XhmikosR committed
2306
        if (this._config.boundary !== 'scrollParent') {
XhmikosR's avatar
XhmikosR committed
2307
          parent.classList.add(CLASS_NAME_POSITION_STATIC);
XhmikosR's avatar
Dist    
XhmikosR committed
2308
        }
Mark Otto's avatar
dist    
Mark Otto committed
2309

XhmikosR's avatar
Dist    
XhmikosR committed
2310
2311
2312
2313
2314
        this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
      } // If this is a touch-enabled device we add extra
      // empty mouseover listeners to the body's immediate children;
      // only needed because of broken event delegation on iOS
      // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
Mark Otto's avatar
dist    
Mark Otto committed
2315

Johann-S's avatar
build    
Johann-S committed
2316

XhmikosR's avatar
XhmikosR committed
2317
      if ('ontouchstart' in document.documentElement && !parent.closest(SELECTOR_NAVBAR_NAV)) {
XhmikosR's avatar
XhmikosR committed
2318
2319
2320
        var _ref;

        (_ref = []).concat.apply(_ref, document.body.children).forEach(function (elem) {
XhmikosR's avatar
XhmikosR committed
2321
2322
          return EventHandler.on(elem, 'mouseover', null, noop());
        });
XhmikosR's avatar
Dist    
XhmikosR committed
2323
      }
Mark Otto's avatar
dist    
Mark Otto committed
2324

XhmikosR's avatar
Dist    
XhmikosR committed
2325
      this._element.focus();
Mark Otto's avatar
dist    
Mark Otto committed
2326

XhmikosR's avatar
Dist    
XhmikosR committed
2327
      this._element.setAttribute('aria-expanded', true);
Mark Otto's avatar
grunt    
Mark Otto committed
2328

XhmikosR's avatar
XhmikosR committed
2329
2330
2331
      Manipulator.toggleClass(this._menu, CLASS_NAME_SHOW$1);
      Manipulator.toggleClass(this._element, CLASS_NAME_SHOW$1);
      EventHandler.trigger(parent, EVENT_SHOWN$1, relatedTarget);
XhmikosR's avatar
Dist    
XhmikosR committed
2332
    };
Mark Otto's avatar
dist    
Mark Otto committed
2333

XhmikosR's avatar
Dist    
XhmikosR committed
2334
    _proto.hide = function hide() {
XhmikosR's avatar
XhmikosR committed
2335
      if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED$1) || !this._menu.classList.contains(CLASS_NAME_SHOW$1)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2336
2337
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2338

XhmikosR's avatar
XhmikosR committed
2339
      var parent = Dropdown.getParentFromElement(this._element);
XhmikosR's avatar
Dist    
XhmikosR committed
2340
2341
2342
      var relatedTarget = {
        relatedTarget: this._element
      };
XhmikosR's avatar
XhmikosR committed
2343
      var hideEvent = EventHandler.trigger(parent, EVENT_HIDE$1, relatedTarget);
Mark Otto's avatar
dist    
Mark Otto committed
2344

XhmikosR's avatar
XhmikosR committed
2345
      if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2346
2347
        return;
      }
Johann-S's avatar
build    
Johann-S committed
2348

XhmikosR's avatar
XhmikosR committed
2349
2350
2351
2352
      if (this._popper) {
        this._popper.destroy();
      }

XhmikosR's avatar
XhmikosR committed
2353
2354
2355
      Manipulator.toggleClass(this._menu, CLASS_NAME_SHOW$1);
      Manipulator.toggleClass(this._element, CLASS_NAME_SHOW$1);
      EventHandler.trigger(parent, EVENT_HIDDEN$1, relatedTarget);
XhmikosR's avatar
Dist    
XhmikosR committed
2356
    };
Johann-S's avatar
build    
Johann-S committed
2357

XhmikosR's avatar
Dist    
XhmikosR committed
2358
    _proto.dispose = function dispose() {
XhmikosR's avatar
XhmikosR committed
2359
2360
      Data.removeData(this._element, DATA_KEY$4);
      EventHandler.off(this._element, EVENT_KEY$4);
XhmikosR's avatar
Dist    
XhmikosR committed
2361
2362
      this._element = null;
      this._menu = null;
Mark Otto's avatar
dist    
Mark Otto committed
2363

XhmikosR's avatar
XhmikosR committed
2364
      if (this._popper) {
XhmikosR's avatar
Dist    
XhmikosR committed
2365
        this._popper.destroy();
Mark Otto's avatar
dist    
Mark Otto committed
2366

XhmikosR's avatar
Dist    
XhmikosR committed
2367
2368
2369
        this._popper = null;
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
2370

XhmikosR's avatar
Dist    
XhmikosR committed
2371
2372
    _proto.update = function update() {
      this._inNavbar = this._detectNavbar();
Mark Otto's avatar
build    
Mark Otto committed
2373

XhmikosR's avatar
XhmikosR committed
2374
      if (this._popper) {
XhmikosR's avatar
Dist    
XhmikosR committed
2375
2376
        this._popper.scheduleUpdate();
      }
Mark Otto's avatar
Mark Otto committed
2377
2378
    } // Private
    ;
Mark Otto's avatar
dist    
Mark Otto committed
2379

XhmikosR's avatar
Dist    
XhmikosR committed
2380
2381
    _proto._addEventListeners = function _addEventListeners() {
      var _this = this;
Mark Otto's avatar
build    
Mark Otto committed
2382

XhmikosR's avatar
XhmikosR committed
2383
      EventHandler.on(this._element, EVENT_CLICK, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2384
2385
        event.preventDefault();
        event.stopPropagation();
Mark Otto's avatar
build    
Mark Otto committed
2386

XhmikosR's avatar
Dist    
XhmikosR committed
2387
2388
2389
        _this.toggle();
      });
    };
Mark Otto's avatar
dist    
Mark Otto committed
2390

XhmikosR's avatar
Dist    
XhmikosR committed
2391
    _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
2392
      config = _objectSpread2(_objectSpread2(_objectSpread2({}, this.constructor.Default), Manipulator.getDataAttributes(this._element)), config);
XhmikosR's avatar
XhmikosR committed
2393
      typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
XhmikosR's avatar
Dist    
XhmikosR committed
2394
2395
      return config;
    };
Mark Otto's avatar
dist    
Mark Otto committed
2396

XhmikosR's avatar
Dist    
XhmikosR committed
2397
    _proto._getMenuElement = function _getMenuElement() {
XhmikosR's avatar
XhmikosR committed
2398
      return SelectorEngine.next(this._element, SELECTOR_MENU)[0];
XhmikosR's avatar
Dist    
XhmikosR committed
2399
    };
Mark Otto's avatar
dist    
Mark Otto committed
2400

XhmikosR's avatar
Dist    
XhmikosR committed
2401
    _proto._getPlacement = function _getPlacement() {
XhmikosR's avatar
XhmikosR committed
2402
      var parentDropdown = this._element.parentNode;
XhmikosR's avatar
XhmikosR committed
2403
      var placement = PLACEMENT_BOTTOM; // Handle dropup
Mark Otto's avatar
dist    
Mark Otto committed
2404

XhmikosR's avatar
XhmikosR committed
2405
2406
      if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
        placement = PLACEMENT_TOP;
Mark Otto's avatar
build    
Mark Otto committed
2407

XhmikosR's avatar
XhmikosR committed
2408
2409
        if (this._menu.classList.contains(CLASS_NAME_MENURIGHT)) {
          placement = PLACEMENT_TOPEND;
XhmikosR's avatar
Dist    
XhmikosR committed
2410
        }
XhmikosR's avatar
XhmikosR committed
2411
2412
2413
2414
2415
2416
      } else if (parentDropdown.classList.contains(CLASS_NAME_DROPRIGHT)) {
        placement = PLACEMENT_RIGHT;
      } else if (parentDropdown.classList.contains(CLASS_NAME_DROPLEFT)) {
        placement = PLACEMENT_LEFT;
      } else if (this._menu.classList.contains(CLASS_NAME_MENURIGHT)) {
        placement = PLACEMENT_BOTTOMEND;
XhmikosR's avatar
Dist    
XhmikosR committed
2417
      }
Jacob Thornton's avatar
Jacob Thornton committed
2418

XhmikosR's avatar
Dist    
XhmikosR committed
2419
2420
      return placement;
    };
Mark Otto's avatar
dist    
Mark Otto committed
2421

XhmikosR's avatar
Dist    
XhmikosR committed
2422
    _proto._detectNavbar = function _detectNavbar() {
XhmikosR's avatar
XhmikosR committed
2423
      return Boolean(this._element.closest("." + CLASS_NAME_NAVBAR));
XhmikosR's avatar
Dist    
XhmikosR committed
2424
    };
Jacob Thornton's avatar
Jacob Thornton committed
2425

Mark Otto's avatar
Mark Otto committed
2426
    _proto._getOffset = function _getOffset() {
XhmikosR's avatar
Dist    
XhmikosR committed
2427
      var _this2 = this;
Mark Otto's avatar
dist    
Mark Otto committed
2428

Mark Otto's avatar
Mark Otto committed
2429
      var offset = {};
Jacob Thornton's avatar
Jacob Thornton committed
2430

XhmikosR's avatar
Dist    
XhmikosR committed
2431
      if (typeof this._config.offset === 'function') {
Mark Otto's avatar
Mark Otto committed
2432
        offset.fn = function (data) {
XhmikosR's avatar
XhmikosR committed
2433
          data.offsets = _objectSpread2(_objectSpread2({}, data.offsets), _this2._config.offset(data.offsets, _this2._element) || {});
XhmikosR's avatar
Dist    
XhmikosR committed
2434
2435
2436
          return data;
        };
      } else {
Mark Otto's avatar
Mark Otto committed
2437
        offset.offset = this._config.offset;
XhmikosR's avatar
Dist    
XhmikosR committed
2438
      }
Mark Otto's avatar
dist    
Mark Otto committed
2439

Mark Otto's avatar
Mark Otto committed
2440
2441
2442
2443
      return offset;
    };

    _proto._getPopperConfig = function _getPopperConfig() {
XhmikosR's avatar
Dist    
XhmikosR committed
2444
2445
2446
      var popperConfig = {
        placement: this._getPlacement(),
        modifiers: {
Mark Otto's avatar
Mark Otto committed
2447
          offset: this._getOffset(),
XhmikosR's avatar
Dist    
XhmikosR committed
2448
2449
2450
2451
2452
          flip: {
            enabled: this._config.flip
          },
          preventOverflow: {
            boundariesElement: this._config.boundary
Mark Otto's avatar
grunt    
Mark Otto committed
2453
          }
XhmikosR's avatar
XhmikosR committed
2454
2455
        }
      }; // Disable Popper.js if we have a static display
Jacob Thornton's avatar
Jacob Thornton committed
2456

XhmikosR's avatar
Dist    
XhmikosR committed
2457
2458
2459
2460
2461
      if (this._config.display === 'static') {
        popperConfig.modifiers.applyStyle = {
          enabled: false
        };
      }
Jacob Thornton's avatar
Jacob Thornton committed
2462

XhmikosR's avatar
XhmikosR committed
2463
      return _objectSpread2(_objectSpread2({}, popperConfig), this._config.popperConfig);
Mark Otto's avatar
Mark Otto committed
2464
2465
    } // Static
    ;
Mark Otto's avatar
dist    
Mark Otto committed
2466

XhmikosR's avatar
XhmikosR committed
2467
    Dropdown.dropdownInterface = function dropdownInterface(element, config) {
XhmikosR's avatar
XhmikosR committed
2468
      var data = Data.getData(element, DATA_KEY$4);
Mark Otto's avatar
dist    
Mark Otto committed
2469

XhmikosR's avatar
XhmikosR committed
2470
      var _config = typeof config === 'object' ? config : null;
Jacob Thornton's avatar
Jacob Thornton committed
2471

XhmikosR's avatar
XhmikosR committed
2472
2473
2474
2475
2476
2477
      if (!data) {
        data = new Dropdown(element, _config);
      }

      if (typeof config === 'string') {
        if (typeof data[config] === 'undefined') {
XhmikosR's avatar
Dist.    
XhmikosR committed
2478
          throw new TypeError("No method named \"" + config + "\"");
XhmikosR's avatar
Dist    
XhmikosR committed
2479
        }
Johann-S's avatar
build    
Johann-S committed
2480

XhmikosR's avatar
XhmikosR committed
2481
2482
2483
        data[config]();
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
2484

XhmikosR's avatar
XhmikosR committed
2485
    Dropdown.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
XhmikosR committed
2486
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
2487
        Dropdown.dropdownInterface(this, config);
XhmikosR's avatar
Dist    
XhmikosR committed
2488
2489
      });
    };
Jacob Thornton's avatar
Jacob Thornton committed
2490

XhmikosR's avatar
XhmikosR committed
2491
    Dropdown.clearMenus = function clearMenus(event) {
XhmikosR's avatar
XhmikosR committed
2492
      if (event && (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2493
2494
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2495

XhmikosR's avatar
XhmikosR committed
2496
      var toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE$2);
Mark Otto's avatar
dist    
Mark Otto committed
2497

XhmikosR's avatar
Dist    
XhmikosR committed
2498
      for (var i = 0, len = toggles.length; i < len; i++) {
XhmikosR's avatar
XhmikosR committed
2499
        var parent = Dropdown.getParentFromElement(toggles[i]);
XhmikosR's avatar
XhmikosR committed
2500
        var context = Data.getData(toggles[i], DATA_KEY$4);
XhmikosR's avatar
Dist    
XhmikosR committed
2501
2502
2503
        var relatedTarget = {
          relatedTarget: toggles[i]
        };
Mark Otto's avatar
dist    
Mark Otto committed
2504

XhmikosR's avatar
Dist    
XhmikosR committed
2505
2506
        if (event && event.type === 'click') {
          relatedTarget.clickEvent = event;
Mark Otto's avatar
grunt    
Mark Otto committed
2507
2508
        }

XhmikosR's avatar
Dist    
XhmikosR committed
2509
2510
        if (!context) {
          continue;
Mark Otto's avatar
dist    
Mark Otto committed
2511
        }
Jacob Thornton's avatar
Jacob Thornton committed
2512

XhmikosR's avatar
Dist    
XhmikosR committed
2513
        var dropdownMenu = context._menu;
Jacob Thornton's avatar
Jacob Thornton committed
2514

XhmikosR's avatar
XhmikosR committed
2515
        if (!toggles[i].classList.contains(CLASS_NAME_SHOW$1)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2516
2517
          continue;
        }
Mark Otto's avatar
dist    
Mark Otto committed
2518

XhmikosR's avatar
XhmikosR committed
2519
        if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.key === TAB_KEY) && dropdownMenu.contains(event.target)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2520
          continue;
Mark Otto's avatar
dist    
Mark Otto committed
2521
        }
Jacob Thornton's avatar
Jacob Thornton committed
2522

XhmikosR's avatar
XhmikosR committed
2523
        var hideEvent = EventHandler.trigger(parent, EVENT_HIDE$1, relatedTarget);
Jacob Thornton's avatar
Jacob Thornton committed
2524

XhmikosR's avatar
XhmikosR committed
2525
        if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2526
2527
2528
2529
2530
2531
          continue;
        } // If this is a touch-enabled device we remove the extra
        // empty mouseover listeners we added for iOS support


        if ('ontouchstart' in document.documentElement) {
XhmikosR's avatar
XhmikosR committed
2532
2533
2534
          var _ref2;

          (_ref2 = []).concat.apply(_ref2, document.body.children).forEach(function (elem) {
XhmikosR's avatar
XhmikosR committed
2535
2536
            return EventHandler.off(elem, 'mouseover', null, noop());
          });
Mark Otto's avatar
dist    
Mark Otto committed
2537
        }
Jacob Thornton's avatar
Jacob Thornton committed
2538

XhmikosR's avatar
Dist    
XhmikosR committed
2539
        toggles[i].setAttribute('aria-expanded', 'false');
XhmikosR's avatar
XhmikosR committed
2540
2541
2542
2543
2544

        if (context._popper) {
          context._popper.destroy();
        }

XhmikosR's avatar
XhmikosR committed
2545
2546
2547
        dropdownMenu.classList.remove(CLASS_NAME_SHOW$1);
        toggles[i].classList.remove(CLASS_NAME_SHOW$1);
        EventHandler.trigger(parent, EVENT_HIDDEN$1, relatedTarget);
XhmikosR's avatar
Dist    
XhmikosR committed
2548
2549
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
2550

XhmikosR's avatar
XhmikosR committed
2551
2552
    Dropdown.getParentFromElement = function getParentFromElement(element) {
      return getElementFromSelector(element) || element.parentNode;
XhmikosR's avatar
XhmikosR committed
2553
    };
Jacob Thornton's avatar
Jacob Thornton committed
2554

XhmikosR's avatar
XhmikosR committed
2555
    Dropdown.dataApiKeydownHandler = function dataApiKeydownHandler(event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2556
2557
2558
2559
2560
2561
2562
      // If not input/textarea:
      //  - And not a key in REGEXP_KEYDOWN => not a dropdown command
      // If input/textarea:
      //  - If space key => not a dropdown command
      //  - If key is other than escape
      //    - If key is not up or down => not a dropdown command
      //    - If trigger inside the menu => not a dropdown command
XhmikosR's avatar
XhmikosR committed
2563
      if (/input|textarea/i.test(event.target.tagName) ? event.key === SPACE_KEY || event.key !== ESCAPE_KEY && (event.key !== ARROW_DOWN_KEY && event.key !== ARROW_UP_KEY || event.target.closest(SELECTOR_MENU)) : !REGEXP_KEYDOWN.test(event.key)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2564
2565
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2566

XhmikosR's avatar
Dist    
XhmikosR committed
2567
2568
      event.preventDefault();
      event.stopPropagation();
Jacob Thornton's avatar
Jacob Thornton committed
2569

XhmikosR's avatar
XhmikosR committed
2570
      if (this.disabled || this.classList.contains(CLASS_NAME_DISABLED$1)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2571
2572
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2573

XhmikosR's avatar
XhmikosR committed
2574
      var parent = Dropdown.getParentFromElement(this);
XhmikosR's avatar
XhmikosR committed
2575
      var isActive = this.classList.contains(CLASS_NAME_SHOW$1);
Jacob Thornton's avatar
Jacob Thornton committed
2576

XhmikosR's avatar
XhmikosR committed
2577
      if (event.key === ESCAPE_KEY) {
XhmikosR's avatar
XhmikosR committed
2578
2579
2580
2581
2582
        var button = this.matches(SELECTOR_DATA_TOGGLE$2) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$2)[0];
        button.focus();
        Dropdown.clearMenus();
        return;
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2583

XhmikosR's avatar
XhmikosR committed
2584
      if (!isActive || event.key === SPACE_KEY) {
XhmikosR's avatar
XhmikosR committed
2585
        Dropdown.clearMenus();
XhmikosR's avatar
Dist    
XhmikosR committed
2586
2587
        return;
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2588

XhmikosR's avatar
XhmikosR committed
2589
      var items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, parent).filter(isVisible);
Jacob Thornton's avatar
Jacob Thornton committed
2590

XhmikosR's avatar
XhmikosR committed
2591
      if (!items.length) {
XhmikosR's avatar
Dist    
XhmikosR committed
2592
2593
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2594

XhmikosR's avatar
XhmikosR committed
2595
      var index = items.indexOf(event.target);
Mark Otto's avatar
dist    
Mark Otto committed
2596

XhmikosR's avatar
XhmikosR committed
2597
      if (event.key === ARROW_UP_KEY && index > 0) {
XhmikosR's avatar
Dist    
XhmikosR committed
2598
2599
2600
        // Up
        index--;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2601

XhmikosR's avatar
XhmikosR committed
2602
      if (event.key === ARROW_DOWN_KEY && index < items.length - 1) {
XhmikosR's avatar
Dist    
XhmikosR committed
2603
2604
        // Down
        index++;
XhmikosR's avatar
XhmikosR committed
2605
2606
      } // index is -1 if the first keydown is an ArrowUp

Mark Otto's avatar
dist    
Mark Otto committed
2607

XhmikosR's avatar
XhmikosR committed
2608
      index = index === -1 ? 0 : index;
XhmikosR's avatar
Dist    
XhmikosR committed
2609
      items[index].focus();
Mark Otto's avatar
dist    
Mark Otto committed
2610
    };
Jacob Thornton's avatar
Jacob Thornton committed
2611

XhmikosR's avatar
XhmikosR committed
2612
    Dropdown.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
2613
2614
2615
      return Data.getData(element, DATA_KEY$4);
    };

XhmikosR's avatar
Dist    
XhmikosR committed
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
    _createClass(Dropdown, null, [{
      key: "VERSION",
      get: function get() {
        return VERSION$4;
      }
    }, {
      key: "Default",
      get: function get() {
        return Default$2;
      }
    }, {
      key: "DefaultType",
      get: function get() {
        return DefaultType$2;
      }
    }]);

Mark Otto's avatar
dist    
Mark Otto committed
2633
    return Dropdown;
XhmikosR's avatar
Dist    
XhmikosR committed
2634
2635
2636
2637
2638
2639
2640
2641
  }();
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */


XhmikosR's avatar
XhmikosR committed
2642
2643
2644
2645
2646
  EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$2, Dropdown.dataApiKeydownHandler);
  EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
  EventHandler.on(document, EVENT_CLICK_DATA_API$4, Dropdown.clearMenus);
  EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
  EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$2, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2647
2648
    event.preventDefault();
    event.stopPropagation();
XhmikosR's avatar
XhmikosR committed
2649
    Dropdown.dropdownInterface(this, 'toggle');
XhmikosR's avatar
XhmikosR committed
2650
  });
XhmikosR's avatar
XhmikosR committed
2651
  EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_FORM_CHILD, function (e) {
XhmikosR's avatar
XhmikosR committed
2652
    return e.stopPropagation();
XhmikosR's avatar
Dist    
XhmikosR committed
2653
  });
XhmikosR's avatar
XhmikosR committed
2654
  var $$5 = getjQuery();
XhmikosR's avatar
Dist    
XhmikosR committed
2655
2656
2657
2658
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
2659
   * add .dropdown to jQuery only if jQuery is present
XhmikosR's avatar
Dist    
XhmikosR committed
2660
2661
   */

2662
2663
  /* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
2664
2665
2666
2667
  if ($$5) {
    var JQUERY_NO_CONFLICT$4 = $$5.fn[NAME$4];
    $$5.fn[NAME$4] = Dropdown.jQueryInterface;
    $$5.fn[NAME$4].Constructor = Dropdown;
XhmikosR's avatar
Dist    
XhmikosR committed
2668

XhmikosR's avatar
XhmikosR committed
2669
2670
2671
    $$5.fn[NAME$4].noConflict = function () {
      $$5.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
      return Dropdown.jQueryInterface;
XhmikosR's avatar
XhmikosR committed
2672
2673
    };
  }
Jacob Thornton's avatar
Jacob Thornton committed
2674

XhmikosR's avatar
Dist    
XhmikosR committed
2675
2676
2677
2678
2679
2680
2681
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME$5 = 'modal';
2682
  var VERSION$5 = '5.0.0-alpha1';
XhmikosR's avatar
Dist    
XhmikosR committed
2683
2684
2685
  var DATA_KEY$5 = 'bs.modal';
  var EVENT_KEY$5 = "." + DATA_KEY$5;
  var DATA_API_KEY$5 = '.data-api';
XhmikosR's avatar
XhmikosR committed
2686
  var ESCAPE_KEY$1 = 'Escape';
XhmikosR's avatar
Dist    
XhmikosR committed
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
  var Default$3 = {
    backdrop: true,
    keyboard: true,
    focus: true,
    show: true
  };
  var DefaultType$3 = {
    backdrop: '(boolean|string)',
    keyboard: 'boolean',
    focus: 'boolean',
    show: 'boolean'
  };
XhmikosR's avatar
XhmikosR committed
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
  var EVENT_HIDE$2 = "hide" + EVENT_KEY$5;
  var EVENT_HIDE_PREVENTED = "hidePrevented" + EVENT_KEY$5;
  var EVENT_HIDDEN$2 = "hidden" + EVENT_KEY$5;
  var EVENT_SHOW$2 = "show" + EVENT_KEY$5;
  var EVENT_SHOWN$2 = "shown" + EVENT_KEY$5;
  var EVENT_FOCUSIN = "focusin" + EVENT_KEY$5;
  var EVENT_RESIZE = "resize" + EVENT_KEY$5;
  var EVENT_CLICK_DISMISS = "click.dismiss" + EVENT_KEY$5;
  var EVENT_KEYDOWN_DISMISS = "keydown.dismiss" + EVENT_KEY$5;
  var EVENT_MOUSEUP_DISMISS = "mouseup.dismiss" + EVENT_KEY$5;
  var EVENT_MOUSEDOWN_DISMISS = "mousedown.dismiss" + EVENT_KEY$5;
  var EVENT_CLICK_DATA_API$5 = "click" + EVENT_KEY$5 + DATA_API_KEY$5;
  var CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure';
  var CLASS_NAME_BACKDROP = 'modal-backdrop';
  var CLASS_NAME_OPEN = 'modal-open';
  var CLASS_NAME_FADE = 'fade';
  var CLASS_NAME_SHOW$2 = 'show';
  var CLASS_NAME_STATIC = 'modal-static';
  var SELECTOR_DIALOG = '.modal-dialog';
  var SELECTOR_MODAL_BODY = '.modal-body';
  var SELECTOR_DATA_TOGGLE$3 = '[data-toggle="modal"]';
  var SELECTOR_DATA_DISMISS = '[data-dismiss="modal"]';
  var SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
  var SELECTOR_STICKY_CONTENT = '.sticky-top';
XhmikosR's avatar
XhmikosR committed
2723
2724
2725
2726
2727
  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */
XhmikosR's avatar
Dist    
XhmikosR committed
2728

XhmikosR's avatar
XhmikosR committed
2729
  var Modal = /*#__PURE__*/function () {
XhmikosR's avatar
Dist    
XhmikosR committed
2730
2731
2732
    function Modal(element, config) {
      this._config = this._getConfig(config);
      this._element = element;
XhmikosR's avatar
XhmikosR committed
2733
      this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, element);
XhmikosR's avatar
Dist    
XhmikosR committed
2734
2735
2736
2737
2738
2739
      this._backdrop = null;
      this._isShown = false;
      this._isBodyOverflowing = false;
      this._ignoreBackdropClick = false;
      this._isTransitioning = false;
      this._scrollbarWidth = 0;
XhmikosR's avatar
XhmikosR committed
2740
      Data.setData(element, DATA_KEY$5, this);
XhmikosR's avatar
Dist    
XhmikosR committed
2741
2742
2743
2744
2745
2746
2747
2748
    } // Getters


    var _proto = Modal.prototype;

    // Public
    _proto.toggle = function toggle(relatedTarget) {
      return this._isShown ? this.hide() : this.show(relatedTarget);
Mark Otto's avatar
dist    
Mark Otto committed
2749
    };
Jacob Thornton's avatar
Jacob Thornton committed
2750

XhmikosR's avatar
Dist    
XhmikosR committed
2751
2752
    _proto.show = function show(relatedTarget) {
      var _this = this;
Mark Otto's avatar
grunt    
Mark Otto committed
2753

XhmikosR's avatar
Dist    
XhmikosR committed
2754
2755
2756
      if (this._isShown || this._isTransitioning) {
        return;
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2757

XhmikosR's avatar
XhmikosR committed
2758
      if (this._element.classList.contains(CLASS_NAME_FADE)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2759
2760
        this._isTransitioning = true;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2761

XhmikosR's avatar
XhmikosR committed
2762
      var showEvent = EventHandler.trigger(this._element, EVENT_SHOW$2, {
XhmikosR's avatar
Dist    
XhmikosR committed
2763
2764
        relatedTarget: relatedTarget
      });
Jacob Thornton's avatar
Jacob Thornton committed
2765

XhmikosR's avatar
XhmikosR committed
2766
      if (this._isShown || showEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2767
2768
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2769

XhmikosR's avatar
Dist    
XhmikosR committed
2770
      this._isShown = true;
Mark Otto's avatar
dist    
Mark Otto committed
2771

XhmikosR's avatar
Dist    
XhmikosR committed
2772
      this._checkScrollbar();
Jacob Thornton's avatar
Jacob Thornton committed
2773

XhmikosR's avatar
Dist    
XhmikosR committed
2774
      this._setScrollbar();
Mark Otto's avatar
dist    
Mark Otto committed
2775

XhmikosR's avatar
Dist    
XhmikosR committed
2776
      this._adjustDialog();
Jacob Thornton's avatar
Jacob Thornton committed
2777

XhmikosR's avatar
Dist    
XhmikosR committed
2778
      this._setEscapeEvent();
Jacob Thornton's avatar
Jacob Thornton committed
2779

XhmikosR's avatar
Dist    
XhmikosR committed
2780
      this._setResizeEvent();
Mark Otto's avatar
grunt    
Mark Otto committed
2781

XhmikosR's avatar
XhmikosR committed
2782
      EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2783
2784
        return _this.hide(event);
      });
XhmikosR's avatar
XhmikosR committed
2785
2786
      EventHandler.on(this._dialog, EVENT_MOUSEDOWN_DISMISS, function () {
        EventHandler.one(_this._element, EVENT_MOUSEUP_DISMISS, function (event) {
XhmikosR's avatar
XhmikosR committed
2787
          if (event.target === _this._element) {
XhmikosR's avatar
Dist    
XhmikosR committed
2788
2789
            _this._ignoreBackdropClick = true;
          }
Mark Otto's avatar
dist    
Mark Otto committed
2790
        });
XhmikosR's avatar
Dist    
XhmikosR committed
2791
      });
Jacob Thornton's avatar
Jacob Thornton committed
2792

XhmikosR's avatar
Dist    
XhmikosR committed
2793
2794
2795
2796
      this._showBackdrop(function () {
        return _this._showElement(relatedTarget);
      });
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2797

XhmikosR's avatar
Dist    
XhmikosR committed
2798
2799
    _proto.hide = function hide(event) {
      var _this2 = this;
Jacob Thornton's avatar
Jacob Thornton committed
2800

XhmikosR's avatar
Dist    
XhmikosR committed
2801
2802
2803
      if (event) {
        event.preventDefault();
      }
Jacob Thornton's avatar
Jacob Thornton committed
2804

XhmikosR's avatar
Dist    
XhmikosR committed
2805
2806
2807
      if (!this._isShown || this._isTransitioning) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2808

XhmikosR's avatar
XhmikosR committed
2809
      var hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$2);
Jacob Thornton's avatar
Jacob Thornton committed
2810

2811
      if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2812
2813
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2814

XhmikosR's avatar
Dist    
XhmikosR committed
2815
      this._isShown = false;
XhmikosR's avatar
XhmikosR committed
2816

XhmikosR's avatar
XhmikosR committed
2817
      var transition = this._element.classList.contains(CLASS_NAME_FADE);
Jacob Thornton's avatar
Jacob Thornton committed
2818

XhmikosR's avatar
Dist    
XhmikosR committed
2819
2820
2821
      if (transition) {
        this._isTransitioning = true;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2822

XhmikosR's avatar
Dist    
XhmikosR committed
2823
      this._setEscapeEvent();
Jacob Thornton's avatar
Jacob Thornton committed
2824

XhmikosR's avatar
Dist    
XhmikosR committed
2825
      this._setResizeEvent();
Jacob Thornton's avatar
Jacob Thornton committed
2826

XhmikosR's avatar
XhmikosR committed
2827
      EventHandler.off(document, EVENT_FOCUSIN);
XhmikosR's avatar
XhmikosR committed
2828

XhmikosR's avatar
XhmikosR committed
2829
      this._element.classList.remove(CLASS_NAME_SHOW$2);
XhmikosR's avatar
XhmikosR committed
2830

XhmikosR's avatar
XhmikosR committed
2831
2832
      EventHandler.off(this._element, EVENT_CLICK_DISMISS);
      EventHandler.off(this._dialog, EVENT_MOUSEDOWN_DISMISS);
Jacob Thornton's avatar
Jacob Thornton committed
2833

XhmikosR's avatar
Dist    
XhmikosR committed
2834
      if (transition) {
XhmikosR's avatar
XhmikosR committed
2835
2836
        var transitionDuration = getTransitionDurationFromElement(this._element);
        EventHandler.one(this._element, TRANSITION_END, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2837
          return _this2._hideModal(event);
XhmikosR's avatar
XhmikosR committed
2838
2839
        });
        emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
2840
2841
2842
2843
      } else {
        this._hideModal();
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
2844

XhmikosR's avatar
Dist    
XhmikosR committed
2845
2846
    _proto.dispose = function dispose() {
      [window, this._element, this._dialog].forEach(function (htmlElement) {
XhmikosR's avatar
XhmikosR committed
2847
        return EventHandler.off(htmlElement, EVENT_KEY$5);
XhmikosR's avatar
Dist    
XhmikosR committed
2848
2849
      });
      /**
XhmikosR's avatar
XhmikosR committed
2850
       * `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API`
XhmikosR's avatar
Dist    
XhmikosR committed
2851
       * Do not move `document` in `htmlElements` array
XhmikosR's avatar
XhmikosR committed
2852
       * It will remove `EVENT_CLICK_DATA_API` event that should remain
XhmikosR's avatar
Dist    
XhmikosR committed
2853
       */
Mark Otto's avatar
grunt    
Mark Otto committed
2854

XhmikosR's avatar
XhmikosR committed
2855
      EventHandler.off(document, EVENT_FOCUSIN);
XhmikosR's avatar
XhmikosR committed
2856
      Data.removeData(this._element, DATA_KEY$5);
XhmikosR's avatar
Dist    
XhmikosR committed
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
      this._config = null;
      this._element = null;
      this._dialog = null;
      this._backdrop = null;
      this._isShown = null;
      this._isBodyOverflowing = null;
      this._ignoreBackdropClick = null;
      this._isTransitioning = null;
      this._scrollbarWidth = null;
    };
Jacob Thornton's avatar
Jacob Thornton committed
2867

XhmikosR's avatar
Dist    
XhmikosR committed
2868
2869
    _proto.handleUpdate = function handleUpdate() {
      this._adjustDialog();
Mark Otto's avatar
Mark Otto committed
2870
2871
    } // Private
    ;
Jacob Thornton's avatar
Jacob Thornton committed
2872

XhmikosR's avatar
Dist    
XhmikosR committed
2873
    _proto._getConfig = function _getConfig(config) {
XhmikosR's avatar
XhmikosR committed
2874
      config = _objectSpread2(_objectSpread2({}, Default$3), config);
XhmikosR's avatar
XhmikosR committed
2875
      typeCheckConfig(NAME$5, config, DefaultType$3);
XhmikosR's avatar
Dist    
XhmikosR committed
2876
2877
      return config;
    };
Jacob Thornton's avatar
Jacob Thornton committed
2878

XhmikosR's avatar
Dist    
XhmikosR committed
2879
2880
    _proto._showElement = function _showElement(relatedTarget) {
      var _this3 = this;
Jacob Thornton's avatar
Jacob Thornton committed
2881

XhmikosR's avatar
XhmikosR committed
2882
      var transition = this._element.classList.contains(CLASS_NAME_FADE);
Mark Otto's avatar
dist    
Mark Otto committed
2883

XhmikosR's avatar
XhmikosR committed
2884
      var modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog);
XhmikosR's avatar
XhmikosR committed
2885

XhmikosR's avatar
Dist    
XhmikosR committed
2886
2887
2888
2889
      if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
        // Don't move modal's DOM position
        document.body.appendChild(this._element);
      }
Mark Otto's avatar
dist    
Mark Otto committed
2890

XhmikosR's avatar
Dist    
XhmikosR committed
2891
      this._element.style.display = 'block';
Jacob Thornton's avatar
Jacob Thornton committed
2892

XhmikosR's avatar
Dist    
XhmikosR committed
2893
      this._element.removeAttribute('aria-hidden');
Mark Otto's avatar
grunt    
Mark Otto committed
2894

Mark Otto's avatar
dist    
Mark Otto committed
2895
2896
      this._element.setAttribute('aria-modal', true);

XhmikosR's avatar
XhmikosR committed
2897
2898
2899
      this._element.scrollTop = 0;

      if (modalBody) {
XhmikosR's avatar
XhmikosR committed
2900
        modalBody.scrollTop = 0;
Mark Otto's avatar
Mark Otto committed
2901
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2902

XhmikosR's avatar
Dist    
XhmikosR committed
2903
      if (transition) {
XhmikosR's avatar
XhmikosR committed
2904
        reflow(this._element);
XhmikosR's avatar
Dist    
XhmikosR committed
2905
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2906

XhmikosR's avatar
XhmikosR committed
2907
      this._element.classList.add(CLASS_NAME_SHOW$2);
Mark Otto's avatar
dist    
Mark Otto committed
2908

XhmikosR's avatar
Dist    
XhmikosR committed
2909
2910
2911
      if (this._config.focus) {
        this._enforceFocus();
      }
Mark Otto's avatar
dist    
Mark Otto committed
2912

XhmikosR's avatar
Dist    
XhmikosR committed
2913
2914
2915
      var transitionComplete = function transitionComplete() {
        if (_this3._config.focus) {
          _this3._element.focus();
Jacob Thornton's avatar
Jacob Thornton committed
2916
        }
Mark Otto's avatar
dist    
Mark Otto committed
2917

XhmikosR's avatar
Dist    
XhmikosR committed
2918
        _this3._isTransitioning = false;
XhmikosR's avatar
XhmikosR committed
2919
        EventHandler.trigger(_this3._element, EVENT_SHOWN$2, {
XhmikosR's avatar
XhmikosR committed
2920
2921
          relatedTarget: relatedTarget
        });
Mark Otto's avatar
grunt    
Mark Otto committed
2922
2923
      };

XhmikosR's avatar
Dist    
XhmikosR committed
2924
      if (transition) {
XhmikosR's avatar
XhmikosR committed
2925
2926
2927
        var transitionDuration = getTransitionDurationFromElement(this._dialog);
        EventHandler.one(this._dialog, TRANSITION_END, transitionComplete);
        emulateTransitionEnd(this._dialog, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
2928
2929
2930
2931
      } else {
        transitionComplete();
      }
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2932

XhmikosR's avatar
Dist    
XhmikosR committed
2933
2934
    _proto._enforceFocus = function _enforceFocus() {
      var _this4 = this;
Mark Otto's avatar
grunt    
Mark Otto committed
2935

XhmikosR's avatar
XhmikosR committed
2936
      EventHandler.off(document, EVENT_FOCUSIN); // guard against infinite focus loop
XhmikosR's avatar
XhmikosR committed
2937

XhmikosR's avatar
XhmikosR committed
2938
      EventHandler.on(document, EVENT_FOCUSIN, function (event) {
XhmikosR's avatar
XhmikosR committed
2939
        if (document !== event.target && _this4._element !== event.target && !_this4._element.contains(event.target)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2940
          _this4._element.focus();
Mark Otto's avatar
dist    
Mark Otto committed
2941
        }
XhmikosR's avatar
Dist    
XhmikosR committed
2942
2943
      });
    };
Mark Otto's avatar
dist    
Mark Otto committed
2944

XhmikosR's avatar
Dist    
XhmikosR committed
2945
2946
    _proto._setEscapeEvent = function _setEscapeEvent() {
      var _this5 = this;
Mark Otto's avatar
grunt    
Mark Otto committed
2947

XhmikosR's avatar
XhmikosR committed
2948
2949
      if (this._isShown) {
        EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, function (event) {
XhmikosR's avatar
XhmikosR committed
2950
          if (_this5._config.keyboard && event.key === ESCAPE_KEY$1) {
XhmikosR's avatar
XhmikosR committed
2951
2952
2953
            event.preventDefault();

            _this5.hide();
XhmikosR's avatar
XhmikosR committed
2954
          } else if (!_this5._config.keyboard && event.key === ESCAPE_KEY$1) {
XhmikosR's avatar
XhmikosR committed
2955
            _this5._triggerBackdropTransition();
XhmikosR's avatar
Dist    
XhmikosR committed
2956
2957
          }
        });
2958
      } else {
XhmikosR's avatar
XhmikosR committed
2959
        EventHandler.off(this._element, EVENT_KEYDOWN_DISMISS);
XhmikosR's avatar
Dist    
XhmikosR committed
2960
2961
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
2962

XhmikosR's avatar
Dist    
XhmikosR committed
2963
2964
    _proto._setResizeEvent = function _setResizeEvent() {
      var _this6 = this;
Jacob Thornton's avatar
Jacob Thornton committed
2965

XhmikosR's avatar
Dist    
XhmikosR committed
2966
      if (this._isShown) {
XhmikosR's avatar
XhmikosR committed
2967
        EventHandler.on(window, EVENT_RESIZE, function () {
2968
          return _this6._adjustDialog();
XhmikosR's avatar
Dist    
XhmikosR committed
2969
2970
        });
      } else {
XhmikosR's avatar
XhmikosR committed
2971
        EventHandler.off(window, EVENT_RESIZE);
XhmikosR's avatar
Dist    
XhmikosR committed
2972
2973
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
2974

XhmikosR's avatar
Dist    
XhmikosR committed
2975
2976
    _proto._hideModal = function _hideModal() {
      var _this7 = this;
Mark Otto's avatar
dist    
Mark Otto committed
2977

XhmikosR's avatar
Dist    
XhmikosR committed
2978
      this._element.style.display = 'none';
Mark Otto's avatar
dist    
Mark Otto committed
2979

XhmikosR's avatar
Dist    
XhmikosR committed
2980
      this._element.setAttribute('aria-hidden', true);
Mark Otto's avatar
dist    
Mark Otto committed
2981

Mark Otto's avatar
dist    
Mark Otto committed
2982
2983
      this._element.removeAttribute('aria-modal');

XhmikosR's avatar
Dist    
XhmikosR committed
2984
      this._isTransitioning = false;
Mark Otto's avatar
dist    
Mark Otto committed
2985

XhmikosR's avatar
Dist    
XhmikosR committed
2986
      this._showBackdrop(function () {
XhmikosR's avatar
XhmikosR committed
2987
        document.body.classList.remove(CLASS_NAME_OPEN);
Mark Otto's avatar
dist    
Mark Otto committed
2988

XhmikosR's avatar
Dist    
XhmikosR committed
2989
        _this7._resetAdjustments();
Mark Otto's avatar
dist    
Mark Otto committed
2990

XhmikosR's avatar
Dist    
XhmikosR committed
2991
        _this7._resetScrollbar();
Jacob Thornton's avatar
Jacob Thornton committed
2992

XhmikosR's avatar
XhmikosR committed
2993
        EventHandler.trigger(_this7._element, EVENT_HIDDEN$2);
XhmikosR's avatar
Dist    
XhmikosR committed
2994
2995
      });
    };
Mark Otto's avatar
dist    
Mark Otto committed
2996

XhmikosR's avatar
Dist    
XhmikosR committed
2997
    _proto._removeBackdrop = function _removeBackdrop() {
2998
      this._backdrop.parentNode.removeChild(this._backdrop);
XhmikosR's avatar
XhmikosR committed
2999

3000
      this._backdrop = null;
For faster browsing, not all history is shown. View entire blame