bootstrap.js 153 KB
Newer Older
XhmikosR's avatar
Dist    
XhmikosR committed
2001
        });
Mark Otto's avatar
dist    
Mark Otto committed
2002

XhmikosR's avatar
Dist    
XhmikosR committed
2003
2004
        if (actives.length === 0) {
          actives = null;
Jacob Thornton's avatar
Jacob Thornton committed
2005
        }
XhmikosR's avatar
Dist    
XhmikosR committed
2006
      }
Jacob Thornton's avatar
Jacob Thornton committed
2007

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

XhmikosR's avatar
Dist    
XhmikosR committed
2010
      if (actives) {
XhmikosR's avatar
XhmikosR committed
2011
2012
2013
2014
        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
2015

XhmikosR's avatar
Dist    
XhmikosR committed
2016
        if (activesData && activesData._isTransitioning) {
Mark Otto's avatar
dist    
Mark Otto committed
2017
2018
          return;
        }
XhmikosR's avatar
Dist    
XhmikosR committed
2019
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2020

XhmikosR's avatar
XhmikosR committed
2021
      var startEvent = EventHandler.trigger(this._element, Event$4.SHOW);
Mark Otto's avatar
dist    
Mark Otto committed
2022

XhmikosR's avatar
XhmikosR committed
2023
      if (startEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2024
2025
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2026

XhmikosR's avatar
Dist    
XhmikosR committed
2027
      if (actives) {
XhmikosR's avatar
XhmikosR committed
2028
2029
        actives.forEach(function (elemActive) {
          if (container !== elemActive) {
XhmikosR's avatar
XhmikosR committed
2030
            Collapse.collapseInterface(elemActive, 'hide');
XhmikosR's avatar
XhmikosR committed
2031
          }
Jacob Thornton's avatar
Jacob Thornton committed
2032

XhmikosR's avatar
XhmikosR committed
2033
2034
2035
2036
          if (!activesData) {
            Data.setData(elemActive, DATA_KEY$3, null);
          }
        });
XhmikosR's avatar
Dist    
XhmikosR committed
2037
      }
Jacob Thornton's avatar
Jacob Thornton committed
2038

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

XhmikosR's avatar
XhmikosR committed
2041
2042
2043
2044
      this._element.classList.remove(ClassName$3.COLLAPSE);

      this._element.classList.add(ClassName$3.COLLAPSING);

XhmikosR's avatar
Dist    
XhmikosR committed
2045
2046
2047
      this._element.style[dimension] = 0;

      if (this._triggerArray.length) {
XhmikosR's avatar
XhmikosR committed
2048
2049
2050
2051
        this._triggerArray.forEach(function (element) {
          element.classList.remove(ClassName$3.COLLAPSED);
          element.setAttribute('aria-expanded', true);
        });
XhmikosR's avatar
Dist    
XhmikosR committed
2052
      }
Jacob Thornton's avatar
Jacob Thornton committed
2053

XhmikosR's avatar
Dist    
XhmikosR committed
2054
      this.setTransitioning(true);
Jacob Thornton's avatar
Jacob Thornton committed
2055

XhmikosR's avatar
Dist    
XhmikosR committed
2056
      var complete = function complete() {
XhmikosR's avatar
XhmikosR committed
2057
2058
2059
2060
2061
2062
        _this._element.classList.remove(ClassName$3.COLLAPSING);

        _this._element.classList.add(ClassName$3.COLLAPSE);

        _this._element.classList.add(ClassName$3.SHOW);

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

XhmikosR's avatar
Dist    
XhmikosR committed
2065
2066
        _this.setTransitioning(false);

XhmikosR's avatar
XhmikosR committed
2067
        EventHandler.trigger(_this._element, Event$4.SHOWN);
Mark Otto's avatar
dist    
Mark Otto committed
2068
      };
Jacob Thornton's avatar
Jacob Thornton committed
2069

XhmikosR's avatar
Dist    
XhmikosR committed
2070
2071
      var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
      var scrollSize = "scroll" + capitalizedDimension;
XhmikosR's avatar
XhmikosR committed
2072
2073
2074
      var transitionDuration = getTransitionDurationFromElement(this._element);
      EventHandler.one(this._element, TRANSITION_END, complete);
      emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
2075
2076
      this._element.style[dimension] = this._element[scrollSize] + "px";
    };
Jacob Thornton's avatar
Jacob Thornton committed
2077

XhmikosR's avatar
Dist    
XhmikosR committed
2078
2079
    _proto.hide = function hide() {
      var _this2 = this;
Jacob Thornton's avatar
Jacob Thornton committed
2080

XhmikosR's avatar
XhmikosR committed
2081
      if (this._isTransitioning || !this._element.classList.contains(ClassName$3.SHOW)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2082
2083
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2084

XhmikosR's avatar
XhmikosR committed
2085
      var startEvent = EventHandler.trigger(this._element, Event$4.HIDE);
Jacob Thornton's avatar
Jacob Thornton committed
2086

XhmikosR's avatar
XhmikosR committed
2087
      if (startEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2088
2089
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2090

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

XhmikosR's avatar
Dist    
XhmikosR committed
2093
      this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
XhmikosR's avatar
XhmikosR committed
2094
2095
2096
2097
2098
2099
2100
2101
      reflow(this._element);

      this._element.classList.add(ClassName$3.COLLAPSING);

      this._element.classList.remove(ClassName$3.COLLAPSE);

      this._element.classList.remove(ClassName$3.SHOW);

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

XhmikosR's avatar
Dist    
XhmikosR committed
2104
2105
2106
      if (triggerArrayLength > 0) {
        for (var i = 0; i < triggerArrayLength; i++) {
          var trigger = this._triggerArray[i];
XhmikosR's avatar
XhmikosR committed
2107
          var elem = getElementFromSelector(trigger);
XhmikosR's avatar
Dist    
XhmikosR committed
2108

XhmikosR's avatar
XhmikosR committed
2109
2110
2111
          if (elem && !elem.classList.contains(ClassName$3.SHOW)) {
            trigger.classList.add(ClassName$3.COLLAPSED);
            trigger.setAttribute('aria-expanded', false);
Mark Otto's avatar
build    
Mark Otto committed
2112
2113
          }
        }
XhmikosR's avatar
Dist    
XhmikosR committed
2114
      }
Mark Otto's avatar
dist    
Mark Otto committed
2115

XhmikosR's avatar
Dist    
XhmikosR committed
2116
      this.setTransitioning(true);
Jacob Thornton's avatar
Jacob Thornton committed
2117

XhmikosR's avatar
Dist    
XhmikosR committed
2118
2119
      var complete = function complete() {
        _this2.setTransitioning(false);
Jacob Thornton's avatar
Jacob Thornton committed
2120

XhmikosR's avatar
XhmikosR committed
2121
2122
2123
2124
2125
        _this2._element.classList.remove(ClassName$3.COLLAPSING);

        _this2._element.classList.add(ClassName$3.COLLAPSE);

        EventHandler.trigger(_this2._element, Event$4.HIDDEN);
Mark Otto's avatar
dist    
Mark Otto committed
2126
      };
Jacob Thornton's avatar
Jacob Thornton committed
2127

XhmikosR's avatar
Dist    
XhmikosR committed
2128
      this._element.style[dimension] = '';
XhmikosR's avatar
XhmikosR committed
2129
2130
2131
      var transitionDuration = getTransitionDurationFromElement(this._element);
      EventHandler.one(this._element, TRANSITION_END, complete);
      emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
2132
    };
Jacob Thornton's avatar
Jacob Thornton committed
2133

XhmikosR's avatar
Dist    
XhmikosR committed
2134
2135
2136
    _proto.setTransitioning = function setTransitioning(isTransitioning) {
      this._isTransitioning = isTransitioning;
    };
Jacob Thornton's avatar
Jacob Thornton committed
2137

XhmikosR's avatar
Dist    
XhmikosR committed
2138
    _proto.dispose = function dispose() {
XhmikosR's avatar
XhmikosR committed
2139
      Data.removeData(this._element, DATA_KEY$3);
XhmikosR's avatar
Dist    
XhmikosR committed
2140
2141
2142
2143
2144
      this._config = null;
      this._parent = null;
      this._element = null;
      this._triggerArray = null;
      this._isTransitioning = null;
Mark Otto's avatar
Mark Otto committed
2145
2146
    } // Private
    ;
Mark Otto's avatar
dist    
Mark Otto committed
2147

XhmikosR's avatar
Dist    
XhmikosR committed
2148
    _proto._getConfig = function _getConfig(config) {
2149
      config = _objectSpread2({}, Default$1, {}, config);
XhmikosR's avatar
Dist    
XhmikosR committed
2150
      config.toggle = Boolean(config.toggle); // Coerce string values
Mark Otto's avatar
grunt    
Mark Otto committed
2151

XhmikosR's avatar
XhmikosR committed
2152
      typeCheckConfig(NAME$3, config, DefaultType$1);
XhmikosR's avatar
Dist    
XhmikosR committed
2153
2154
      return config;
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2155

XhmikosR's avatar
Dist    
XhmikosR committed
2156
    _proto._getDimension = function _getDimension() {
XhmikosR's avatar
XhmikosR committed
2157
2158
      var hasWidth = this._element.classList.contains(Dimension.WIDTH);

XhmikosR's avatar
Dist    
XhmikosR committed
2159
2160
      return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2161

XhmikosR's avatar
Dist    
XhmikosR committed
2162
2163
    _proto._getParent = function _getParent() {
      var _this3 = this;
Mark Otto's avatar
grunt    
Mark Otto committed
2164

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

XhmikosR's avatar
Dist.    
XhmikosR committed
2167
2168
2169
2170
      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
2171
2172
        }
      } else {
XhmikosR's avatar
Dist.    
XhmikosR committed
2173
        parent = SelectorEngine.findOne(parent);
XhmikosR's avatar
Dist    
XhmikosR committed
2174
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2175

XhmikosR's avatar
Dist.    
XhmikosR committed
2176
      var selector = "[data-toggle=\"collapse\"][data-parent=\"" + parent + "\"]";
XhmikosR's avatar
XhmikosR committed
2177
      makeArray(SelectorEngine.find(selector, parent)).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
2178
        var selected = getElementFromSelector(element);
2179
2180

        _this3._addAriaAndCollapsedClass(selected, [element]);
XhmikosR's avatar
Dist    
XhmikosR committed
2181
2182
2183
      });
      return parent;
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2184

XhmikosR's avatar
Dist    
XhmikosR committed
2185
    _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
XhmikosR's avatar
XhmikosR committed
2186
2187
2188
2189
2190
      if (element) {
        var isOpen = element.classList.contains(ClassName$3.SHOW);

        if (triggerArray.length) {
          triggerArray.forEach(function (elem) {
XhmikosR's avatar
Dist.    
XhmikosR committed
2191
            if (isOpen) {
XhmikosR's avatar
XhmikosR committed
2192
              elem.classList.remove(ClassName$3.COLLAPSED);
XhmikosR's avatar
Dist.    
XhmikosR committed
2193
2194
            } else {
              elem.classList.add(ClassName$3.COLLAPSED);
XhmikosR's avatar
XhmikosR committed
2195
            }
Jacob Thornton's avatar
Jacob Thornton committed
2196

XhmikosR's avatar
XhmikosR committed
2197
2198
2199
            elem.setAttribute('aria-expanded', isOpen);
          });
        }
XhmikosR's avatar
Dist    
XhmikosR committed
2200
      }
Mark Otto's avatar
Mark Otto committed
2201
2202
    } // Static
    ;
Jacob Thornton's avatar
Jacob Thornton committed
2203

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

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

XhmikosR's avatar
XhmikosR committed
2209
2210
2211
      if (!data && _config.toggle && /show|hide/.test(config)) {
        _config.toggle = false;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2212

XhmikosR's avatar
XhmikosR committed
2213
2214
2215
2216
2217
2218
      if (!data) {
        data = new Collapse(element, _config);
      }

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

XhmikosR's avatar
XhmikosR committed
2222
2223
2224
        data[config]();
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
2225

XhmikosR's avatar
XhmikosR committed
2226
    Collapse.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
XhmikosR committed
2227
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
2228
        Collapse.collapseInterface(this, config);
XhmikosR's avatar
Dist    
XhmikosR committed
2229
2230
      });
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2231

XhmikosR's avatar
XhmikosR committed
2232
    Collapse.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
2233
2234
2235
      return Data.getData(element, DATA_KEY$3);
    };

