bootstrap.js 153 KB
Newer Older
Jacob Thornton's avatar
Jacob Thornton committed
2001

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

XhmikosR's avatar
Dist    
XhmikosR committed
2004
      if (actives) {
XhmikosR's avatar
XhmikosR committed
2005
2006
2007
2008
        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
2009

XhmikosR's avatar
Dist    
XhmikosR committed
2010
        if (activesData && activesData._isTransitioning) {
Mark Otto's avatar
dist    
Mark Otto committed
2011
2012
          return;
        }
XhmikosR's avatar
Dist    
XhmikosR committed
2013
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2014

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

XhmikosR's avatar
XhmikosR committed
2017
      if (startEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2018
2019
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2020

XhmikosR's avatar
Dist    
XhmikosR committed
2021
      if (actives) {
XhmikosR's avatar
XhmikosR committed
2022
2023
        actives.forEach(function (elemActive) {
          if (container !== elemActive) {
XhmikosR's avatar
XhmikosR committed
2024
            Collapse.collapseInterface(elemActive, 'hide');
XhmikosR's avatar
XhmikosR committed
2025
          }
Jacob Thornton's avatar
Jacob Thornton committed
2026

XhmikosR's avatar
XhmikosR committed
2027
2028
2029
2030
          if (!activesData) {
            Data.setData(elemActive, DATA_KEY$3, null);
          }
        });
XhmikosR's avatar
Dist    
XhmikosR committed
2031
      }
Jacob Thornton's avatar
Jacob Thornton committed
2032

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

XhmikosR's avatar
XhmikosR committed
2035
2036
2037
2038
      this._element.classList.remove(ClassName$3.COLLAPSE);

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

XhmikosR's avatar
Dist    
XhmikosR committed
2039
2040
2041
      this._element.style[dimension] = 0;

      if (this._triggerArray.length) {
XhmikosR's avatar
XhmikosR committed
2042
2043
2044
2045
        this._triggerArray.forEach(function (element) {
          element.classList.remove(ClassName$3.COLLAPSED);
          element.setAttribute('aria-expanded', true);
        });
XhmikosR's avatar
Dist    
XhmikosR committed
2046
      }
Jacob Thornton's avatar
Jacob Thornton committed
2047

XhmikosR's avatar
Dist    
XhmikosR committed
2048
      this.setTransitioning(true);
Jacob Thornton's avatar
Jacob Thornton committed
2049

XhmikosR's avatar
Dist    
XhmikosR committed
2050
      var complete = function complete() {
XhmikosR's avatar
XhmikosR committed
2051
2052
2053
2054
2055
2056
        _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
2057
        _this._element.style[dimension] = '';
Jacob Thornton's avatar
Jacob Thornton committed
2058

XhmikosR's avatar
Dist    
XhmikosR committed
2059
2060
        _this.setTransitioning(false);

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

XhmikosR's avatar
Dist    
XhmikosR committed
2064
2065
      var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
      var scrollSize = "scroll" + capitalizedDimension;
XhmikosR's avatar
XhmikosR committed
2066
2067
2068
      var transitionDuration = getTransitionDurationFromElement(this._element);
      EventHandler.one(this._element, TRANSITION_END, complete);
      emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
2069
2070
      this._element.style[dimension] = this._element[scrollSize] + "px";
    };
Jacob Thornton's avatar
Jacob Thornton committed
2071

XhmikosR's avatar
Dist    
XhmikosR committed
2072
2073
    _proto.hide = function hide() {
      var _this2 = this;
Jacob Thornton's avatar
Jacob Thornton committed
2074

XhmikosR's avatar
XhmikosR committed
2075
      if (this._isTransitioning || !this._element.classList.contains(ClassName$3.SHOW)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2076
2077
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2078

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

XhmikosR's avatar
XhmikosR committed
2081
      if (startEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2082
2083
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2084

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

XhmikosR's avatar
Dist    
XhmikosR committed
2087
      this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
XhmikosR's avatar
XhmikosR committed
2088
2089
2090
2091
2092
2093
2094
2095
      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
2096
      var triggerArrayLength = this._triggerArray.length;
Mark Otto's avatar
dist    
Mark Otto committed
2097

XhmikosR's avatar
Dist    
XhmikosR committed
2098
2099
2100
      if (triggerArrayLength > 0) {
        for (var i = 0; i < triggerArrayLength; i++) {
          var trigger = this._triggerArray[i];
XhmikosR's avatar
XhmikosR committed
2101
          var elem = getElementFromSelector(trigger);
XhmikosR's avatar
Dist    
XhmikosR committed
2102

XhmikosR's avatar
XhmikosR committed
2103
2104
2105
          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
2106
2107
          }
        }
XhmikosR's avatar
Dist    
XhmikosR committed
2108
      }
Mark Otto's avatar
dist    
Mark Otto committed
2109

XhmikosR's avatar
Dist    
XhmikosR committed
2110
      this.setTransitioning(true);
Jacob Thornton's avatar
Jacob Thornton committed
2111

XhmikosR's avatar
Dist    
XhmikosR committed
2112
2113
      var complete = function complete() {
        _this2.setTransitioning(false);
Jacob Thornton's avatar
Jacob Thornton committed
2114

XhmikosR's avatar
XhmikosR committed
2115
2116
2117
2118
2119
        _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
2120
      };
Jacob Thornton's avatar
Jacob Thornton committed
2121

XhmikosR's avatar
Dist    
XhmikosR committed
2122
      this._element.style[dimension] = '';
XhmikosR's avatar
XhmikosR committed
2123
2124
2125
      var transitionDuration = getTransitionDurationFromElement(this._element);
      EventHandler.one(this._element, TRANSITION_END, complete);
      emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
2126
    };
Jacob Thornton's avatar
Jacob Thornton committed
2127

XhmikosR's avatar
Dist    
XhmikosR committed
2128
2129
2130
    _proto.setTransitioning = function setTransitioning(isTransitioning) {
      this._isTransitioning = isTransitioning;
    };
Jacob Thornton's avatar
Jacob Thornton committed
2131

XhmikosR's avatar
Dist    
XhmikosR committed
2132
    _proto.dispose = function dispose() {
XhmikosR's avatar
XhmikosR committed
2133
      Data.removeData(this._element, DATA_KEY$3);
XhmikosR's avatar
Dist    
XhmikosR committed
2134
2135
2136
2137
2138
      this._config = null;
      this._parent = null;
      this._element = null;
      this._triggerArray = null;
      this._isTransitioning = null;
Mark Otto's avatar
Mark Otto committed
2139
2140
    } // Private
    ;
Mark Otto's avatar
dist    
Mark Otto committed
2141

XhmikosR's avatar
Dist    
XhmikosR committed
2142
    _proto._getConfig = function _getConfig(config) {
2143
      config = _objectSpread2({}, Default$1, {}, config);
XhmikosR's avatar
Dist    
XhmikosR committed
2144
      config.toggle = Boolean(config.toggle); // Coerce string values
Mark Otto's avatar
grunt    
Mark Otto committed
2145

XhmikosR's avatar
XhmikosR committed
2146
      typeCheckConfig(NAME$3, config, DefaultType$1);
XhmikosR's avatar
Dist    
XhmikosR committed
2147
2148
      return config;
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2149

XhmikosR's avatar
Dist    
XhmikosR committed
2150
    _proto._getDimension = function _getDimension() {
XhmikosR's avatar
XhmikosR committed
2151
2152
      var hasWidth = this._element.classList.contains(Dimension.WIDTH);

XhmikosR's avatar
Dist    
XhmikosR committed
2153
2154
      return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2155

XhmikosR's avatar
Dist    
XhmikosR committed
2156
2157
    _proto._getParent = function _getParent() {
      var _this3 = this;
Mark Otto's avatar
grunt    
Mark Otto committed
2158

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

XhmikosR's avatar
Dist.    
XhmikosR committed
2161
2162
2163
2164
      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
2165
2166
        }
      } else {
XhmikosR's avatar
Dist.    
XhmikosR committed
2167
        parent = SelectorEngine.findOne(parent);
XhmikosR's avatar
Dist    
XhmikosR committed
2168
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2169

XhmikosR's avatar
Dist.    
XhmikosR committed
2170
      var selector = "[data-toggle=\"collapse\"][data-parent=\"" + parent + "\"]";
XhmikosR's avatar
XhmikosR committed
2171
      makeArray(SelectorEngine.find(selector, parent)).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
2172
        var selected = getElementFromSelector(element);
2173
2174

        _this3._addAriaAndCollapsedClass(selected, [element]);
XhmikosR's avatar
Dist    
XhmikosR committed
2175
2176
2177
      });
      return parent;
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2178

XhmikosR's avatar
Dist    
XhmikosR committed
2179
    _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
XhmikosR's avatar
XhmikosR committed
2180
2181
2182
2183
2184
      if (element) {
        var isOpen = element.classList.contains(ClassName$3.SHOW);

        if (triggerArray.length) {
          triggerArray.forEach(function (elem) {
XhmikosR's avatar
Dist.    
XhmikosR committed
2185
            if (isOpen) {
XhmikosR's avatar
XhmikosR committed
2186
              elem.classList.remove(ClassName$3.COLLAPSED);
XhmikosR's avatar
Dist.    
XhmikosR committed
2187
2188
            } else {
              elem.classList.add(ClassName$3.COLLAPSED);
XhmikosR's avatar
XhmikosR committed
2189
            }
Jacob Thornton's avatar
Jacob Thornton committed
2190

XhmikosR's avatar
XhmikosR committed
2191
2192
2193
            elem.setAttribute('aria-expanded', isOpen);
          });
        }
XhmikosR's avatar
Dist    
XhmikosR committed
2194
      }
Mark Otto's avatar
Mark Otto committed
2195
2196
    } // Static
    ;
Jacob Thornton's avatar
Jacob Thornton committed
2197

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

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

XhmikosR's avatar
XhmikosR committed
2203
2204
2205
      if (!data && _config.toggle && /show|hide/.test(config)) {
        _config.toggle = false;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2206

XhmikosR's avatar
XhmikosR committed
2207
2208
2209
2210
2211
2212
      if (!data) {
        data = new Collapse(element, _config);
      }

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

XhmikosR's avatar
XhmikosR committed
2216
2217
2218
        data[config]();
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
2219

XhmikosR's avatar
XhmikosR committed
2220
    Collapse.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
XhmikosR committed
2221
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
2222
        Collapse.collapseInterface(this, config);
XhmikosR's avatar
Dist    
XhmikosR committed
2223
2224
      });
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2225

XhmikosR's avatar
XhmikosR committed
2226
    Collapse.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
2227
2228
2229
      return Data.getData(element, DATA_KEY$3);
    };

