bootstrap.esm.js 145 KB
Newer Older
XhmikosR's avatar
XhmikosR committed
2001
        var elem = getElementFromSelector(trigger);
XhmikosR's avatar
Dist.  
XhmikosR committed
2002

XhmikosR's avatar
XhmikosR committed
2003
2004
        if (elem && !elem.classList.contains(CLASS_NAME_SHOW)) {
          trigger.classList.add(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
XhmikosR committed
2005
          trigger.setAttribute('aria-expanded', false);
XhmikosR's avatar
Dist.  
XhmikosR committed
2006
2007
2008
2009
2010
2011
        }
      }
    }

    this.setTransitioning(true);

XhmikosR's avatar
XhmikosR committed
2012
2013
    var complete = function complete() {
      _this2.setTransitioning(false);
XhmikosR's avatar
Dist.  
XhmikosR committed
2014

XhmikosR's avatar
XhmikosR committed
2015
      _this2._element.classList.remove(CLASS_NAME_COLLAPSING);
XhmikosR's avatar
Dist.  
XhmikosR committed
2016

XhmikosR's avatar
XhmikosR committed
2017
      _this2._element.classList.add(CLASS_NAME_COLLAPSE);
XhmikosR's avatar
Dist.  
XhmikosR committed
2018

XhmikosR's avatar
XhmikosR committed
2019
      EventHandler.trigger(_this2._element, EVENT_HIDDEN);
XhmikosR's avatar
Dist.  
XhmikosR committed
2020
2021
2022
    };

    this._element.style[dimension] = '';
XhmikosR's avatar
XhmikosR committed
2023
    var transitionDuration = getTransitionDurationFromElement(this._element);
XhmikosR's avatar
Dist.  
XhmikosR committed
2024
2025
    EventHandler.one(this._element, TRANSITION_END, complete);
    emulateTransitionEnd(this._element, transitionDuration);
XhmikosR's avatar
XhmikosR committed
2026
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2027

XhmikosR's avatar
XhmikosR committed
2028
  _proto.setTransitioning = function setTransitioning(isTransitioning) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2029
    this._isTransitioning = isTransitioning;
XhmikosR's avatar
XhmikosR committed
2030
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2031

XhmikosR's avatar
XhmikosR committed
2032
  _proto.dispose = function dispose() {
XhmikosR's avatar
Dist.  
XhmikosR committed
2033
2034
2035
2036
2037
2038
2039
    Data.removeData(this._element, DATA_KEY$3);
    this._config = null;
    this._parent = null;
    this._element = null;
    this._triggerArray = null;
    this._isTransitioning = null;
  } // Private
XhmikosR's avatar
XhmikosR committed
2040
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
2041