XhmikosR's avatar
Dist    
XhmikosR committed
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
    _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
2247

XhmikosR's avatar
Dist    
XhmikosR committed
2248
2249
2250
2251
2252
2253
2254
    return Collapse;
  }();
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
Mark Otto's avatar
dist    
Mark Otto committed
2255

Jacob Thornton's avatar
Jacob Thornton committed
2256

XhmikosR's avatar
XhmikosR committed
2257
  EventHandler.on(document, Event$4.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2258
    // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
XhmikosR's avatar
XhmikosR committed
2259
    if (event.target.tagName === 'A') {
XhmikosR's avatar
Dist    
XhmikosR committed
2260
2261
      event.preventDefault();
    }
Mark Otto's avatar
dist    
Mark Otto committed
2262

XhmikosR's avatar
XhmikosR committed
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
    var triggerData = Manipulator.getDataAttributes(this);
    var selector = getSelectorFromElement(this);
    var selectorElements = makeArray(SelectorEngine.find(selector));
    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
2281

XhmikosR's avatar
XhmikosR committed
2282
      Collapse.collapseInterface(element, config);
XhmikosR's avatar
Dist    
XhmikosR committed
2283
2284
    });
  });
XhmikosR's avatar
XhmikosR committed
2285
  var $$4 = getjQuery();