XhmikosR's avatar
Dist    
XhmikosR committed
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
    _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
2241

XhmikosR's avatar
Dist    
XhmikosR committed
2242
2243
2244
2245
2246
2247
2248
    return Collapse;
  }();
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
Mark Otto's avatar
dist    
Mark Otto committed
2249

Jacob Thornton's avatar
Jacob Thornton committed
2250

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

XhmikosR's avatar
XhmikosR committed
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
    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
2275

XhmikosR's avatar
XhmikosR committed
2276
      Collapse.collapseInterface(element, config);
XhmikosR's avatar
Dist    
XhmikosR committed
2277
2278
    });
  });
XhmikosR's avatar
XhmikosR committed
2279
  var $$4 = getjQuery();
XhmikosR's avatar
Dist    
XhmikosR committed
2280
2281
2282
2283
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
2284
   * add .collapse to jQuery only if jQuery is present
XhmikosR's avatar
Dist    
XhmikosR committed
2285
   */
Jacob Thornton's avatar
Jacob Thornton committed
2286

2287
2288
  /* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
2289
2290
2291
2292
  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
2293

XhmikosR's avatar
XhmikosR committed
2294
2295
2296
    $$4.fn[NAME$3].noConflict = function () {
      $$4.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
      return Collapse.jQueryInterface;
XhmikosR's avatar
XhmikosR committed
2297
2298
    };
  }
Jacob Thornton's avatar
Jacob Thornton committed
2299

XhmikosR's avatar
Dist    
XhmikosR committed
2300
2301
2302
2303
2304
2305
2306
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME$4 = 'dropdown';
XhmikosR's avatar
XhmikosR committed
2307
  var VERSION$4 = '4.3.1';
XhmikosR's avatar
Dist    
XhmikosR committed
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
  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
2324
  var Event$5 = {
XhmikosR's avatar
Dist    
XhmikosR committed
2325
2326
2327
2328
2329
2330
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
    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
2365
2366
    display: 'dynamic',
    popperConfig: null
XhmikosR's avatar
Dist    
XhmikosR committed
2367
2368
2369
2370
2371
2372
  };
  var DefaultType$2 = {
    offset: '(number|string|function)',
    flip: 'boolean',
    boundary: '(string|element)',
    reference: '(string|element)',
XhmikosR's avatar
XhmikosR committed
2373
2374
    display: 'string',
    popperConfig: '(null|object)'
XhmikosR's avatar
Dist    
XhmikosR committed
2375
  };
XhmikosR's avatar
XhmikosR committed
2376
2377
2378
2379
2380
  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */
Mark Otto's avatar
dist    
Mark Otto committed
2381

XhmikosR's avatar
Dist    
XhmikosR committed
2382
2383
2384
2385
2386
2387
2388
2389
2390
  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
2391

XhmikosR's avatar
Dist    
XhmikosR committed
2392
      this._addEventListeners();
XhmikosR's avatar
XhmikosR committed
2393
2394

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

Jacob Thornton's avatar
Jacob Thornton committed
2397

XhmikosR's avatar
Dist    
XhmikosR committed
2398
    var _proto = Dropdown.prototype;
Jacob Thornton's avatar
Jacob Thornton committed
2399

XhmikosR's avatar
Dist    
XhmikosR committed
2400
2401
    // Public
    _proto.toggle = function toggle() {
XhmikosR's avatar
XhmikosR committed
2402
      if (this._element.disabled || this._element.classList.contains(ClassName$4.DISABLED)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2403
2404
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2405

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

XhmikosR's avatar
XhmikosR committed
2408
      Dropdown.clearMenus();
Jacob Thornton's avatar
Jacob Thornton committed
2409

XhmikosR's avatar
Dist    
XhmikosR committed
2410
2411
2412
      if (isActive) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2413

XhmikosR's avatar
XhmikosR committed
2414
2415
2416
2417
2418
2419
2420
2421
2422
      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
2423
2424
2425
      var relatedTarget = {
        relatedTarget: this._element
      };
XhmikosR's avatar
XhmikosR committed
2426
      var showEvent = EventHandler.trigger(parent, Event$5.SHOW, relatedTarget);
Mark Otto's avatar
dist    
Mark Otto committed
2427

XhmikosR's avatar
XhmikosR committed
2428
      if (showEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2429
2430
        return;
      } // Disable totally Popper.js for Dropdown in Navbar
Jacob Thornton's avatar
Jacob Thornton committed
2431
2432


XhmikosR's avatar
Dist    
XhmikosR committed
2433
2434
      if (!this._inNavbar) {
        if (typeof Popper === 'undefined') {
XhmikosR's avatar
XhmikosR committed
2435
          throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org)');
Mark Otto's avatar
dist    
Mark Otto committed
2436
        }
Jacob Thornton's avatar
Jacob Thornton committed
2437

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

XhmikosR's avatar
Dist    
XhmikosR committed
2440
2441
        if (this._config.reference === 'parent') {
          referenceElement = parent;
XhmikosR's avatar
XhmikosR committed
2442
        } else if (isElement(this._config.reference)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2443
          referenceElement = this._config.reference; // Check if it's jQuery element
Mark Otto's avatar
dist    
Mark Otto committed
2444

XhmikosR's avatar
Dist    
XhmikosR committed
2445
2446
          if (typeof this._config.reference.jquery !== 'undefined') {
            referenceElement = this._config.reference[0];
Mark Otto's avatar
dist    
Mark Otto committed
2447
          }
XhmikosR's avatar
Dist    
XhmikosR committed
2448
2449
2450
        } // 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
2451

Mark Otto's avatar
dist    
Mark Otto committed
2452

XhmikosR's avatar
Dist    
XhmikosR committed
2453
        if (this._config.boundary !== 'scrollParent') {
XhmikosR's avatar
XhmikosR committed
2454
          parent.classList.add(ClassName$4.POSITION_STATIC);
XhmikosR's avatar
Dist    
XhmikosR committed
2455
        }
Mark Otto's avatar
dist    
Mark Otto committed
2456

XhmikosR's avatar
Dist    
XhmikosR committed
2457
2458
2459
2460
2461
        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
2462

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

XhmikosR's avatar
XhmikosR committed
2464
2465
2466
2467
      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
2468
      }
Mark Otto's avatar
dist    
Mark Otto committed
2469

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

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

XhmikosR's avatar
XhmikosR committed
2474
2475
2476
      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
2477
    };