XhmikosR's avatar
XhmikosR committed
2042
  _proto._getConfig = function _getConfig(config) {
2043
    config = _objectSpread2({}, Default$1, {}, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
2044
2045
2046
2047
    config.toggle = Boolean(config.toggle); // Coerce string values

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

XhmikosR's avatar
XhmikosR committed
2050
  _proto._getDimension = function _getDimension() {
XhmikosR's avatar
XhmikosR committed
2051
    var hasWidth = this._element.classList.contains(WIDTH);
XhmikosR's avatar
Dist.  
XhmikosR committed
2052

XhmikosR's avatar
XhmikosR committed
2053
    return hasWidth ? WIDTH : HEIGHT;
XhmikosR's avatar
XhmikosR committed
2054
2055
2056
2057
  };

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

XhmikosR's avatar
XhmikosR committed
2059
    var parent = this._config.parent;
XhmikosR's avatar
Dist.  
XhmikosR committed
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069

    if (isElement(parent)) {
      // it's a jQuery object
      if (typeof parent.jquery !== 'undefined' || typeof parent[0] !== 'undefined') {
        parent = parent[0];
      }
    } else {
      parent = SelectorEngine.findOne(parent);
    }

XhmikosR's avatar
XhmikosR committed
2070
2071
    var selector = SELECTOR_DATA_TOGGLE$1 + "[data-parent=\"" + parent + "\"]";
    SelectorEngine.find(selector, parent).forEach(function (element) {
XhmikosR's avatar
XhmikosR committed
2072
      var selected = getElementFromSelector(element);
2073
2074

      _this3._addAriaAndCollapsedClass(selected, [element]);
XhmikosR's avatar
Dist.  
XhmikosR committed
2075
2076
    });
    return parent;
XhmikosR's avatar
XhmikosR committed
2077
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2078

XhmikosR's avatar
XhmikosR committed
2079
  _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2080
    if (element) {
XhmikosR's avatar
XhmikosR committed
2081
      var isOpen = element.classList.contains(CLASS_NAME_SHOW);
XhmikosR's avatar
Dist.  
XhmikosR committed
2082
2083

      if (triggerArray.length) {
XhmikosR's avatar
XhmikosR committed
2084
        triggerArray.forEach(function (elem) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2085
          if (isOpen) {
XhmikosR's avatar
XhmikosR committed
2086
            elem.classList.remove(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
Dist.  
XhmikosR committed
2087
          } else {
XhmikosR's avatar
XhmikosR committed
2088
            elem.classList.add(CLASS_NAME_COLLAPSED);
XhmikosR's avatar
Dist.  
XhmikosR committed
2089
2090
2091
2092
2093
2094
2095
          }

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

XhmikosR's avatar
XhmikosR committed
2098
  Collapse.collapseInterface = function collapseInterface(element, config) {
XhmikosR's avatar
XhmikosR committed
2099
    var data = Data.getData(element, DATA_KEY$3);
XhmikosR's avatar
Dist.  
XhmikosR committed
2100

2101
    var _config = _objectSpread2({}, Default$1, {}, Manipulator.getDataAttributes(element), {}, typeof config === 'object' && config ? config : {});
XhmikosR's avatar
Dist.  
XhmikosR committed
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112

    if (!data && _config.toggle && /show|hide/.test(config)) {
      _config.toggle = false;
    }

    if (!data) {
      data = new Collapse(element, _config);
    }

    if (typeof config === 'string') {
      if (typeof data[config] === 'undefined') {
XhmikosR's avatar
XhmikosR committed
2113
        throw new TypeError("No method named \"" + config + "\"");
XhmikosR's avatar
Dist.  
XhmikosR committed
2114
2115
2116
2117
      }

      data[config]();
    }
XhmikosR's avatar
XhmikosR committed
2118
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2119

XhmikosR's avatar
XhmikosR committed
2120
  Collapse.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2121
    return this.each(function () {
XhmikosR's avatar
XhmikosR committed
2122
      Collapse.collapseInterface(this, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
2123
    });
XhmikosR's avatar
XhmikosR committed
2124
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2125

XhmikosR's avatar
XhmikosR committed
2126
  Collapse.getInstance = function getInstance(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2127
    return Data.getData(element, DATA_KEY$3);
XhmikosR's avatar
XhmikosR committed
2128
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2129

XhmikosR's avatar
XhmikosR committed
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
  _createClass(Collapse, null, [{
    key: "VERSION",
    get: function get() {
      return VERSION$3;
    }
  }, {
    key: "Default",
    get: function get() {
      return Default$1;
    }
  }]);

  return Collapse;
}();
XhmikosR's avatar
Dist.  
XhmikosR committed
2144
2145
2146
2147
2148
2149
2150
/**
 * ------------------------------------------------------------------------
 * Data Api implementation
 * ------------------------------------------------------------------------
 */


XhmikosR's avatar
XhmikosR committed
2151
EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$1, function (event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2152
2153
2154
2155
2156
  // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  if (event.target.tagName === 'A') {
    event.preventDefault();
  }

XhmikosR's avatar
XhmikosR committed
2157
2158
  var triggerData = Manipulator.getDataAttributes(this);
  var selector = getSelectorFromElement(this);
XhmikosR's avatar
XhmikosR committed
2159
  var selectorElements = SelectorEngine.find(selector);
XhmikosR's avatar
XhmikosR committed
2160
2161
2162
  selectorElements.forEach(function (element) {
    var data = Data.getData(element, DATA_KEY$3);
    var config;
XhmikosR's avatar
Dist.  
XhmikosR committed
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175

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

XhmikosR's avatar
XhmikosR committed
2176
    Collapse.collapseInterface(element, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
2177
2178
  });
});
XhmikosR's avatar
XhmikosR committed
2179
var $$4 = getjQuery();
XhmikosR's avatar
Dist.  
XhmikosR committed
2180
2181
2182
2183
2184
2185
2186
/**
 * ------------------------------------------------------------------------
 * jQuery
 * ------------------------------------------------------------------------
 * add .collapse to jQuery only if jQuery is present
 */

2187
2188
/* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
2189
2190
2191
2192
if ($$4) {
  var JQUERY_NO_CONFLICT$3 = $$4.fn[NAME$3];
  $$4.fn[NAME$3] = Collapse.jQueryInterface;
  $$4.fn[NAME$3].Constructor = Collapse;
XhmikosR's avatar
Dist.  
XhmikosR committed
2193

XhmikosR's avatar
XhmikosR committed
2194
2195
2196
  $$4.fn[NAME$3].noConflict = function () {
    $$4.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
    return Collapse.jQueryInterface;
XhmikosR's avatar
Dist.  
XhmikosR committed
2197
2198
2199
2200
2201
2202
2203
2204
2205
  };
}

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

XhmikosR's avatar
XhmikosR committed
2206
2207
2208
2209
2210
2211
var NAME$4 = 'dropdown';
var VERSION$4 = '4.3.1';
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
XhmikosR's avatar
Dist.  
XhmikosR committed
2212

XhmikosR's avatar
XhmikosR committed
2213
var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
XhmikosR's avatar
Dist.  
XhmikosR committed
2214

XhmikosR's avatar
XhmikosR committed
2215
var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
XhmikosR's avatar
Dist.  
XhmikosR committed
2216

XhmikosR's avatar
XhmikosR committed
2217
var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
XhmikosR's avatar
Dist.  
XhmikosR committed
2218

XhmikosR's avatar
XhmikosR committed
2219
var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
XhmikosR's avatar
Dist.  
XhmikosR committed
2220

XhmikosR's avatar
XhmikosR committed
2221
var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
XhmikosR's avatar
Dist.  
XhmikosR committed
2222

XhmikosR's avatar
XhmikosR committed
2223
var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
XhmikosR's avatar
XhmikosR committed
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
var EVENT_HIDE$1 = "hide" + EVENT_KEY$4;
var EVENT_HIDDEN$1 = "hidden" + EVENT_KEY$4;
var EVENT_SHOW$1 = "show" + EVENT_KEY$4;
var EVENT_SHOWN$1 = "shown" + EVENT_KEY$4;
var EVENT_CLICK = "click" + EVENT_KEY$4;
var EVENT_CLICK_DATA_API$4 = "click" + EVENT_KEY$4 + DATA_API_KEY$4;
var EVENT_KEYDOWN_DATA_API = "keydown" + EVENT_KEY$4 + DATA_API_KEY$4;
var EVENT_KEYUP_DATA_API = "keyup" + EVENT_KEY$4 + DATA_API_KEY$4;
var CLASS_NAME_DISABLED$1 = 'disabled';
var CLASS_NAME_SHOW$1 = 'show';
var CLASS_NAME_DROPUP = 'dropup';
var CLASS_NAME_DROPRIGHT = 'dropright';
var CLASS_NAME_DROPLEFT = 'dropleft';
var CLASS_NAME_MENURIGHT = 'dropdown-menu-right';
var CLASS_NAME_NAVBAR = 'navbar';
var CLASS_NAME_POSITION_STATIC = 'position-static';
var SELECTOR_DATA_TOGGLE$2 = '[data-toggle="dropdown"]';
var SELECTOR_FORM_CHILD = '.dropdown form';
var SELECTOR_MENU = '.dropdown-menu';
var SELECTOR_NAVBAR_NAV = '.navbar-nav';
var SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
var PLACEMENT_TOP = 'top-start';
var PLACEMENT_TOPEND = 'top-end';
var PLACEMENT_BOTTOM = 'bottom-start';
var PLACEMENT_BOTTOMEND = 'bottom-end';
var PLACEMENT_RIGHT = 'right-start';
var PLACEMENT_LEFT = 'left-start';
XhmikosR's avatar
XhmikosR committed
2251
var Default$2 = {
XhmikosR's avatar
Dist.  
XhmikosR committed
2252
2253
2254
2255
  offset: 0,
  flip: true,
  boundary: 'scrollParent',
  reference: 'toggle',
XhmikosR's avatar
XhmikosR committed
2256
2257
  display: 'dynamic',
  popperConfig: null
XhmikosR's avatar
Dist.  
XhmikosR committed
2258
};
XhmikosR's avatar
XhmikosR committed
2259
var DefaultType$2 = {
XhmikosR's avatar
Dist.  
XhmikosR committed
2260
2261
2262
2263
  offset: '(number|string|function)',
  flip: 'boolean',
  boundary: '(string|element)',
  reference: '(string|element)',
XhmikosR's avatar
XhmikosR committed
2264
2265
  display: 'string',
  popperConfig: '(null|object)'
XhmikosR's avatar
Dist.  
XhmikosR committed
2266
};
XhmikosR's avatar
XhmikosR committed
2267
2268
2269
2270
2271
/**
 * ------------------------------------------------------------------------
 * Class Definition
 * ------------------------------------------------------------------------
 */
XhmikosR's avatar
Dist.  
XhmikosR committed
2272

XhmikosR's avatar
XhmikosR committed
2273
var Dropdown = /*#__PURE__*/function () {
XhmikosR's avatar
XhmikosR committed
2274
  function Dropdown(element, config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
    this._element = element;
    this._popper = null;
    this._config = this._getConfig(config);
    this._menu = this._getMenuElement();
    this._inNavbar = this._detectNavbar();

    this._addEventListeners();

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


XhmikosR's avatar
XhmikosR committed
2287
  var _proto = Dropdown.prototype;
XhmikosR's avatar
Dist.  
XhmikosR committed
2288

XhmikosR's avatar
XhmikosR committed
2289
2290
  // Public
  _proto.toggle = function toggle() {
XhmikosR's avatar
XhmikosR committed
2291
    if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED$1)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2292
2293
2294
      return;
    }

XhmikosR's avatar
XhmikosR committed
2295
    var isActive = this._element.classList.contains(CLASS_NAME_SHOW$1);
XhmikosR's avatar
Dist.  
XhmikosR committed
2296

XhmikosR's avatar
XhmikosR committed
2297
    Dropdown.clearMenus();
XhmikosR's avatar
Dist.  
XhmikosR committed
2298
2299
2300
2301
2302

    if (isActive) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
2303
2304
2305
2306
    this.show();
  };

  _proto.show = function show() {
XhmikosR's avatar
XhmikosR committed
2307
    if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED$1) || this._menu.classList.contains(CLASS_NAME_SHOW$1)) {
XhmikosR's avatar
XhmikosR committed
2308
2309
2310
2311
      return;
    }

    var parent = Dropdown.getParentFromElement(this._element);
XhmikosR's avatar
XhmikosR committed
2312
    var relatedTarget = {
XhmikosR's avatar
Dist.  
XhmikosR committed
2313
2314
      relatedTarget: this._element
    };
XhmikosR's avatar
XhmikosR committed
2315
    var showEvent = EventHandler.trigger(this._element, EVENT_SHOW$1, relatedTarget);
XhmikosR's avatar
Dist.  
XhmikosR committed
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326

    if (showEvent.defaultPrevented) {
      return;
    } // Disable totally Popper.js for Dropdown in Navbar


    if (!this._inNavbar) {
      if (typeof Popper === 'undefined') {
        throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org)');
      }

XhmikosR's avatar
XhmikosR committed
2327
      var referenceElement = this._element;
XhmikosR's avatar
Dist.  
XhmikosR committed
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342

      if (this._config.reference === 'parent') {
        referenceElement = parent;
      } else if (isElement(this._config.reference)) {
        referenceElement = this._config.reference; // Check if it's jQuery element

        if (typeof this._config.reference.jquery !== 'undefined') {
          referenceElement = this._config.reference[0];
        }
      } // 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


      if (this._config.boundary !== 'scrollParent') {
XhmikosR's avatar
XhmikosR committed
2343
        parent.classList.add(CLASS_NAME_POSITION_STATIC);
XhmikosR's avatar
Dist.  
XhmikosR committed
2344
2345
2346
2347
2348
2349
2350
2351
2352
      }

      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


XhmikosR's avatar
XhmikosR committed
2353
2354
2355
2356
    if ('ontouchstart' in document.documentElement && !SelectorEngine.closest(parent, SELECTOR_NAVBAR_NAV)) {
      var _ref;

      (_ref = []).concat.apply(_ref, document.body.children).forEach(function (elem) {
XhmikosR's avatar
XhmikosR committed
2357
2358
        return EventHandler.on(elem, 'mouseover', null, noop());
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
2359
2360
2361
2362
2363
2364
    }

    this._element.focus();

    this._element.setAttribute('aria-expanded', true);

XhmikosR's avatar
XhmikosR committed
2365
2366
2367
    Manipulator.toggleClass(this._menu, CLASS_NAME_SHOW$1);
    Manipulator.toggleClass(this._element, CLASS_NAME_SHOW$1);
    EventHandler.trigger(parent, EVENT_SHOWN$1, relatedTarget);
XhmikosR's avatar
XhmikosR committed
2368
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2369

XhmikosR's avatar
XhmikosR committed
2370
  _proto.hide = function hide() {
XhmikosR's avatar
XhmikosR committed
2371
    if (this._element.disabled || this._element.classList.contains(CLASS_NAME_DISABLED$1) || !this._menu.classList.contains(CLASS_NAME_SHOW$1)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2372
2373
2374
      return;
    }

XhmikosR's avatar
XhmikosR committed
2375
    var parent = Dropdown.getParentFromElement(this._element);
XhmikosR's avatar
XhmikosR committed
2376
    var relatedTarget = {
XhmikosR's avatar
Dist.  
XhmikosR committed
2377
2378
      relatedTarget: this._element
    };
XhmikosR's avatar
XhmikosR committed
2379
    var hideEvent = EventHandler.trigger(parent, EVENT_HIDE$1, relatedTarget);
XhmikosR's avatar
Dist.  
XhmikosR committed
2380
2381
2382
2383
2384

    if (hideEvent.defaultPrevented) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
2385
2386
2387
2388
    if (this._popper) {
      this._popper.destroy();
    }

XhmikosR's avatar
XhmikosR committed
2389
2390
2391
    Manipulator.toggleClass(this._menu, CLASS_NAME_SHOW$1);
    Manipulator.toggleClass(this._element, CLASS_NAME_SHOW$1);
    EventHandler.trigger(parent, EVENT_HIDDEN$1, relatedTarget);
XhmikosR's avatar
XhmikosR committed
2392
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2393

XhmikosR's avatar
XhmikosR committed
2394
  _proto.dispose = function dispose() {
XhmikosR's avatar
Dist.  
XhmikosR committed
2395
2396
2397
2398
2399
    Data.removeData(this._element, DATA_KEY$4);
    EventHandler.off(this._element, EVENT_KEY$4);
    this._element = null;
    this._menu = null;

XhmikosR's avatar
XhmikosR committed
2400
    if (this._popper) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2401
2402
2403
2404
      this._popper.destroy();

      this._popper = null;
    }
XhmikosR's avatar
XhmikosR committed
2405
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2406

XhmikosR's avatar
XhmikosR committed
2407
  _proto.update = function update() {
XhmikosR's avatar
Dist.  
XhmikosR committed
2408
2409
    this._inNavbar = this._detectNavbar();

XhmikosR's avatar
XhmikosR committed
2410
    if (this._popper) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2411
2412
2413
      this._popper.scheduleUpdate();
    }
  } // Private
XhmikosR's avatar
XhmikosR committed
2414
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
2415

XhmikosR's avatar
XhmikosR committed
2416
2417
  _proto._addEventListeners = function _addEventListeners() {
    var _this = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
2418

XhmikosR's avatar
XhmikosR committed
2419
    EventHandler.on(this._element, EVENT_CLICK, function (event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2420
2421
      event.preventDefault();
      event.stopPropagation();
XhmikosR's avatar
XhmikosR committed
2422
2423

      _this.toggle();
XhmikosR's avatar
Dist.  
XhmikosR committed
2424
    });
XhmikosR's avatar
XhmikosR committed
2425
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2426

XhmikosR's avatar
XhmikosR committed
2427
  _proto._getConfig = function _getConfig(config) {
2428
    config = _objectSpread2({}, this.constructor.Default, {}, Manipulator.getDataAttributes(this._element), {}, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
2429
2430
    typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
    return config;
XhmikosR's avatar
XhmikosR committed
2431
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2432

XhmikosR's avatar
XhmikosR committed
2433
  _proto._getMenuElement = function _getMenuElement() {
XhmikosR's avatar
XhmikosR committed
2434
    return SelectorEngine.next(this._element, SELECTOR_MENU)[0];
XhmikosR's avatar
XhmikosR committed
2435
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2436

XhmikosR's avatar
XhmikosR committed
2437
2438
  _proto._getPlacement = function _getPlacement() {
    var parentDropdown = this._element.parentNode;
XhmikosR's avatar
XhmikosR committed
2439
    var placement = PLACEMENT_BOTTOM; // Handle dropup
XhmikosR's avatar
Dist.  
XhmikosR committed
2440

XhmikosR's avatar
XhmikosR committed
2441
2442
    if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
      placement = PLACEMENT_TOP;
XhmikosR's avatar
Dist.  
XhmikosR committed
2443

XhmikosR's avatar
XhmikosR committed
2444
2445
      if (this._menu.classList.contains(CLASS_NAME_MENURIGHT)) {
        placement = PLACEMENT_TOPEND;
XhmikosR's avatar
Dist.  
XhmikosR committed
2446
      }
XhmikosR's avatar
XhmikosR committed
2447
2448
2449
2450
2451
2452
    } else if (parentDropdown.classList.contains(CLASS_NAME_DROPRIGHT)) {
      placement = PLACEMENT_RIGHT;
    } else if (parentDropdown.classList.contains(CLASS_NAME_DROPLEFT)) {
      placement = PLACEMENT_LEFT;
    } else if (this._menu.classList.contains(CLASS_NAME_MENURIGHT)) {
      placement = PLACEMENT_BOTTOMEND;
XhmikosR's avatar
Dist.  
XhmikosR committed
2453
2454
2455
    }

    return placement;
XhmikosR's avatar
XhmikosR committed
2456
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2457

XhmikosR's avatar
XhmikosR committed
2458
  _proto._detectNavbar = function _detectNavbar() {
XhmikosR's avatar
XhmikosR committed
2459
    return Boolean(SelectorEngine.closest(this._element, "." + CLASS_NAME_NAVBAR));
XhmikosR's avatar
XhmikosR committed
2460
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2461

XhmikosR's avatar
XhmikosR committed
2462
2463
2464
2465
  _proto._getOffset = function _getOffset() {
    var _this2 = this;

    var offset = {};
XhmikosR's avatar
Dist.  
XhmikosR committed
2466
2467

    if (typeof this._config.offset === 'function') {
XhmikosR's avatar
XhmikosR committed
2468
      offset.fn = function (data) {
2469
        data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
XhmikosR's avatar
Dist.  
XhmikosR committed
2470
2471
2472
2473
2474
2475
2476
        return data;
      };
    } else {
      offset.offset = this._config.offset;
    }

    return offset;
XhmikosR's avatar
XhmikosR committed
2477
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2478

XhmikosR's avatar
XhmikosR committed
2479
2480
  _proto._getPopperConfig = function _getPopperConfig() {
    var popperConfig = {
XhmikosR's avatar
Dist.  
XhmikosR committed
2481
2482
2483
2484
2485
2486
2487
2488
2489
      placement: this._getPlacement(),
      modifiers: {
        offset: this._getOffset(),
        flip: {
          enabled: this._config.flip
        },
        preventOverflow: {
          boundariesElement: this._config.boundary
        }
XhmikosR's avatar
XhmikosR committed
2490
2491
      }
    }; // Disable Popper.js if we have a static display
XhmikosR's avatar
Dist.  
XhmikosR committed
2492
2493
2494
2495
2496
2497
2498

    if (this._config.display === 'static') {
      popperConfig.modifiers.applyStyle = {
        enabled: false
      };
    }

XhmikosR's avatar
XhmikosR committed
2499
    return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
XhmikosR's avatar
Dist.  
XhmikosR committed
2500
  } // Static
XhmikosR's avatar
XhmikosR committed
2501
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
2502

XhmikosR's avatar
XhmikosR committed
2503
  Dropdown.dropdownInterface = function dropdownInterface(element, config) {
XhmikosR's avatar
XhmikosR committed
2504
    var data = Data.getData(element, DATA_KEY$4);
XhmikosR's avatar
Dist.  
XhmikosR committed
2505

XhmikosR's avatar
XhmikosR committed
2506
    var _config = typeof config === 'object' ? config : null;
XhmikosR's avatar
Dist.  
XhmikosR committed
2507
2508
2509
2510
2511
2512
2513

    if (!data) {
      data = new Dropdown(element, _config);
    }

    if (typeof config === 'string') {
      if (typeof data[config] === 'undefined') {
XhmikosR's avatar
XhmikosR committed
2514
        throw new TypeError("No method named \"" + config + "\"");
XhmikosR's avatar
Dist.  
XhmikosR committed
2515
2516
2517
2518
      }

      data[config]();
    }
XhmikosR's avatar
XhmikosR committed
2519
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2520

XhmikosR's avatar
XhmikosR committed
2521
  Dropdown.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2522
    return this.each(function () {
XhmikosR's avatar
XhmikosR committed
2523
      Dropdown.dropdownInterface(this, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
2524
    });
XhmikosR's avatar
XhmikosR committed
2525
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2526

XhmikosR's avatar
XhmikosR committed
2527
  Dropdown.clearMenus = function clearMenus(event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2528
2529
2530
2531
    if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
2532
    var toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE$2);
XhmikosR's avatar
Dist.  
XhmikosR committed
2533

XhmikosR's avatar
XhmikosR committed
2534
    for (var i = 0, len = toggles.length; i < len; i++) {
XhmikosR's avatar
XhmikosR committed
2535
      var parent = Dropdown.getParentFromElement(toggles[i]);
XhmikosR's avatar
XhmikosR committed
2536
2537
      var context = Data.getData(toggles[i], DATA_KEY$4);
      var relatedTarget = {
XhmikosR's avatar
Dist.  
XhmikosR committed
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
        relatedTarget: toggles[i]
      };

      if (event && event.type === 'click') {
        relatedTarget.clickEvent = event;
      }

      if (!context) {
        continue;
      }

XhmikosR's avatar
XhmikosR committed
2549
      var dropdownMenu = context._menu;
XhmikosR's avatar
Dist.  
XhmikosR committed
2550

XhmikosR's avatar
XhmikosR committed
2551
      if (!toggles[i].classList.contains(CLASS_NAME_SHOW$1)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2552
2553
2554
        continue;
      }

XhmikosR's avatar
XhmikosR committed
2555
      if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && dropdownMenu.contains(event.target)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2556
2557
2558
        continue;
      }

XhmikosR's avatar
XhmikosR committed
2559
      var hideEvent = EventHandler.trigger(parent, EVENT_HIDE$1, relatedTarget);
XhmikosR's avatar
Dist.  
XhmikosR committed
2560
2561
2562
2563
2564
2565
2566
2567

      if (hideEvent.defaultPrevented) {
        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
2568
2569
2570
        var _ref2;

        (_ref2 = []).concat.apply(_ref2, document.body.children).forEach(function (elem) {
XhmikosR's avatar
XhmikosR committed
2571
2572
          return EventHandler.off(elem, 'mouseover', null, noop());
        });
XhmikosR's avatar
Dist.  
XhmikosR committed
2573
2574
2575
      }

      toggles[i].setAttribute('aria-expanded', 'false');
XhmikosR's avatar
XhmikosR committed
2576
2577
2578
2579
2580

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

XhmikosR's avatar
XhmikosR committed
2581
2582
2583
      dropdownMenu.classList.remove(CLASS_NAME_SHOW$1);
      toggles[i].classList.remove(CLASS_NAME_SHOW$1);
      EventHandler.trigger(parent, EVENT_HIDDEN$1, relatedTarget);
XhmikosR's avatar
Dist.  
XhmikosR committed
2584
    }
XhmikosR's avatar
XhmikosR committed
2585
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2586

XhmikosR's avatar
XhmikosR committed
2587
2588
  Dropdown.getParentFromElement = function getParentFromElement(element) {
    return getElementFromSelector(element) || element.parentNode;
XhmikosR's avatar
XhmikosR committed
2589
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2590

XhmikosR's avatar
XhmikosR committed
2591
  Dropdown.dataApiKeydownHandler = function dataApiKeydownHandler(event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2592
2593
2594
2595
2596
2597
2598
    // 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
2599
    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_MENU)) : !REGEXP_KEYDOWN.test(event.which)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2600
2601
2602
2603
2604
2605
      return;
    }

    event.preventDefault();
    event.stopPropagation();

XhmikosR's avatar
XhmikosR committed
2606
    if (this.disabled || this.classList.contains(CLASS_NAME_DISABLED$1)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2607
2608
2609
      return;
    }

XhmikosR's avatar
XhmikosR committed
2610
    var parent = Dropdown.getParentFromElement(this);
XhmikosR's avatar
XhmikosR committed
2611
    var isActive = this.classList.contains(CLASS_NAME_SHOW$1);
XhmikosR's avatar
Dist.  
XhmikosR committed
2612

XhmikosR's avatar
XhmikosR committed
2613
2614
2615
2616
2617
2618
    if (event.which === ESCAPE_KEYCODE) {
      var button = this.matches(SELECTOR_DATA_TOGGLE$2) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$2)[0];
      button.focus();
      Dropdown.clearMenus();
      return;
    }
XhmikosR's avatar
Dist.  
XhmikosR committed
2619

XhmikosR's avatar
XhmikosR committed
2620
    if (!isActive || event.which === SPACE_KEYCODE) {
XhmikosR's avatar
XhmikosR committed
2621
      Dropdown.clearMenus();
XhmikosR's avatar
Dist.  
XhmikosR committed
2622
2623
2624
      return;
    }

XhmikosR's avatar
XhmikosR committed
2625
    var items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, parent).filter(isVisible);
XhmikosR's avatar
Dist.  
XhmikosR committed
2626
2627
2628
2629
2630

    if (!items.length) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
2631
    var index = items.indexOf(event.target) || 0;
XhmikosR's avatar
Dist.  
XhmikosR committed
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643

    if (event.which === ARROW_UP_KEYCODE && index > 0) {
      // Up
      index--;
    }

    if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
      // Down
      index++;
    }

    items[index].focus();
XhmikosR's avatar
XhmikosR committed
2644
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2645

XhmikosR's avatar
XhmikosR committed
2646
  Dropdown.getInstance = function getInstance(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2647
    return Data.getData(element, DATA_KEY$4);
XhmikosR's avatar
XhmikosR committed
2648
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2649

XhmikosR's avatar
XhmikosR committed
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
  _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;
    }
  }]);

  return Dropdown;
}();
XhmikosR's avatar
Dist.  
XhmikosR committed
2669
2670
2671
2672
2673
2674
2675
/**
 * ------------------------------------------------------------------------
 * Data Api implementation
 * ------------------------------------------------------------------------
 */


XhmikosR's avatar
XhmikosR committed
2676
2677
2678
2679
2680
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$2, Dropdown.dataApiKeydownHandler);
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
EventHandler.on(document, EVENT_CLICK_DATA_API$4, Dropdown.clearMenus);
EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$2, function (event) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2681
2682
  event.preventDefault();
  event.stopPropagation();
XhmikosR's avatar
XhmikosR committed
2683
  Dropdown.dropdownInterface(this, 'toggle');
XhmikosR's avatar
Dist.  
XhmikosR committed
2684
});
XhmikosR's avatar
XhmikosR committed
2685
EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_FORM_CHILD, function (e) {
XhmikosR's avatar
XhmikosR committed
2686
2687
  return e.stopPropagation();
});
XhmikosR's avatar
XhmikosR committed
2688
var $$5 = getjQuery();
XhmikosR's avatar
Dist.  
XhmikosR committed
2689
2690
2691
2692
2693
2694
2695
/**
 * ------------------------------------------------------------------------
 * jQuery
 * ------------------------------------------------------------------------
 * add .dropdown to jQuery only if jQuery is present
 */

2696
2697
/* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
2698
2699
2700
2701
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
2702

XhmikosR's avatar
XhmikosR committed
2703
2704
2705
  $$5.fn[NAME$4].noConflict = function () {
    $$5.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
    return Dropdown.jQueryInterface;
XhmikosR's avatar
Dist.  
XhmikosR committed
2706
2707
2708
2709
2710
2711
2712
2713
2714
  };
}

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

XhmikosR's avatar
XhmikosR committed
2715
2716
2717
2718
2719
2720
var NAME$5 = 'modal';
var VERSION$5 = '4.3.1';
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
XhmikosR's avatar
Dist.  
XhmikosR committed
2721

XhmikosR's avatar
XhmikosR committed
2722
var Default$3 = {
XhmikosR's avatar
Dist.  
XhmikosR committed
2723
2724
2725
2726
2727
  backdrop: true,
  keyboard: true,
  focus: true,
  show: true
};
XhmikosR's avatar
XhmikosR committed
2728
var DefaultType$3 = {
XhmikosR's avatar
Dist.  
XhmikosR committed
2729
2730
2731
2732
2733
  backdrop: '(boolean|string)',
  keyboard: 'boolean',
  focus: 'boolean',
  show: 'boolean'
};
XhmikosR's avatar
XhmikosR committed
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
var EVENT_HIDE$2 = "hide" + EVENT_KEY$5;
var EVENT_HIDE_PREVENTED = "hidePrevented" + EVENT_KEY$5;
var EVENT_HIDDEN$2 = "hidden" + EVENT_KEY$5;
var EVENT_SHOW$2 = "show" + EVENT_KEY$5;
var EVENT_SHOWN$2 = "shown" + EVENT_KEY$5;
var EVENT_FOCUSIN = "focusin" + EVENT_KEY$5;
var EVENT_RESIZE = "resize" + EVENT_KEY$5;
var EVENT_CLICK_DISMISS = "click.dismiss" + EVENT_KEY$5;
var EVENT_KEYDOWN_DISMISS = "keydown.dismiss" + EVENT_KEY$5;
var EVENT_MOUSEUP_DISMISS = "mouseup.dismiss" + EVENT_KEY$5;
var EVENT_MOUSEDOWN_DISMISS = "mousedown.dismiss" + EVENT_KEY$5;
var EVENT_CLICK_DATA_API$5 = "click" + EVENT_KEY$5 + DATA_API_KEY$5;
var CLASS_NAME_SCROLLABLE = 'modal-dialog-scrollable';
var CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure';
var CLASS_NAME_BACKDROP = 'modal-backdrop';
var CLASS_NAME_OPEN = 'modal-open';
var CLASS_NAME_FADE = 'fade';
var CLASS_NAME_SHOW$2 = 'show';
var CLASS_NAME_STATIC = 'modal-static';
var SELECTOR_DIALOG = '.modal-dialog';
var SELECTOR_MODAL_BODY = '.modal-body';
var SELECTOR_DATA_TOGGLE$3 = '[data-toggle="modal"]';
var SELECTOR_DATA_DISMISS = '[data-dismiss="modal"]';
var SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
var SELECTOR_STICKY_CONTENT = '.sticky-top';
XhmikosR's avatar
XhmikosR committed
2759
2760
2761
2762
2763
/**
 * ------------------------------------------------------------------------
 * Class Definition
 * ------------------------------------------------------------------------
 */
XhmikosR's avatar
Dist.  
XhmikosR committed
2764

XhmikosR's avatar
XhmikosR committed
2765
var Modal = /*#__PURE__*/function () {
XhmikosR's avatar
XhmikosR committed
2766
  function Modal(element, config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2767
2768
    this._config = this._getConfig(config);
    this._element = element;
XhmikosR's avatar
XhmikosR committed
2769
    this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, element);
XhmikosR's avatar
Dist.  
XhmikosR committed
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
    this._backdrop = null;
    this._isShown = false;
    this._isBodyOverflowing = false;
    this._ignoreBackdropClick = false;
    this._isTransitioning = false;
    this._scrollbarWidth = 0;
    Data.setData(element, DATA_KEY$5, this);
  } // Getters


XhmikosR's avatar
XhmikosR committed
2780
  var _proto = Modal.prototype;
XhmikosR's avatar
Dist.  
XhmikosR committed
2781

XhmikosR's avatar
XhmikosR committed
2782
2783
  // Public
  _proto.toggle = function toggle(relatedTarget) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2784
    return this._isShown ? this.hide() : this.show(relatedTarget);
XhmikosR's avatar
XhmikosR committed
2785
2786
2787
2788
  };

  _proto.show = function show(relatedTarget) {
    var _this = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
2789
2790
2791
2792
2793

    if (this._isShown || this._isTransitioning) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
2794
    if (this._element.classList.contains(CLASS_NAME_FADE)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2795
2796
2797
      this._isTransitioning = true;
    }

XhmikosR's avatar
XhmikosR committed
2798
    var showEvent = EventHandler.trigger(this._element, EVENT_SHOW$2, {
XhmikosR's avatar
XhmikosR committed
2799
      relatedTarget: relatedTarget
XhmikosR's avatar
Dist.  
XhmikosR committed
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
    });

    if (this._isShown || showEvent.defaultPrevented) {
      return;
    }

    this._isShown = true;

    this._checkScrollbar();

    this._setScrollbar();

    this._adjustDialog();

    this._setEscapeEvent();

    this._setResizeEvent();

XhmikosR's avatar
XhmikosR committed
2818
    EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function (event) {
XhmikosR's avatar
XhmikosR committed
2819
2820
      return _this.hide(event);
    });
XhmikosR's avatar
XhmikosR committed
2821
2822
    EventHandler.on(this._dialog, EVENT_MOUSEDOWN_DISMISS, function () {
      EventHandler.one(_this._element, EVENT_MOUSEUP_DISMISS, function (event) {
XhmikosR's avatar
XhmikosR committed
2823
2824
        if (event.target === _this._element) {
          _this._ignoreBackdropClick = true;
XhmikosR's avatar
Dist.  
XhmikosR committed
2825
2826
2827
2828
        }
      });
    });

XhmikosR's avatar
XhmikosR committed
2829
2830
2831
2832
2833
2834
2835
    this._showBackdrop(function () {
      return _this._showElement(relatedTarget);
    });
  };

  _proto.hide = function hide(event) {
    var _this2 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
2836
2837
2838
2839
2840
2841
2842
2843
2844

    if (event) {
      event.preventDefault();
    }

    if (!this._isShown || this._isTransitioning) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
2845
    var hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$2);
XhmikosR's avatar
Dist.  
XhmikosR committed
2846

2847
    if (hideEvent.defaultPrevented) {
XhmikosR's avatar
Dist.  
XhmikosR committed
2848
2849
2850
2851
2852
      return;
    }

    this._isShown = false;

XhmikosR's avatar
XhmikosR committed
2853
    var transition = this._element.classList.contains(CLASS_NAME_FADE);
XhmikosR's avatar
Dist.  
XhmikosR committed
2854
2855
2856
2857
2858
2859
2860
2861
2862

    if (transition) {
      this._isTransitioning = true;
    }

    this._setEscapeEvent();

    this._setResizeEvent();

XhmikosR's avatar
XhmikosR committed
2863
    EventHandler.off(document, EVENT_FOCUSIN);
XhmikosR's avatar
Dist.  
XhmikosR committed
2864

XhmikosR's avatar
XhmikosR committed
2865
    this._element.classList.remove(CLASS_NAME_SHOW$2);
XhmikosR's avatar
Dist.  
XhmikosR committed
2866

XhmikosR's avatar
XhmikosR committed
2867
2868
    EventHandler.off(this._element, EVENT_CLICK_DISMISS);
    EventHandler.off(this._dialog, EVENT_MOUSEDOWN_DISMISS);
XhmikosR's avatar
Dist.  
XhmikosR committed
2869
2870

    if (transition) {
XhmikosR's avatar
XhmikosR committed
2871
2872
2873
2874
      var transitionDuration = getTransitionDurationFromElement(this._element);
      EventHandler.one(this._element, TRANSITION_END, function (event) {
        return _this2._hideModal(event);
      });
XhmikosR's avatar
Dist.  
XhmikosR committed
2875
2876
2877
2878
      emulateTransitionEnd(this._element, transitionDuration);
    } else {
      this._hideModal();
    }
XhmikosR's avatar
XhmikosR committed
2879
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2880

XhmikosR's avatar
XhmikosR committed
2881
2882
2883
2884
  _proto.dispose = function dispose() {
    [window, this._element, this._dialog].forEach(function (htmlElement) {
      return EventHandler.off(htmlElement, EVENT_KEY$5);
    });
XhmikosR's avatar
Dist.  
XhmikosR committed
2885
    /**
XhmikosR's avatar
XhmikosR committed
2886
     * `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API`
XhmikosR's avatar
Dist.  
XhmikosR committed
2887
     * Do not move `document` in `htmlElements` array
XhmikosR's avatar
XhmikosR committed
2888
     * It will remove `EVENT_CLICK_DATA_API` event that should remain
XhmikosR's avatar
Dist.  
XhmikosR committed
2889
2890
     */

XhmikosR's avatar
XhmikosR committed
2891
    EventHandler.off(document, EVENT_FOCUSIN);
XhmikosR's avatar
Dist.  
XhmikosR committed
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
    Data.removeData(this._element, DATA_KEY$5);
    this._config = null;
    this._element = null;
    this._dialog = null;
    this._backdrop = null;
    this._isShown = null;
    this._isBodyOverflowing = null;
    this._ignoreBackdropClick = null;
    this._isTransitioning = null;
    this._scrollbarWidth = null;
XhmikosR's avatar
XhmikosR committed
2902
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
2903

XhmikosR's avatar
XhmikosR committed
2904
  _proto.handleUpdate = function handleUpdate() {
XhmikosR's avatar
Dist.  
XhmikosR committed
2905
2906
    this._adjustDialog();
  } // Private
XhmikosR's avatar
XhmikosR committed
2907
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
2908

XhmikosR's avatar
XhmikosR committed
2909
  _proto._getConfig = function _getConfig(config) {
2910
    config = _objectSpread2({}, Default$3, {}, config);
XhmikosR's avatar
Dist.  
XhmikosR committed
2911
2912
    typeCheckConfig(NAME$5, config, DefaultType$3);
    return config;
XhmikosR's avatar
XhmikosR committed
2913
2914
2915
2916
  };

  _proto._showElement = function _showElement(relatedTarget) {
    var _this3 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
2917

XhmikosR's avatar
XhmikosR committed
2918
    var transition = this._element.classList.contains(CLASS_NAME_FADE);
XhmikosR's avatar
Dist.  
XhmikosR committed
2919

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

XhmikosR's avatar
Dist.  
XhmikosR committed
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
    if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
      // Don't move modal's DOM position
      document.body.appendChild(this._element);
    }

    this._element.style.display = 'block';

    this._element.removeAttribute('aria-hidden');

    this._element.setAttribute('aria-modal', true);

XhmikosR's avatar
XhmikosR committed
2933
    if (this._dialog.classList.contains(CLASS_NAME_SCROLLABLE) && modalBody) {
XhmikosR's avatar
XhmikosR committed
2934
      modalBody.scrollTop = 0;
XhmikosR's avatar
Dist.  
XhmikosR committed
2935
2936
2937
2938
2939
2940
2941
2942
    } else {
      this._element.scrollTop = 0;
    }

    if (transition) {
      reflow(this._element);
    }

XhmikosR's avatar
XhmikosR committed
2943
    this._element.classList.add(CLASS_NAME_SHOW$2);
XhmikosR's avatar
Dist.  
XhmikosR committed
2944
2945
2946
2947
2948

    if (this._config.focus) {
      this._enforceFocus();
    }

XhmikosR's avatar
XhmikosR committed
2949
2950
2951
    var transitionComplete = function transitionComplete() {
      if (_this3._config.focus) {
        _this3._element.focus();
XhmikosR's avatar
Dist.  
XhmikosR committed
2952
2953
      }

XhmikosR's avatar
XhmikosR committed
2954
      _this3._isTransitioning = false;
XhmikosR's avatar
XhmikosR committed
2955
      EventHandler.trigger(_this3._element, EVENT_SHOWN$2, {
XhmikosR's avatar
XhmikosR committed
2956
        relatedTarget: relatedTarget
XhmikosR's avatar
Dist.  
XhmikosR committed
2957
2958
2959
2960
      });
    };

    if (transition) {
XhmikosR's avatar
XhmikosR committed
2961
      var transitionDuration = getTransitionDurationFromElement(this._dialog);
XhmikosR's avatar
Dist.  
XhmikosR committed
2962
2963
2964
2965
2966
      EventHandler.one(this._dialog, TRANSITION_END, transitionComplete);
      emulateTransitionEnd(this._dialog, transitionDuration);
    } else {
      transitionComplete();
    }
XhmikosR's avatar
XhmikosR committed
2967
2968
2969
2970
  };

  _proto._enforceFocus = function _enforceFocus() {
    var _this4 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
2971

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

XhmikosR's avatar
XhmikosR committed
2974
    EventHandler.on(document, EVENT_FOCUSIN, function (event) {
XhmikosR's avatar
XhmikosR committed
2975
2976
      if (document !== event.target && _this4._element !== event.target && !_this4._element.contains(event.target)) {
        _this4._element.focus();
XhmikosR's avatar
Dist.  
XhmikosR committed
2977
2978
      }
    });
XhmikosR's avatar
XhmikosR committed
2979
2980
2981
2982
  };

  _proto._setEscapeEvent = function _setEscapeEvent() {
    var _this5 = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
2983

XhmikosR's avatar
XhmikosR committed
2984
2985
2986
2987
2988
2989
2990
    if (this._isShown) {
      EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, function (event) {
        if (_this5._config.keyboard && event.which === ESCAPE_KEYCODE$1) {
          event.preventDefault();

          _this5.hide();
        } else if (!_this5._config.keyboard && event.which === ESCAPE_KEYCODE$1) {
XhmikosR's avatar
XhmikosR committed
2991
          _this5._triggerBackdropTransition();
XhmikosR's avatar
Dist.  
XhmikosR committed
2992
2993
        }
      });
2994
    } else {
XhmikosR's avatar
XhmikosR committed
2995
      EventHandler.off(this._element, EVENT_KEYDOWN_DISMISS);
XhmikosR's avatar
Dist.  
XhmikosR committed
2996
    }
XhmikosR's avatar
XhmikosR committed
2997
2998
2999
3000
  };

  _proto._setResizeEvent = function _setResizeEvent() {
    var _this6 = this;
For faster browsing, not all history is shown. View entire blame