XhmikosR's avatar
Dist    
XhmikosR committed
2286
2287
2288
2289
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
2290
   * add .collapse to jQuery only if jQuery is present
XhmikosR's avatar
Dist    
XhmikosR committed
2291
   */
Jacob Thornton's avatar
Jacob Thornton committed
2292

2293
2294
  /* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
2295
2296
2297
2298
  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
2299

XhmikosR's avatar
XhmikosR committed
2300
2301
2302
    $$4.fn[NAME$3].noConflict = function () {
      $$4.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
      return Collapse.jQueryInterface;
XhmikosR's avatar
XhmikosR committed
2303
2304
    };
  }
Jacob Thornton's avatar
Jacob Thornton committed
2305

XhmikosR's avatar
Dist    
XhmikosR committed
2306
2307
2308
2309
2310
2311
2312
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME$4 = 'dropdown';
XhmikosR's avatar
XhmikosR committed
2313
  var VERSION$4 = '4.3.1';
XhmikosR's avatar
Dist    
XhmikosR committed
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
  var DATA_KEY$4 = 'bs.dropdown';
  var EVENT_KEY$4 = "." + DATA_KEY$4;
  var DATA_API_KEY$4 = '.data-api';
  var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key

  var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key

  var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key

  var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key

  var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key

  var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)

  var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
XhmikosR's avatar
XhmikosR committed
2330
  var Event$5 = {
XhmikosR's avatar
Dist    
XhmikosR committed
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
    HIDE: "hide" + EVENT_KEY$4,
    HIDDEN: "hidden" + EVENT_KEY$4,
    SHOW: "show" + EVENT_KEY$4,
    SHOWN: "shown" + EVENT_KEY$4,
    CLICK: "click" + EVENT_KEY$4,
    CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
    KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
    KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  };
  var ClassName$4 = {
    DISABLED: 'disabled',
    SHOW: 'show',
    DROPUP: 'dropup',
    DROPRIGHT: 'dropright',
    DROPLEFT: 'dropleft',
    MENURIGHT: 'dropdown-menu-right',
    POSITION_STATIC: 'position-static'
  };
  var Selector$4 = {
    DATA_TOGGLE: '[data-toggle="dropdown"]',
    FORM_CHILD: '.dropdown form',
    MENU: '.dropdown-menu',
    NAVBAR_NAV: '.navbar-nav',
    VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  };
  var AttachmentMap = {
    TOP: 'top-start',
    TOPEND: 'top-end',
    BOTTOM: 'bottom-start',
    BOTTOMEND: 'bottom-end',
    RIGHT: 'right-start',
    RIGHTEND: 'right-end',
    LEFT: 'left-start',
    LEFTEND: 'left-end'
  };
  var Default$2 = {
    offset: 0,
    flip: true,
    boundary: 'scrollParent',
    reference: 'toggle',
XhmikosR's avatar
XhmikosR committed
2371
2372
    display: 'dynamic',
    popperConfig: null
XhmikosR's avatar
Dist    
XhmikosR committed
2373
2374
2375
2376
2377
2378
  };
  var DefaultType$2 = {
    offset: '(number|string|function)',
    flip: 'boolean',
    boundary: '(string|element)',
    reference: '(string|element)',
XhmikosR's avatar
XhmikosR committed
2379
2380
    display: 'string',
    popperConfig: '(null|object)'
Mark Otto's avatar
dist    
Mark Otto committed
2381
2382
    /**
     * ------------------------------------------------------------------------
XhmikosR's avatar
Dist    
XhmikosR committed
2383
     * Class Definition
Mark Otto's avatar
dist    
Mark Otto committed
2384
2385
     * ------------------------------------------------------------------------
     */
Mark Otto's avatar
dist    
Mark Otto committed
2386

XhmikosR's avatar
Dist    
XhmikosR committed
2387
  };
Mark Otto's avatar
dist    
Mark Otto committed
2388