Mark Otto's avatar
dist    
Mark Otto committed
2478

XhmikosR's avatar
Dist    
XhmikosR committed
2479
    _proto.hide = function hide() {
XhmikosR's avatar
XhmikosR committed
2480
      if (this._element.disabled || this._element.classList.contains(ClassName$4.DISABLED) || !this._menu.classList.contains(ClassName$4.SHOW)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2481
2482
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2483

XhmikosR's avatar
XhmikosR committed
2484
      var parent = Dropdown.getParentFromElement(this._element);
XhmikosR's avatar
Dist    
XhmikosR committed
2485
2486
2487
      var relatedTarget = {
        relatedTarget: this._element
      };
XhmikosR's avatar
XhmikosR committed
2488
      var hideEvent = EventHandler.trigger(parent, Event$5.HIDE, relatedTarget);
Mark Otto's avatar
dist    
Mark Otto committed
2489

XhmikosR's avatar
XhmikosR committed
2490
      if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2491
2492
        return;
      }
Johann-S's avatar
build    
Johann-S committed
2493

XhmikosR's avatar
XhmikosR committed
2494
2495
2496
2497
      if (this._popper) {
        this._popper.destroy();
      }

XhmikosR's avatar
XhmikosR committed
2498
2499
2500
      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
2501
    };
Johann-S's avatar
build    
Johann-S committed
2502

XhmikosR's avatar
Dist    
XhmikosR committed
2503
    _proto.dispose = function dispose() {
XhmikosR's avatar
XhmikosR committed
2504
2505
      Data.removeData(this._element, DATA_KEY$4);
      EventHandler.off(this._element, EVENT_KEY$4);
XhmikosR's avatar
Dist    
XhmikosR committed
2506
2507
      this._element = null;
      this._menu = null;
Mark Otto's avatar
dist    
Mark Otto committed
2508

XhmikosR's avatar
XhmikosR committed
2509
      if (this._popper) {
XhmikosR's avatar
Dist    
XhmikosR committed
2510
        this._popper.destroy();
Mark Otto's avatar
dist    
Mark Otto committed
2511

XhmikosR's avatar
Dist    
XhmikosR committed
2512
2513
2514
        this._popper = null;
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
2515

XhmikosR's avatar
Dist    
XhmikosR committed
2516
2517
    _proto.update = function update() {
      this._inNavbar = this._detectNavbar();
Mark Otto's avatar
build    
Mark Otto committed
2518

XhmikosR's avatar
XhmikosR committed
2519
      if (this._popper) {
XhmikosR's avatar
Dist    
XhmikosR committed
2520
2521
        this._popper.scheduleUpdate();
      }
Mark Otto's avatar
Mark Otto committed
2522
2523
    } // Private
    ;
Mark Otto's avatar
dist    
Mark Otto committed
2524

XhmikosR's avatar
Dist    
XhmikosR committed
2525
2526
    _proto._addEventListeners = function _addEventListeners() {
      var _this = this;
Mark Otto's avatar
build    
Mark Otto committed
2527

XhmikosR's avatar
XhmikosR committed
2528
      EventHandler.on(this._element, Event$5.CLICK, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2529
2530
        event.preventDefault();
        event.stopPropagation();
Mark Otto's avatar
build    
Mark Otto committed
2531

XhmikosR's avatar
Dist    
XhmikosR committed
2532
2533
2534
        _this.toggle();
      });
    };
Mark Otto's avatar
dist    
Mark Otto committed
2535

XhmikosR's avatar
Dist    
XhmikosR committed
2536
    _proto._getConfig = function _getConfig(config) {
2537
      config = _objectSpread2({}, this.constructor.Default, {}, Manipulator.getDataAttributes(this._element), {}, config);
XhmikosR's avatar
XhmikosR committed
2538
      typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
XhmikosR's avatar
Dist    
XhmikosR committed
2539
2540
      return config;
    };
Mark Otto's avatar
dist    
Mark Otto committed
2541

XhmikosR's avatar
Dist    
XhmikosR committed
2542
    _proto._getMenuElement = function _getMenuElement() {
XhmikosR's avatar
XhmikosR committed
2543
      var parent = Dropdown.getParentFromElement(this._element);
2544
      return SelectorEngine.findOne(Selector$4.MENU, parent);
XhmikosR's avatar
Dist    
XhmikosR committed
2545
    };
Mark Otto's avatar
dist    
Mark Otto committed
2546

XhmikosR's avatar
Dist    
XhmikosR committed
2547
    _proto._getPlacement = function _getPlacement() {
XhmikosR's avatar
XhmikosR committed
2548
      var parentDropdown = this._element.parentNode;
XhmikosR's avatar
Dist    
XhmikosR committed
2549
      var placement = AttachmentMap.BOTTOM; // Handle dropup
Mark Otto's avatar
dist    
Mark Otto committed
2550

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

XhmikosR's avatar
XhmikosR committed
2554
        if (this._menu.classList.contains(ClassName$4.MENURIGHT)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2555
2556
          placement = AttachmentMap.TOPEND;
        }
XhmikosR's avatar
XhmikosR committed
2557
      } else if (parentDropdown.classList.contains(ClassName$4.DROPRIGHT)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2558
        placement = AttachmentMap.RIGHT;
XhmikosR's avatar
XhmikosR committed
2559
      } else if (parentDropdown.classList.contains(ClassName$4.DROPLEFT)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2560
        placement = AttachmentMap.LEFT;
XhmikosR's avatar
XhmikosR committed
2561
      } else if (this._menu.classList.contains(ClassName$4.MENURIGHT)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2562
2563
        placement = AttachmentMap.BOTTOMEND;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2564

XhmikosR's avatar
Dist    
XhmikosR committed
2565
2566
      return placement;
    };
Mark Otto's avatar
dist    
Mark Otto committed
2567

XhmikosR's avatar
Dist    
XhmikosR committed
2568
    _proto._detectNavbar = function _detectNavbar() {
XhmikosR's avatar
XhmikosR committed
2569
      return Boolean(SelectorEngine.closest(this._element, '.navbar'));
XhmikosR's avatar
Dist    
XhmikosR committed
2570
    };
Jacob Thornton's avatar
Jacob Thornton committed
2571

Mark Otto's avatar
Mark Otto committed
2572
    _proto._getOffset = function _getOffset() {
XhmikosR's avatar
Dist    
XhmikosR committed
2573
      var _this2 = this;
Mark Otto's avatar
dist    
Mark Otto committed
2574

Mark Otto's avatar
Mark Otto committed
2575
      var offset = {};
Jacob Thornton's avatar
Jacob Thornton committed
2576

XhmikosR's avatar
Dist    
XhmikosR committed
2577
      if (typeof this._config.offset === 'function') {
Mark Otto's avatar
Mark Otto committed
2578
        offset.fn = function (data) {
2579
          data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
XhmikosR's avatar
Dist    
XhmikosR committed
2580
2581
2582
          return data;
        };
      } else {
Mark Otto's avatar
Mark Otto committed
2583
        offset.offset = this._config.offset;
XhmikosR's avatar
Dist    
XhmikosR committed
2584
      }
Mark Otto's avatar
dist    
Mark Otto committed
2585

Mark Otto's avatar
Mark Otto committed
2586
2587
2588
2589
      return offset;
    };

    _proto._getPopperConfig = function _getPopperConfig() {
XhmikosR's avatar
Dist    
XhmikosR committed
2590
2591
2592
      var popperConfig = {
        placement: this._getPlacement(),
        modifiers: {
Mark Otto's avatar
Mark Otto committed
2593
          offset: this._getOffset(),
XhmikosR's avatar
Dist    
XhmikosR committed
2594
2595
2596
2597
2598
          flip: {
            enabled: this._config.flip
          },
          preventOverflow: {
            boundariesElement: this._config.boundary
Mark Otto's avatar
grunt    
Mark Otto committed
2599
          }
XhmikosR's avatar
XhmikosR committed
2600
2601
        }
      }; // Disable Popper.js if we have a static display
Jacob Thornton's avatar
Jacob Thornton committed
2602

XhmikosR's avatar
Dist    
XhmikosR committed
2603
2604
2605
2606
2607
      if (this._config.display === 'static') {
        popperConfig.modifiers.applyStyle = {
          enabled: false
        };
      }
Jacob Thornton's avatar
Jacob Thornton committed
2608

XhmikosR's avatar
XhmikosR committed
2609
      return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
Mark Otto's avatar
Mark Otto committed
2610
2611
    } // Static
    ;
Mark Otto's avatar
dist    
Mark Otto committed
2612

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

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

XhmikosR's avatar
XhmikosR committed
2618
2619
2620
2621
2622
2623
      if (!data) {
        data = new Dropdown(element, _config);
      }

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

XhmikosR's avatar
XhmikosR committed
2627
2628
2629
        data[config]();
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
2630

XhmikosR's avatar
XhmikosR committed
2631
    Dropdown.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
XhmikosR committed
2632
      return this.each(function () {
XhmikosR's avatar
XhmikosR committed
2633
        Dropdown.dropdownInterface(this, config);
XhmikosR's avatar
Dist    
XhmikosR committed
2634
2635
      });
    };