XhmikosR's avatar
Dist    
XhmikosR committed
2389
2390
2391
2392
2393
2394
2395
2396
2397
  var Dropdown =
  /*#__PURE__*/
  function () {
    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
2398

XhmikosR's avatar
Dist    
XhmikosR committed
2399
      this._addEventListeners();
XhmikosR's avatar
XhmikosR committed
2400
2401

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

Jacob Thornton's avatar
Jacob Thornton committed
2404

XhmikosR's avatar
Dist    
XhmikosR committed
2405
    var _proto = Dropdown.prototype;
Jacob Thornton's avatar
Jacob Thornton committed
2406

XhmikosR's avatar
Dist    
XhmikosR committed
2407
2408
    // Public
    _proto.toggle = function toggle() {
XhmikosR's avatar
XhmikosR committed
2409
      if (this._element.disabled || this._element.classList.contains(ClassName$4.DISABLED)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2410
2411
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2412

XhmikosR's avatar
XhmikosR committed
2413
      var isActive = this._menu.classList.contains(ClassName$4.SHOW);
Jacob Thornton's avatar
Jacob Thornton committed
2414

XhmikosR's avatar
XhmikosR committed
2415
      Dropdown.clearMenus();
Jacob Thornton's avatar
Jacob Thornton committed
2416

XhmikosR's avatar
Dist    
XhmikosR committed
2417
2418
2419
      if (isActive) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2420

XhmikosR's avatar
XhmikosR committed
2421
2422
2423
2424
2425
2426
2427
2428
2429
      this.show();
    };

    _proto.show = function show() {
      if (this._element.disabled || this._element.classList.contains(ClassName$4.DISABLED) || this._menu.classList.contains(ClassName$4.SHOW)) {
        return;
      }

      var parent = Dropdown.getParentFromElement(this._element);
XhmikosR's avatar
Dist    
XhmikosR committed
2430
2431
2432
      var relatedTarget = {
        relatedTarget: this._element
      };
XhmikosR's avatar
XhmikosR committed
2433
      var showEvent = EventHandler.trigger(parent, Event$5.SHOW, relatedTarget);
Mark Otto's avatar
dist    
Mark Otto committed
2434

XhmikosR's avatar
XhmikosR committed
2435
      if (showEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2436
2437
        return;
      } // Disable totally Popper.js for Dropdown in Navbar
Jacob Thornton's avatar
Jacob Thornton committed
2438
2439


XhmikosR's avatar
Dist    
XhmikosR committed
2440
2441
      if (!this._inNavbar) {
        if (typeof Popper === 'undefined') {
XhmikosR's avatar
XhmikosR committed
2442
          throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org)');
Mark Otto's avatar
dist    
Mark Otto committed
2443
        }
Jacob Thornton's avatar
Jacob Thornton committed
2444

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

XhmikosR's avatar
Dist    
XhmikosR committed
2447
2448
        if (this._config.reference === 'parent') {
          referenceElement = parent;
XhmikosR's avatar
XhmikosR committed
2449
        } else if (isElement(this._config.reference)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2450
          referenceElement = this._config.reference; // Check if it's jQuery element
Mark Otto's avatar
dist    
Mark Otto committed
2451

XhmikosR's avatar
Dist    
XhmikosR committed
2452
2453
          if (typeof this._config.reference.jquery !== 'undefined') {
            referenceElement = this._config.reference[0];
Mark Otto's avatar
dist    
Mark Otto committed
2454
          }
XhmikosR's avatar
Dist    
XhmikosR committed
2455
2456
2457
        } // 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
2458

Mark Otto's avatar
dist    
Mark Otto committed
2459

XhmikosR's avatar
Dist    
XhmikosR committed
2460
        if (this._config.boundary !== 'scrollParent') {
XhmikosR's avatar
XhmikosR committed
2461
          parent.classList.add(ClassName$4.POSITION_STATIC);
XhmikosR's avatar
Dist    
XhmikosR committed
2462
        }
Mark Otto's avatar
dist    
Mark Otto committed
2463

XhmikosR's avatar
Dist    
XhmikosR committed
2464
2465
2466
2467
2468
        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
2469

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

XhmikosR's avatar
XhmikosR committed
2471
2472
2473
2474
      if ('ontouchstart' in document.documentElement && !makeArray(SelectorEngine.closest(parent, Selector$4.NAVBAR_NAV)).length) {
        makeArray(document.body.children).forEach(function (elem) {
          return EventHandler.on(elem, 'mouseover', null, noop());
        });
XhmikosR's avatar
Dist    
XhmikosR committed
2475
      }
Mark Otto's avatar
dist    
Mark Otto committed
2476

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

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

XhmikosR's avatar
XhmikosR committed
2481
2482
2483
      Manipulator.toggleClass(this._menu, ClassName$4.SHOW);
      Manipulator.toggleClass(parent, ClassName$4.SHOW);
      EventHandler.trigger(parent, Event$5.SHOWN, relatedTarget);
XhmikosR's avatar
Dist    
XhmikosR committed
2484
    };
Mark Otto's avatar
dist    
Mark Otto committed
2485

XhmikosR's avatar
Dist    
XhmikosR committed
2486
    _proto.hide = function hide() {
XhmikosR's avatar
XhmikosR committed
2487
      if (this._element.disabled || this._element.classList.contains(ClassName$4.DISABLED) || !this._menu.classList.contains(ClassName$4.SHOW)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2488
2489
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2490

XhmikosR's avatar
XhmikosR committed
2491
      var parent = Dropdown.getParentFromElement(this._element);
XhmikosR's avatar
Dist    
XhmikosR committed
2492
2493
2494
      var relatedTarget = {
        relatedTarget: this._element
      };
XhmikosR's avatar
XhmikosR committed
2495
      var hideEvent = EventHandler.trigger(parent, Event$5.HIDE, relatedTarget);
Mark Otto's avatar
dist    
Mark Otto committed
2496

XhmikosR's avatar
XhmikosR committed
2497
      if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2498
2499
        return;
      }
Johann-S's avatar
build    
Johann-S committed
2500

XhmikosR's avatar
XhmikosR committed
2501
2502
2503
2504
      if (this._popper) {
        this._popper.destroy();
      }

XhmikosR's avatar
XhmikosR committed
2505
2506
2507
      Manipulator.toggleClass(this._menu, ClassName$4.SHOW);
      Manipulator.toggleClass(parent, ClassName$4.SHOW);
      EventHandler.trigger(parent, Event$5.HIDDEN, relatedTarget);
XhmikosR's avatar
Dist    
XhmikosR committed
2508
    };
Johann-S's avatar
build    
Johann-S committed
2509

XhmikosR's avatar
Dist    
XhmikosR committed
2510
    _proto.dispose = function dispose() {
XhmikosR's avatar
XhmikosR committed
2511
2512
      Data.removeData(this._element, DATA_KEY$4);
      EventHandler.off(this._element, EVENT_KEY$4);
XhmikosR's avatar
Dist    
XhmikosR committed
2513
2514
      this._element = null;
      this._menu = null;
Mark Otto's avatar
dist    
Mark Otto committed
2515

XhmikosR's avatar
XhmikosR committed
2516
      if (this._popper) {
XhmikosR's avatar
Dist    
XhmikosR committed
2517
        this._popper.destroy();
Mark Otto's avatar
dist    
Mark Otto committed
2518

XhmikosR's avatar
Dist    
XhmikosR committed
2519
2520
2521
        this._popper = null;
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
2522

XhmikosR's avatar
Dist    
XhmikosR committed
2523
2524
    _proto.update = function update() {
      this._inNavbar = this._detectNavbar();
Mark Otto's avatar
build    
Mark Otto committed
2525

XhmikosR's avatar
XhmikosR committed
2526
      if (this._popper) {
XhmikosR's avatar
Dist    
XhmikosR committed
2527
2528
        this._popper.scheduleUpdate();
      }
Mark Otto's avatar
Mark Otto committed
2529
2530
    } // Private
    ;
Mark Otto's avatar
dist    
Mark Otto committed
2531

XhmikosR's avatar
Dist    
XhmikosR committed
2532
2533
    _proto._addEventListeners = function _addEventListeners() {
      var _this = this;
Mark Otto's avatar
build    
Mark Otto committed
2534

XhmikosR's avatar
XhmikosR committed
2535
      EventHandler.on(this._element, Event$5.CLICK, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2536
2537
        event.preventDefault();
        event.stopPropagation();
Mark Otto's avatar
build    
Mark Otto committed
2538

XhmikosR's avatar
Dist    
XhmikosR committed
2539
2540
2541
        _this.toggle();
      });
    };
Mark Otto's avatar
dist    
Mark Otto committed
2542

XhmikosR's avatar
Dist    
XhmikosR committed
2543
    _proto._getConfig = function _getConfig(config) {
2544
      config = _objectSpread2({}, this.constructor.Default, {}, Manipulator.getDataAttributes(this._element), {}, config);
XhmikosR's avatar
XhmikosR committed
2545
      typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
XhmikosR's avatar
Dist    
XhmikosR committed
2546
2547
      return config;
    };
Mark Otto's avatar
dist    
Mark Otto committed
2548

XhmikosR's avatar
Dist    
XhmikosR committed
2549
    _proto._getMenuElement = function _getMenuElement() {
XhmikosR's avatar
XhmikosR committed
2550
      var parent = Dropdown.getParentFromElement(this._element);
2551
      return SelectorEngine.findOne(Selector$4.MENU, parent);
XhmikosR's avatar
Dist    
XhmikosR committed
2552
    };
Mark Otto's avatar
dist    
Mark Otto committed
2553

XhmikosR's avatar
Dist    
XhmikosR committed
2554
    _proto._getPlacement = function _getPlacement() {
XhmikosR's avatar
XhmikosR committed
2555
      var parentDropdown = this._element.parentNode;
XhmikosR's avatar
Dist    
XhmikosR committed
2556
      var placement = AttachmentMap.BOTTOM; // Handle dropup
Mark Otto's avatar
dist    
Mark Otto committed
2557

XhmikosR's avatar
XhmikosR committed
2558
      if (parentDropdown.classList.contains(ClassName$4.DROPUP)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2559
        placement = AttachmentMap.TOP;
Mark Otto's avatar
build    
Mark Otto committed
2560

XhmikosR's avatar
XhmikosR committed
2561
        if (this._menu.classList.contains(ClassName$4.MENURIGHT)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2562
2563
          placement = AttachmentMap.TOPEND;
        }
XhmikosR's avatar
XhmikosR committed
2564
      } else if (parentDropdown.classList.contains(ClassName$4.DROPRIGHT)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2565
        placement = AttachmentMap.RIGHT;
XhmikosR's avatar
XhmikosR committed
2566
      } else if (parentDropdown.classList.contains(ClassName$4.DROPLEFT)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2567
        placement = AttachmentMap.LEFT;
XhmikosR's avatar
XhmikosR committed
2568
      } else if (this._menu.classList.contains(ClassName$4.MENURIGHT)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2569
2570
        placement = AttachmentMap.BOTTOMEND;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2571

XhmikosR's avatar
Dist    
XhmikosR committed
2572
2573
      return placement;
    };
Mark Otto's avatar
dist    
Mark Otto committed
2574

XhmikosR's avatar
Dist    
XhmikosR committed
2575
    _proto._detectNavbar = function _detectNavbar() {
XhmikosR's avatar
XhmikosR committed
2576
      return Boolean(SelectorEngine.closest(this._element, '.navbar'));
XhmikosR's avatar
Dist    
XhmikosR committed
2577
    };
Jacob Thornton's avatar
Jacob Thornton committed
2578

Mark Otto's avatar
Mark Otto committed
2579
    _proto._getOffset = function _getOffset() {
XhmikosR's avatar
Dist    
XhmikosR committed
2580
      var _this2 = this;
Mark Otto's avatar
dist    
Mark Otto committed
2581

Mark Otto's avatar
Mark Otto committed
2582
      var offset = {};
Jacob Thornton's avatar
Jacob Thornton committed
2583

XhmikosR's avatar
Dist    
XhmikosR committed
2584
      if (typeof this._config.offset === 'function') {
Mark Otto's avatar
Mark Otto committed
2585
        offset.fn = function (data) {
2586
          data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
XhmikosR's avatar
Dist    
XhmikosR committed
2587
2588
2589
          return data;
        };
      } else {
Mark Otto's avatar
Mark Otto committed
2590
        offset.offset = this._config.offset;
XhmikosR's avatar
Dist    
XhmikosR committed
2591
      }
Mark Otto's avatar
dist    
Mark Otto committed
2592

Mark Otto's avatar
Mark Otto committed
2593
2594
2595
2596
      return offset;
    };

    _proto._getPopperConfig = function _getPopperConfig() {
XhmikosR's avatar
Dist    
XhmikosR committed
2597
2598
2599
      var popperConfig = {
        placement: this._getPlacement(),
        modifiers: {
Mark Otto's avatar
Mark Otto committed
2600
          offset: this._getOffset(),
XhmikosR's avatar
Dist    
XhmikosR committed
2601
2602
2603
2604
2605
          flip: {
            enabled: this._config.flip
          },
          preventOverflow: {
            boundariesElement: this._config.boundary
Mark Otto's avatar
grunt    
Mark Otto committed
2606
          }
XhmikosR's avatar
Dist    
XhmikosR committed
2607
        } // Disable Popper.js if we have a static display
Mark Otto's avatar
dist    
Mark Otto committed
2608

XhmikosR's avatar
Dist    
XhmikosR committed
2609
      };
Jacob Thornton's avatar
Jacob Thornton committed
2610

XhmikosR's avatar
Dist    
XhmikosR committed
2611
2612
2613
2614
2615
      if (this._config.display === 'static') {
        popperConfig.modifiers.applyStyle = {
          enabled: false
        };
      }
Jacob Thornton's avatar
Jacob Thornton committed
2616

XhmikosR's avatar
XhmikosR committed
2617
      return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
Mark Otto's avatar
Mark Otto committed
2618
2619
    } // Static
    ;
Mark Otto's avatar
dist    
Mark Otto committed
2620

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

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

XhmikosR's avatar
XhmikosR committed
2626
2627
2628
2629
2630
2631
      if (!data) {
        data = new Dropdown(element, _config);
      }

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

XhmikosR's avatar
XhmikosR committed
2635
2636
2637
        data[config]();
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
2638

XhmikosR's avatar
XhmikosR committed
2639
    Dropdown.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
XhmikosR committed
2640
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
2641
        Dropdown.dropdownInterface(this, config);
XhmikosR's avatar
Dist    
XhmikosR committed
2642
2643
      });
    };
Jacob Thornton's avatar
Jacob Thornton committed
2644

XhmikosR's avatar
XhmikosR committed
2645
    Dropdown.clearMenus = function clearMenus(event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2646
2647
2648
      if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2649

XhmikosR's avatar
XhmikosR committed
2650
      var toggles = makeArray(SelectorEngine.find(Selector$4.DATA_TOGGLE));
Mark Otto's avatar
dist    
Mark Otto committed
2651

XhmikosR's avatar
Dist    
XhmikosR committed
2652
      for (var i = 0, len = toggles.length; i < len; i++) {
XhmikosR's avatar
XhmikosR committed
2653
        var parent = Dropdown.getParentFromElement(toggles[i]);
XhmikosR's avatar
XhmikosR committed
2654
        var context = Data.getData(toggles[i], DATA_KEY$4);
XhmikosR's avatar
Dist    
XhmikosR committed
2655
2656
2657
        var relatedTarget = {
          relatedTarget: toggles[i]
        };
Mark Otto's avatar
dist    
Mark Otto committed
2658

XhmikosR's avatar
Dist    
XhmikosR committed
2659
2660
        if (event && event.type === 'click') {
          relatedTarget.clickEvent = event;
Mark Otto's avatar
grunt    
Mark Otto committed
2661
2662
        }

XhmikosR's avatar
Dist    
XhmikosR committed
2663
2664
        if (!context) {
          continue;
Mark Otto's avatar
dist    
Mark Otto committed
2665
        }
Jacob Thornton's avatar
Jacob Thornton committed
2666

XhmikosR's avatar
Dist    
XhmikosR committed
2667
        var dropdownMenu = context._menu;
Jacob Thornton's avatar
Jacob Thornton committed
2668

XhmikosR's avatar
XhmikosR committed
2669
        if (!parent.classList.contains(ClassName$4.SHOW)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2670
2671
          continue;
        }
Mark Otto's avatar
dist    
Mark Otto committed
2672

XhmikosR's avatar
XhmikosR committed
2673
        if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && parent.contains(event.target)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2674
          continue;
Mark Otto's avatar
dist    
Mark Otto committed
2675
        }
Jacob Thornton's avatar
Jacob Thornton committed
2676

XhmikosR's avatar
XhmikosR committed
2677
        var hideEvent = EventHandler.trigger(parent, Event$5.HIDE, relatedTarget);
Jacob Thornton's avatar
Jacob Thornton committed
2678

XhmikosR's avatar
XhmikosR committed
2679
        if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2680
2681
2682
2683
2684
2685
          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
2686
2687
2688
          makeArray(document.body.children).forEach(function (elem) {
            return EventHandler.off(elem, 'mouseover', null, noop());
          });
Mark Otto's avatar
dist    
Mark Otto committed
2689
        }
Jacob Thornton's avatar
Jacob Thornton committed
2690

XhmikosR's avatar
Dist    
XhmikosR committed
2691
        toggles[i].setAttribute('aria-expanded', 'false');
XhmikosR's avatar
XhmikosR committed
2692
2693
2694
2695
2696

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

XhmikosR's avatar
XhmikosR committed
2697
2698
2699
        dropdownMenu.classList.remove(ClassName$4.SHOW);
        parent.classList.remove(ClassName$4.SHOW);
        EventHandler.trigger(parent, Event$5.HIDDEN, relatedTarget);
XhmikosR's avatar
Dist    
XhmikosR committed
2700
2701
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
2702

XhmikosR's avatar
XhmikosR committed
2703
2704
    Dropdown.getParentFromElement = function getParentFromElement(element) {
      return getElementFromSelector(element) || element.parentNode;
XhmikosR's avatar
XhmikosR committed
2705
    };
Jacob Thornton's avatar
Jacob Thornton committed
2706

XhmikosR's avatar
XhmikosR committed
2707
    Dropdown.dataApiKeydownHandler = function dataApiKeydownHandler(event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2708
2709
2710
2711
2712
2713
2714
      // 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
2715
      if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || SelectorEngine.closest(event.target, Selector$4.MENU)) : !REGEXP_KEYDOWN.test(event.which)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2716
2717
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2718

XhmikosR's avatar
Dist    
XhmikosR committed
2719
2720
      event.preventDefault();
      event.stopPropagation();
Jacob Thornton's avatar
Jacob Thornton committed
2721

XhmikosR's avatar
XhmikosR committed
2722
      if (this.disabled || this.classList.contains(ClassName$4.DISABLED)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2723
2724
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2725

XhmikosR's avatar
XhmikosR committed
2726
      var parent = Dropdown.getParentFromElement(this);
XhmikosR's avatar
XhmikosR committed
2727
      var isActive = parent.classList.contains(ClassName$4.SHOW);
Jacob Thornton's avatar
Jacob Thornton committed
2728

Mark Otto's avatar
dist    
Mark Otto committed
2729
      if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2730
        if (event.which === ESCAPE_KEYCODE) {
Mark Otto's avatar
dist v5    
Mark Otto committed
2731
          SelectorEngine.findOne(Selector$4.DATA_TOGGLE, parent).focus();
Mark Otto's avatar
dist    
Mark Otto committed
2732
        }
Mark Otto's avatar
grunt    
Mark Otto committed
2733

XhmikosR's avatar
XhmikosR committed
2734
        Dropdown.clearMenus();
XhmikosR's avatar
Dist    
XhmikosR committed
2735
2736
        return;
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2737

XhmikosR's avatar
XhmikosR committed
2738
      var items = makeArray(SelectorEngine.find(Selector$4.VISIBLE_ITEMS, parent));
Jacob Thornton's avatar
Jacob Thornton committed
2739

XhmikosR's avatar
XhmikosR committed
2740
      if (!items.length) {
XhmikosR's avatar
Dist    
XhmikosR committed
2741
2742
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2743

XhmikosR's avatar
Dist    
XhmikosR committed
2744
      var index = items.indexOf(event.target);
Mark Otto's avatar
dist    
Mark Otto committed
2745

XhmikosR's avatar
Dist    
XhmikosR committed
2746
2747
2748
2749
      if (event.which === ARROW_UP_KEYCODE && index > 0) {
        // Up
        index--;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2750

XhmikosR's avatar
Dist    
XhmikosR committed
2751
2752
2753
2754
      if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
        // Down
        index++;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2755

XhmikosR's avatar
Dist    
XhmikosR committed
2756
2757
2758
      if (index < 0) {
        index = 0;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2759

XhmikosR's avatar
Dist    
XhmikosR committed
2760
      items[index].focus();
Mark Otto's avatar
dist    
Mark Otto committed
2761
    };
Jacob Thornton's avatar
Jacob Thornton committed
2762

XhmikosR's avatar
XhmikosR committed
2763
    Dropdown.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
2764
2765
2766
      return Data.getData(element, DATA_KEY$4);
    };

XhmikosR's avatar
Dist    
XhmikosR committed
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
    _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
2784
    return Dropdown;
XhmikosR's avatar
Dist    
XhmikosR committed
2785
2786
2787
2788
2789
2790
2791
2792
  }();
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */


XhmikosR's avatar
XhmikosR committed
2793
2794
2795
2796
  EventHandler.on(document, Event$5.KEYDOWN_DATA_API, Selector$4.DATA_TOGGLE, Dropdown.dataApiKeydownHandler);
  EventHandler.on(document, Event$5.KEYDOWN_DATA_API, Selector$4.MENU, Dropdown.dataApiKeydownHandler);
  EventHandler.on(document, Event$5.CLICK_DATA_API, Dropdown.clearMenus);
  EventHandler.on(document, Event$5.KEYUP_DATA_API, Dropdown.clearMenus);
XhmikosR's avatar
XhmikosR committed
2797
  EventHandler.on(document, Event$5.CLICK_DATA_API, Selector$4.DATA_TOGGLE, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2798
2799
    event.preventDefault();
    event.stopPropagation();
XhmikosR's avatar
XhmikosR committed
2800
    Dropdown.dropdownInterface(this, 'toggle');
XhmikosR's avatar
XhmikosR committed
2801
2802
2803
  });
  EventHandler.on(document, Event$5.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
    return e.stopPropagation();
XhmikosR's avatar
Dist    
XhmikosR committed
2804
  });
XhmikosR's avatar
XhmikosR committed
2805
  var $$5 = getjQuery();
XhmikosR's avatar
Dist    
XhmikosR committed
2806
2807
2808
2809
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
2810
   * add .dropdown to jQuery only if jQuery is present
XhmikosR's avatar
Dist    
XhmikosR committed
2811
2812
   */

2813
2814
  /* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
2815
2816
2817
2818
  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
2819

XhmikosR's avatar
XhmikosR committed
2820
2821
2822
    $$5.fn[NAME$4].noConflict = function () {
      $$5.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
      return Dropdown.jQueryInterface;
XhmikosR's avatar
XhmikosR committed
2823
2824
    };
  }
Jacob Thornton's avatar
Jacob Thornton committed
2825

XhmikosR's avatar
Dist    
XhmikosR committed
2826
2827
2828
2829
2830
2831
2832
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME$5 = 'modal';
XhmikosR's avatar
XhmikosR committed
2833
  var VERSION$5 = '4.3.1';
XhmikosR's avatar
Dist    
XhmikosR committed
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
  var DATA_KEY$5 = 'bs.modal';
  var EVENT_KEY$5 = "." + DATA_KEY$5;
  var DATA_API_KEY$5 = '.data-api';
  var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key

  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
2851
  var Event$6 = {
XhmikosR's avatar
Dist    
XhmikosR committed
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
    HIDE: "hide" + EVENT_KEY$5,
    HIDDEN: "hidden" + EVENT_KEY$5,
    SHOW: "show" + EVENT_KEY$5,
    SHOWN: "shown" + EVENT_KEY$5,
    FOCUSIN: "focusin" + EVENT_KEY$5,
    RESIZE: "resize" + EVENT_KEY$5,
    CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
    KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
    MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
    MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
    CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  };
  var ClassName$5 = {
Mark Otto's avatar
Mark Otto committed
2865
    SCROLLABLE: 'modal-dialog-scrollable',
XhmikosR's avatar
Dist    
XhmikosR committed
2866
2867
2868
2869
2870
2871
2872
2873
    SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
    BACKDROP: 'modal-backdrop',
    OPEN: 'modal-open',
    FADE: 'fade',
    SHOW: 'show'
  };
  var Selector$5 = {
    DIALOG: '.modal-dialog',
Mark Otto's avatar
Mark Otto committed
2874
    MODAL_BODY: '.modal-body',
XhmikosR's avatar
Dist    
XhmikosR committed
2875
2876
2877
2878
    DATA_TOGGLE: '[data-toggle="modal"]',
    DATA_DISMISS: '[data-dismiss="modal"]',
    FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
    STICKY_CONTENT: '.sticky-top'
Mark Otto's avatar
dist    
Mark Otto committed
2879
2880
    /**
     * ------------------------------------------------------------------------
XhmikosR's avatar
Dist    
XhmikosR committed
2881
     * Class Definition
Mark Otto's avatar
dist    
Mark Otto committed
2882
2883
     * ------------------------------------------------------------------------
     */