Jacob Thornton's avatar
Jacob Thornton committed
2636

XhmikosR's avatar
XhmikosR committed
2637
    Dropdown.clearMenus = function clearMenus(event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2638
2639
2640
      if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2641

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

XhmikosR's avatar
Dist    
XhmikosR committed
2644
      for (var i = 0, len = toggles.length; i < len; i++) {
XhmikosR's avatar
XhmikosR committed
2645
        var parent = Dropdown.getParentFromElement(toggles[i]);
XhmikosR's avatar
XhmikosR committed
2646
        var context = Data.getData(toggles[i], DATA_KEY$4);
XhmikosR's avatar
Dist    
XhmikosR committed
2647
2648
2649
        var relatedTarget = {
          relatedTarget: toggles[i]
        };
Mark Otto's avatar
dist    
Mark Otto committed
2650

XhmikosR's avatar
Dist    
XhmikosR committed
2651
2652
        if (event && event.type === 'click') {
          relatedTarget.clickEvent = event;
Mark Otto's avatar
grunt    
Mark Otto committed
2653
2654
        }

XhmikosR's avatar
Dist    
XhmikosR committed
2655
2656
        if (!context) {
          continue;
Mark Otto's avatar
dist    
Mark Otto committed
2657
        }
Jacob Thornton's avatar
Jacob Thornton committed
2658

XhmikosR's avatar
Dist    
XhmikosR committed
2659
        var dropdownMenu = context._menu;
Jacob Thornton's avatar
Jacob Thornton committed
2660

XhmikosR's avatar
XhmikosR committed
2661
        if (!parent.classList.contains(ClassName$4.SHOW)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2662
2663
          continue;
        }
Mark Otto's avatar
dist    
Mark Otto committed
2664

XhmikosR's avatar
XhmikosR committed
2665
        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
2666
          continue;
Mark Otto's avatar
dist    
Mark Otto committed
2667
        }
Jacob Thornton's avatar
Jacob Thornton committed
2668

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

XhmikosR's avatar
XhmikosR committed
2671
        if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2672
2673
2674
2675
2676
2677
          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
2678
2679
2680
          makeArray(document.body.children).forEach(function (elem) {
            return EventHandler.off(elem, 'mouseover', null, noop());
          });
Mark Otto's avatar
dist    
Mark Otto committed
2681
        }
Jacob Thornton's avatar
Jacob Thornton committed
2682

XhmikosR's avatar
Dist    
XhmikosR committed
2683
        toggles[i].setAttribute('aria-expanded', 'false');
XhmikosR's avatar
XhmikosR committed
2684
2685
2686
2687
2688

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

XhmikosR's avatar
XhmikosR committed
2689
2690
2691
        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
2692
2693
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
2694

XhmikosR's avatar
XhmikosR committed
2695
2696
    Dropdown.getParentFromElement = function getParentFromElement(element) {
      return getElementFromSelector(element) || element.parentNode;
XhmikosR's avatar
XhmikosR committed
2697
    };
Jacob Thornton's avatar
Jacob Thornton committed
2698

XhmikosR's avatar
XhmikosR committed
2699
    Dropdown.dataApiKeydownHandler = function dataApiKeydownHandler(event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2700
2701
2702
2703
2704
2705
2706
      // 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
2707
      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
2708
2709
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2710

XhmikosR's avatar
Dist    
XhmikosR committed
2711
2712
      event.preventDefault();
      event.stopPropagation();
Jacob Thornton's avatar
Jacob Thornton committed
2713

XhmikosR's avatar
XhmikosR committed
2714
      if (this.disabled || this.classList.contains(ClassName$4.DISABLED)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2715
2716
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2717

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

Mark Otto's avatar
dist    
Mark Otto committed
2721
      if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2722
        if (event.which === ESCAPE_KEYCODE) {
Mark Otto's avatar
dist v5    
Mark Otto committed
2723
          SelectorEngine.findOne(Selector$4.DATA_TOGGLE, parent).focus();
Mark Otto's avatar
dist    
Mark Otto committed
2724
        }
Mark Otto's avatar
grunt    
Mark Otto committed
2725

XhmikosR's avatar
XhmikosR committed
2726
        Dropdown.clearMenus();
XhmikosR's avatar
Dist    
XhmikosR committed
2727
2728
        return;
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2729

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

XhmikosR's avatar
XhmikosR committed
2732
      if (!items.length) {
XhmikosR's avatar
Dist    
XhmikosR committed
2733
2734
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2735

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

XhmikosR's avatar
Dist    
XhmikosR committed
2738
2739
2740
2741
      if (event.which === ARROW_UP_KEYCODE && index > 0) {
        // Up
        index--;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2742

XhmikosR's avatar
Dist    
XhmikosR committed
2743
2744
2745
2746
      if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
        // Down
        index++;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2747

XhmikosR's avatar
Dist    
XhmikosR committed
2748
2749
2750
      if (index < 0) {
        index = 0;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2751

XhmikosR's avatar
Dist    
XhmikosR committed
2752
      items[index].focus();
Mark Otto's avatar
dist    
Mark Otto committed
2753
    };
Jacob Thornton's avatar
Jacob Thornton committed
2754

XhmikosR's avatar
XhmikosR committed
2755
    Dropdown.getInstance = function getInstance(element) {
XhmikosR's avatar
XhmikosR committed
2756
2757
2758
      return Data.getData(element, DATA_KEY$4);
    };

XhmikosR's avatar
Dist    
XhmikosR committed
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
    _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
2776
    return Dropdown;
XhmikosR's avatar
Dist    
XhmikosR committed
2777
2778
2779
2780
2781
2782
2783
2784
  }();
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */


XhmikosR's avatar
XhmikosR committed
2785
2786
2787
2788
  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
2789
  EventHandler.on(document, Event$5.CLICK_DATA_API, Selector$4.DATA_TOGGLE, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2790
2791
    event.preventDefault();
    event.stopPropagation();
XhmikosR's avatar
XhmikosR committed
2792
    Dropdown.dropdownInterface(this, 'toggle');
XhmikosR's avatar
XhmikosR committed
2793
2794
2795
  });
  EventHandler.on(document, Event$5.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
    return e.stopPropagation();
XhmikosR's avatar
Dist    
XhmikosR committed
2796
  });
XhmikosR's avatar
XhmikosR committed
2797
  var $$5 = getjQuery();
XhmikosR's avatar
Dist    
XhmikosR committed
2798
2799
2800
2801
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
2802
   * add .dropdown to jQuery only if jQuery is present
XhmikosR's avatar
Dist    
XhmikosR committed
2803
2804
   */

2805
2806
  /* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
2807
2808
2809
2810
  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
2811

XhmikosR's avatar
XhmikosR committed
2812
2813
2814
    $$5.fn[NAME$4].noConflict = function () {
      $$5.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
      return Dropdown.jQueryInterface;
XhmikosR's avatar
XhmikosR committed
2815
2816
    };
  }
Jacob Thornton's avatar
Jacob Thornton committed
2817

XhmikosR's avatar
Dist    
XhmikosR committed
2818
2819
2820
2821
2822
2823
2824
  /**
   * ------------------------------------------------------------------------
   * Constants
   * ------------------------------------------------------------------------
   */

  var NAME$5 = 'modal';
XhmikosR's avatar
XhmikosR committed
2825
  var VERSION$5 = '4.3.1';
XhmikosR's avatar
Dist    
XhmikosR committed
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
  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
2843
  var Event$6 = {
XhmikosR's avatar
Dist    
XhmikosR committed
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
    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
2857
    SCROLLABLE: 'modal-dialog-scrollable',
XhmikosR's avatar
Dist    
XhmikosR committed
2858
2859
2860
2861
2862
2863
2864
2865
    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
2866
    MODAL_BODY: '.modal-body',
XhmikosR's avatar
Dist    
XhmikosR committed
2867
2868
2869
2870
2871
    DATA_TOGGLE: '[data-toggle="modal"]',
    DATA_DISMISS: '[data-dismiss="modal"]',
    FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
    STICKY_CONTENT: '.sticky-top'
  };
XhmikosR's avatar
XhmikosR committed
2872
2873
2874
2875
2876
  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */
XhmikosR's avatar
Dist    
XhmikosR committed
2877
2878
2879
2880
2881
2882
2883

  var Modal =
  /*#__PURE__*/
  function () {
    function Modal(element, config) {
      this._config = this._getConfig(config);
      this._element = element;
XhmikosR's avatar
XhmikosR committed
2884
      this._dialog = SelectorEngine.findOne(Selector$5.DIALOG, element);
XhmikosR's avatar
Dist    
XhmikosR committed
2885
2886
2887
2888
2889
2890
      this._backdrop = null;
      this._isShown = false;
      this._isBodyOverflowing = false;
      this._ignoreBackdropClick = false;
      this._isTransitioning = false;
      this._scrollbarWidth = 0;
XhmikosR's avatar
XhmikosR committed
2891
      Data.setData(element, DATA_KEY$5, this);
XhmikosR's avatar
Dist    
XhmikosR committed
2892
2893
2894
2895
2896
2897
2898
2899
    } // 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
2900
    };
Jacob Thornton's avatar
Jacob Thornton committed
2901

XhmikosR's avatar
Dist    
XhmikosR committed
2902
2903
    _proto.show = function show(relatedTarget) {
      var _this = this;
Mark Otto's avatar
grunt    
Mark Otto committed
2904

XhmikosR's avatar
Dist    
XhmikosR committed
2905
2906
2907
      if (this._isShown || this._isTransitioning) {
        return;
      }
Mark Otto's avatar
grunt    
Mark Otto committed
2908

XhmikosR's avatar
XhmikosR committed
2909
      if (this._element.classList.contains(ClassName$5.FADE)) {
XhmikosR's avatar
Dist    
XhmikosR committed
2910
2911
        this._isTransitioning = true;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2912

XhmikosR's avatar
XhmikosR committed
2913
      var showEvent = EventHandler.trigger(this._element, Event$6.SHOW, {
XhmikosR's avatar
Dist    
XhmikosR committed
2914
2915
        relatedTarget: relatedTarget
      });
Jacob Thornton's avatar
Jacob Thornton committed
2916

XhmikosR's avatar
XhmikosR committed
2917
      if (this._isShown || showEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2918
2919
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2920

XhmikosR's avatar
Dist    
XhmikosR committed
2921
      this._isShown = true;
Mark Otto's avatar
dist    
Mark Otto committed
2922

XhmikosR's avatar
Dist    
XhmikosR committed
2923
      this._checkScrollbar();
Jacob Thornton's avatar
Jacob Thornton committed
2924

XhmikosR's avatar
Dist    
XhmikosR committed
2925
      this._setScrollbar();
Mark Otto's avatar
dist    
Mark Otto committed
2926

XhmikosR's avatar
Dist    
XhmikosR committed
2927
      this._adjustDialog();
Jacob Thornton's avatar
Jacob Thornton committed
2928

XhmikosR's avatar
Dist    
XhmikosR committed
2929
      this._setEscapeEvent();
Jacob Thornton's avatar
Jacob Thornton committed
2930

XhmikosR's avatar
Dist    
XhmikosR committed
2931
      this._setResizeEvent();
Mark Otto's avatar
grunt    
Mark Otto committed
2932

XhmikosR's avatar
XhmikosR committed
2933
      EventHandler.on(this._element, Event$6.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2934
2935
        return _this.hide(event);
      });
XhmikosR's avatar
XhmikosR committed
2936
2937
2938
      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
2939
2940
            _this._ignoreBackdropClick = true;
          }
Mark Otto's avatar
dist    
Mark Otto committed
2941
        });