Jacob Thornton's avatar
Jacob Thornton committed
2884

XhmikosR's avatar
Dist    
XhmikosR committed
2885
2886
2887
2888
2889
2890
2891
2892
  };

  var Modal =
  /*#__PURE__*/
  function () {
    function Modal(element, config) {
      this._config = this._getConfig(config);
      this._element = element;
XhmikosR's avatar
XhmikosR committed
2893
      this._dialog = SelectorEngine.findOne(Selector$5.DIALOG, element);
XhmikosR's avatar
Dist    
XhmikosR committed
2894
2895
2896
2897
2898
2899
      this._backdrop = null;
      this._isShown = false;
      this._isBodyOverflowing = false;
      this._ignoreBackdropClick = false;
      this._isTransitioning = false;
      this._scrollbarWidth = 0;
XhmikosR's avatar
XhmikosR committed
2900
      Data.setData(element, DATA_KEY$5, this);
XhmikosR's avatar
Dist    
XhmikosR committed
2901
2902
2903
2904
2905
2906
2907
2908
    } // 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
2909
    };
Jacob Thornton's avatar
Jacob Thornton committed
2910

XhmikosR's avatar
Dist    
XhmikosR committed
2911
2912
    _proto.show = function show(relatedTarget) {
      var _this = this;
Mark Otto's avatar
grunt    
Mark Otto committed
2913

XhmikosR's avatar
Dist    
XhmikosR committed
2914
2915
2916
      if (this._isShown || this._isTransitioning) {
        return;
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2917

XhmikosR's avatar
XhmikosR committed
2918
      if (this._element.classList.contains(ClassName$5.FADE)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2919
2920
        this._isTransitioning = true;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2921

XhmikosR's avatar
XhmikosR committed
2922
      var showEvent = EventHandler.trigger(this._element, Event$6.SHOW, {
XhmikosR's avatar
Dist    
XhmikosR committed
2923
2924
        relatedTarget: relatedTarget
      });
Jacob Thornton's avatar
Jacob Thornton committed
2925

XhmikosR's avatar
XhmikosR committed
2926
      if (this._isShown || showEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2927
2928
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2929

XhmikosR's avatar
Dist    
XhmikosR committed
2930
      this._isShown = true;
Mark Otto's avatar
dist    
Mark Otto committed
2931

XhmikosR's avatar
Dist    
XhmikosR committed
2932
      this._checkScrollbar();
Jacob Thornton's avatar
Jacob Thornton committed
2933

XhmikosR's avatar
Dist    
XhmikosR committed
2934
      this._setScrollbar();
Mark Otto's avatar
dist    
Mark Otto committed
2935

XhmikosR's avatar
Dist    
XhmikosR committed
2936
      this._adjustDialog();
Jacob Thornton's avatar
Jacob Thornton committed
2937

XhmikosR's avatar
Dist    
XhmikosR committed
2938
      this._setEscapeEvent();
Jacob Thornton's avatar
Jacob Thornton committed
2939

XhmikosR's avatar
Dist    
XhmikosR committed
2940
      this._setResizeEvent();
Mark Otto's avatar
grunt    
Mark Otto committed
2941

XhmikosR's avatar
XhmikosR committed
2942
      EventHandler.on(this._element, Event$6.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2943
2944
        return _this.hide(event);
      });
XhmikosR's avatar
XhmikosR committed
2945
2946
2947
      EventHandler.on(this._dialog, Event$6.MOUSEDOWN_DISMISS, function () {
        EventHandler.one(_this._element, Event$6.MOUSEUP_DISMISS, function (event) {
          if (event.target === _this._element) {
XhmikosR's avatar
Dist    
XhmikosR committed
2948
2949
            _this._ignoreBackdropClick = true;
          }
Mark Otto's avatar
dist    
Mark Otto committed
2950
        });
XhmikosR's avatar
Dist    
XhmikosR committed
2951
      });
Jacob Thornton's avatar
Jacob Thornton committed
2952

XhmikosR's avatar
Dist    
XhmikosR committed
2953
2954
2955
2956
      this._showBackdrop(function () {
        return _this._showElement(relatedTarget);
      });
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2957

XhmikosR's avatar
Dist    
XhmikosR committed
2958
2959
    _proto.hide = function hide(event) {
      var _this2 = this;
Jacob Thornton's avatar
Jacob Thornton committed
2960

XhmikosR's avatar
Dist    
XhmikosR committed
2961
2962
2963
      if (event) {
        event.preventDefault();
      }
Jacob Thornton's avatar
Jacob Thornton committed
2964

XhmikosR's avatar
Dist    
XhmikosR committed
2965
2966
2967
      if (!this._isShown || this._isTransitioning) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2968

XhmikosR's avatar
XhmikosR committed
2969
      var hideEvent = EventHandler.trigger(this._element, Event$6.HIDE);
Jacob Thornton's avatar
Jacob Thornton committed
2970

2971
      if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2972
2973
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2974

XhmikosR's avatar
Dist    
XhmikosR committed
2975
      this._isShown = false;
XhmikosR's avatar
XhmikosR committed
2976
2977

      var transition = this._element.classList.contains(ClassName$5.FADE);
Jacob Thornton's avatar
Jacob Thornton committed
2978

XhmikosR's avatar
Dist    
XhmikosR committed
2979
2980
2981
      if (transition) {
        this._isTransitioning = true;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2982

XhmikosR's avatar
Dist    
XhmikosR committed
2983
      this._setEscapeEvent();
Jacob Thornton's avatar
Jacob Thornton committed
2984

XhmikosR's avatar
Dist    
XhmikosR committed
2985
      this._setResizeEvent();
Jacob Thornton's avatar
Jacob Thornton committed
2986

XhmikosR's avatar
XhmikosR committed
2987
2988
2989
2990
2991
2992
      EventHandler.off(document, Event$6.FOCUSIN);

      this._element.classList.remove(ClassName$5.SHOW);

      EventHandler.off(this._element, Event$6.CLICK_DISMISS);
      EventHandler.off(this._dialog, Event$6.MOUSEDOWN_DISMISS);
Jacob Thornton's avatar
Jacob Thornton committed
2993

XhmikosR's avatar
Dist    
XhmikosR committed
2994
      if (transition) {
XhmikosR's avatar
XhmikosR committed
2995
2996
        var transitionDuration = getTransitionDurationFromElement(this._element);
        EventHandler.one(this._element, TRANSITION_END, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2997
          return _this2._hideModal(event);
XhmikosR's avatar
XhmikosR committed
2998
2999
        });
        emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
3000
      } else {
For faster browsing, not all history is shown. View entire blame