XhmikosR's avatar
Dist    
XhmikosR committed
2942
      });
Jacob Thornton's avatar
Jacob Thornton committed
2943

XhmikosR's avatar
Dist    
XhmikosR committed
2944
2945
2946
2947
      this._showBackdrop(function () {
        return _this._showElement(relatedTarget);
      });
    };
Mark Otto's avatar
grunt    
Mark Otto committed
2948

XhmikosR's avatar
Dist    
XhmikosR committed
2949
2950
    _proto.hide = function hide(event) {
      var _this2 = this;
Jacob Thornton's avatar
Jacob Thornton committed
2951

XhmikosR's avatar
Dist    
XhmikosR committed
2952
2953
2954
      if (event) {
        event.preventDefault();
      }
Jacob Thornton's avatar
Jacob Thornton committed
2955

XhmikosR's avatar
Dist    
XhmikosR committed
2956
2957
2958
      if (!this._isShown || this._isTransitioning) {
        return;
      }
Jacob Thornton's avatar
Jacob Thornton committed
2959

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

2962
      if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist    
XhmikosR committed
2963
2964
        return;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2965

XhmikosR's avatar
Dist    
XhmikosR committed
2966
      this._isShown = false;
XhmikosR's avatar
XhmikosR committed
2967
2968

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

XhmikosR's avatar
Dist    
XhmikosR committed
2970
2971
2972
      if (transition) {
        this._isTransitioning = true;
      }
Mark Otto's avatar
dist    
Mark Otto committed
2973

XhmikosR's avatar
Dist    
XhmikosR committed
2974
      this._setEscapeEvent();
Jacob Thornton's avatar
Jacob Thornton committed
2975

XhmikosR's avatar
Dist    
XhmikosR committed
2976
      this._setResizeEvent();
Jacob Thornton's avatar
Jacob Thornton committed
2977

XhmikosR's avatar
XhmikosR committed
2978
2979
2980
2981
2982
2983
      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
2984

XhmikosR's avatar
Dist    
XhmikosR committed
2985
      if (transition) {
XhmikosR's avatar
XhmikosR committed
2986
2987
        var transitionDuration = getTransitionDurationFromElement(this._element);
        EventHandler.one(this._element, TRANSITION_END, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2988
          return _this2._hideModal(event);
XhmikosR's avatar
XhmikosR committed
2989
2990
        });
        emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
Dist    
XhmikosR committed
2991
2992
2993
2994
      } else {
        this._hideModal();
      }
    };
Jacob Thornton's avatar
Jacob Thornton committed
2995

XhmikosR's avatar
Dist    
XhmikosR committed
2996
2997
    _proto.dispose = function dispose() {
      [window, this._element, this._dialog].forEach(function (htmlElement) {
XhmikosR's avatar
XhmikosR committed
2998
        return EventHandler.off(htmlElement, EVENT_KEY$5);
XhmikosR's avatar
Dist    
XhmikosR committed
2999
3000
      });
      /**
For faster browsing, not all history is shown. View entire blame