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

XhmikosR's avatar
Dist    
XhmikosR committed
2004
2005
2006
2007
2008
2009
2010
    return Collapse;
  }();
  /**
   * ------------------------------------------------------------------------
   * Data Api implementation
   * ------------------------------------------------------------------------
   */
Mark Otto's avatar
dist    
Mark Otto committed
2011

Mark Otto's avatar
dist  
Mark Otto committed
2012

XhmikosR's avatar
XhmikosR committed
2013
  EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$1, function (event) {
XhmikosR's avatar
Dist    
XhmikosR committed
2014
    // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
XhmikosR's avatar
XhmikosR committed
2015
    if (event.target.tagName === 'A') {
XhmikosR's avatar
Dist    
XhmikosR committed
2016
2017
      event.preventDefault();
    }
Mark Otto's avatar
dist    
Mark Otto committed
2018

XhmikosR's avatar
XhmikosR committed
2019
2020
    var triggerData = Manipulator.getDataAttributes(this);
    var selector = getSelectorFromElement(this);
XhmikosR's avatar
XhmikosR committed
2021
    var selectorElements = SelectorEngine.find(selector);
XhmikosR's avatar
XhmikosR committed
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
    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
2037

XhmikosR's avatar
XhmikosR committed
2038
      Collapse.collapseInterface(element, config);
XhmikosR's avatar
Dist    
XhmikosR committed
2039
2040
    });
  });
XhmikosR's avatar
XhmikosR committed
2041
  var $$4 = getjQuery();
XhmikosR's avatar
Dist    
XhmikosR committed
2042
2043
2044
2045
  /**
   * ------------------------------------------------------------------------
   * jQuery
   * ------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
2046
   * add .collapse to jQuery only if jQuery is present
XhmikosR's avatar
Dist    
XhmikosR committed
2047
   */
Mark Otto's avatar
dist    
Mark Otto committed
2048

2049
2050
  /* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
2051
2052
2053
2054
  if ($$4) {
    var JQUERY_NO_CONFLICT$3 = $$4.fn[NAME$3];
    $$4.fn[NAME$3] = Collapse.jQueryInterface;
    $$4.fn[NAME$3].Constructor = Collapse;
Mark Otto's avatar
dist  
Mark Otto committed
2055

XhmikosR's avatar
XhmikosR committed
2056
2057
2058
    $$4.fn[NAME$3].noConflict = function () {
      $$4.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
      return Collapse.jQueryInterface;
XhmikosR's avatar
XhmikosR committed
2059
2060
    };
  }
Mark Otto's avatar
dist  
Mark Otto committed
2061

Mark Otto's avatar
dist    
Mark Otto committed
2062
2063
  /**!
   * @fileOverview Kickass library to create and place poppers near their reference elements.
XhmikosR's avatar
XhmikosR committed
2064
   * @version 1.16.1
Mark Otto's avatar
dist    
Mark Otto committed
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
   * @license
   * Copyright (c) 2016 Federico Zivolo and contributors
   *
   * Permission is hereby granted, free of charge, to any person obtaining a copy
   * of this software and associated documentation files (the "Software"), to deal
   * in the Software without restriction, including without limitation the rights
   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   * copies of the Software, and to permit persons to whom the Software is
   * furnished to do so, subject to the following conditions:
   *
   * The above copyright notice and this permission notice shall be included in all
   * copies or substantial portions of the Software.
   *
   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   * SOFTWARE.
   */
XhmikosR's avatar
XhmikosR committed
2086
2087
2088
2089
2090
2091
2092
2093
  var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';

  var timeoutDuration = function () {
    var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
    for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
      if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
        return 1;
      }
Mark Otto's avatar
dist  
Mark Otto committed
2094
    }
XhmikosR's avatar
XhmikosR committed
2095
2096
    return 0;
  }();
Mark Otto's avatar
dist  
Mark Otto committed
2097

Mark Otto's avatar
dist    
Mark Otto committed
2098
2099
2100
2101
2102
2103
2104
2105
2106
  function microtaskDebounce(fn) {
    var called = false;
    return function () {
      if (called) {
        return;
      }
      called = true;
      window.Promise.resolve().then(function () {
        called = false;
Mark Otto's avatar
dist  
Mark Otto committed
2107
        fn();
Mark Otto's avatar
dist    
Mark Otto committed
2108
2109
      });
    };
Mark Otto's avatar
dist  
Mark Otto committed
2110
2111
  }

Mark Otto's avatar
dist    
Mark Otto committed
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
  function taskDebounce(fn) {
    var scheduled = false;
    return function () {
      if (!scheduled) {
        scheduled = true;
        setTimeout(function () {
          scheduled = false;
          fn();
        }, timeoutDuration);
      }
    };
Mark Otto's avatar
dist    
Mark Otto committed
2123
2124
  }

Mark Otto's avatar
dist    
Mark Otto committed
2125
  var supportsMicroTasks = isBrowser && window.Promise;
Mark Otto's avatar
dist  
Mark Otto committed
2126

Mark Otto's avatar
dist    
Mark Otto committed
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
  /**
  * Create a debounced version of a method, that's asynchronously deferred
  * but called in the minimum time possible.
  *
  * @method
  * @memberof Popper.Utils
  * @argument {Function} fn
  * @returns {Function}
  */
  var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
Mark Otto's avatar
dist  
Mark Otto committed
2137

Mark Otto's avatar
dist    
Mark Otto committed
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
  /**
   * Check if the given variable is a function
   * @method
   * @memberof Popper.Utils
   * @argument {Any} functionToCheck - variable to check
   * @returns {Boolean} answer to: is a function?
   */
  function isFunction(functionToCheck) {
    var getType = {};
    return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
Mark Otto's avatar
dist  
Mark Otto committed
2148
2149
  }

Mark Otto's avatar
dist    
Mark Otto committed
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
  /**
   * Get CSS computed property of the given element
   * @method
   * @memberof Popper.Utils
   * @argument {Eement} element
   * @argument {String} property
   */
  function getStyleComputedProperty(element, property) {
    if (element.nodeType !== 1) {
      return [];
Mark Otto's avatar
dist    
Mark Otto committed
2160
    }
Mark Otto's avatar
dist    
Mark Otto committed
2161
    // NOTE: 1 DOM access here
XhmikosR's avatar
Dist    
XhmikosR committed
2162
2163
    var window = element.ownerDocument.defaultView;
    var css = window.getComputedStyle(element, null);
Mark Otto's avatar
dist    
Mark Otto committed
2164
    return property ? css[property] : css;
Mark Otto's avatar
dist  
Mark Otto committed
2165
2166
  }

Mark Otto's avatar
dist    
Mark Otto committed
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
  /**
   * Returns the parentNode or the host of the element
   * @method
   * @memberof Popper.Utils
   * @argument {Element} element
   * @returns {Element} parent
   */
  function getParentNode(element) {
    if (element.nodeName === 'HTML') {
      return element;
    }
    return element.parentNode || element.host;
Mark Otto's avatar
dist  
Mark Otto committed
2179
2180
  }

Mark Otto's avatar
dist    
Mark Otto committed
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
  /**
   * Returns the scrolling parent of the given element
   * @method
   * @memberof Popper.Utils
   * @argument {Element} element
   * @returns {Element} scroll parent
   */
  function getScrollParent(element) {
    // Return body, `getScroll` will take care to get the correct `scrollTop` from it
    if (!element) {
      return document.body;
    }
Mark Otto's avatar
dist  
Mark Otto committed
2193

Mark Otto's avatar
dist    
Mark Otto committed
2194
2195
2196
2197
2198
2199
2200
    switch (element.nodeName) {
      case 'HTML':
      case 'BODY':
        return element.ownerDocument.body;
      case '#document':
        return element.body;
    }
Mark Otto's avatar
dist  
Mark Otto committed
2201

Mark Otto's avatar
dist    
Mark Otto committed
2202
    // Firefox want us to check `-x` and `-y` variations as well
Mark Otto's avatar
dist  
Mark Otto committed
2203

Mark Otto's avatar
dist    
Mark Otto committed
2204
2205
2206
2207
    var _getStyleComputedProp = getStyleComputedProperty(element),
        overflow = _getStyleComputedProp.overflow,
        overflowX = _getStyleComputedProp.overflowX,
        overflowY = _getStyleComputedProp.overflowY;
Mark Otto's avatar
dist  
Mark Otto committed
2208

Mark Otto's avatar
dist    
Mark Otto committed
2209
2210
    if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
      return element;
Mark Otto's avatar
dist  
Mark Otto committed
2211
2212
    }

Mark Otto's avatar
dist    
Mark Otto committed
2213
    return getScrollParent(getParentNode(element));
Mark Otto's avatar
dist  
Mark Otto committed
2214
2215
  }

XhmikosR's avatar
XhmikosR committed
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
  /**
   * Returns the reference node of the reference object, or the reference object itself.
   * @method
   * @memberof Popper.Utils
   * @param {Element|Object} reference - the reference element (the popper will be relative to this)
   * @returns {Element} parent
   */
  function getReferenceNode(reference) {
    return reference && reference.referenceNode ? reference.referenceNode : reference;
  }

Mark Otto's avatar
dist    
Mark Otto committed
2227
2228
2229
  var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);

Mark Otto's avatar
dist    
Mark Otto committed
2230
  /**
Mark Otto's avatar
dist    
Mark Otto committed
2231
   * Determines if the browser is Internet Explorer
Mark Otto's avatar
dist    
Mark Otto committed
2232
2233
   * @method
   * @memberof Popper.Utils
Mark Otto's avatar
dist    
Mark Otto committed
2234
   * @param {Number} version to check
Mark Otto's avatar
dist    
Mark Otto committed
2235
2236
   * @returns {Boolean} isIE
   */
Mark Otto's avatar
dist    
Mark Otto committed
2237
2238
2239
  function isIE(version) {
    if (version === 11) {
      return isIE11;
Mark Otto's avatar
dist    
Mark Otto committed
2240
    }
Mark Otto's avatar
dist    
Mark Otto committed
2241
2242
    if (version === 10) {
      return isIE10;
Mark Otto's avatar
dist    
Mark Otto committed
2243
    }
Mark Otto's avatar
dist    
Mark Otto committed
2244
2245
    return isIE11 || isIE10;
  }
Mark Otto's avatar
dist  
Mark Otto committed
2246

Mark Otto's avatar
dist    
Mark Otto committed
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
  /**
   * Returns the offset parent of the given element
   * @method
   * @memberof Popper.Utils
   * @argument {Element} element
   * @returns {Element} offset parent
   */
  function getOffsetParent(element) {
    if (!element) {
      return document.documentElement;
Mark Otto's avatar
dist  
Mark Otto committed
2257
2258
    }

Mark Otto's avatar
dist    
Mark Otto committed
2259
    var noOffsetParent = isIE(10) ? document.body : null;
Mark Otto's avatar
dist  
Mark Otto committed
2260

Mark Otto's avatar
dist    
Mark Otto committed
2261
    // NOTE: 1 DOM access here
XhmikosR's avatar
Dist    
XhmikosR committed
2262
    var offsetParent = element.offsetParent || null;
Mark Otto's avatar
dist    
Mark Otto committed
2263
2264
2265
2266
    // Skip hidden elements which don't have an offsetParent
    while (offsetParent === noOffsetParent && element.nextElementSibling) {
      offsetParent = (element = element.nextElementSibling).offsetParent;
    }
Mark Otto's avatar
dist  
Mark Otto committed
2267

Mark Otto's avatar
dist    
Mark Otto committed
2268
    var nodeName = offsetParent && offsetParent.nodeName;
Mark Otto's avatar
dist  
Mark Otto committed
2269

Mark Otto's avatar
dist    
Mark Otto committed
2270
2271
2272
    if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
      return element ? element.ownerDocument.documentElement : document.documentElement;
    }
Mark Otto's avatar
dist  
Mark Otto committed
2273

XhmikosR's avatar
Dist    
XhmikosR committed
2274
    // .offsetParent will return the closest TH, TD or TABLE in case
Mark Otto's avatar
dist    
Mark Otto committed
2275
    // no offsetParent is present, I hate this job...
XhmikosR's avatar
Dist    
XhmikosR committed
2276
    if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
Mark Otto's avatar
dist    
Mark Otto committed
2277
2278
      return getOffsetParent(offsetParent);
    }
Mark Otto's avatar
dist  
Mark Otto committed
2279

Mark Otto's avatar
dist    
Mark Otto committed
2280
    return offsetParent;
Mark Otto's avatar
dist  
Mark Otto committed
2281
2282
  }

Mark Otto's avatar
dist    
Mark Otto committed
2283
2284
  function isOffsetContainer(element) {
    var nodeName = element.nodeName;
Mark Otto's avatar
dist  
Mark Otto committed
2285

Mark Otto's avatar
dist    
Mark Otto committed
2286
2287
    if (nodeName === 'BODY') {
      return false;
Mark Otto's avatar
dist  
Mark Otto committed
2288
    }
Mark Otto's avatar
dist    
Mark Otto committed
2289
    return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
Mark Otto's avatar
dist  
Mark Otto committed
2290
2291
  }

Mark Otto's avatar
dist    
Mark Otto committed
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
  /**
   * Finds the root node (document, shadowDOM root) of the given element
   * @method
   * @memberof Popper.Utils
   * @argument {Element} node
   * @returns {Element} root node
   */
  function getRoot(node) {
    if (node.parentNode !== null) {
      return getRoot(node.parentNode);
    }
Mark Otto's avatar
dist  
Mark Otto committed
2303

Mark Otto's avatar
dist    
Mark Otto committed
2304
    return node;
Mark Otto's avatar
dist  
Mark Otto committed
2305
2306
  }

Mark Otto's avatar
dist    
Mark Otto committed
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
  /**
   * Finds the offset parent common to the two provided nodes
   * @method
   * @memberof Popper.Utils
   * @argument {Element} element1
   * @argument {Element} element2
   * @returns {Element} common offset parent
   */
  function findCommonOffsetParent(element1, element2) {
    // This check is needed to avoid errors in case one of the elements isn't defined for any reason
    if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
      return document.documentElement;
    }
Mark Otto's avatar
dist  
Mark Otto committed
2320

Mark Otto's avatar
dist    
Mark Otto committed
2321
2322
2323
2324
    // Here we make sure to give as "start" the element that comes first in the DOM
    var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
    var start = order ? element1 : element2;
    var end = order ? element2 : element1;
Mark Otto's avatar
dist  
Mark Otto committed
2325

Mark Otto's avatar
dist    
Mark Otto committed
2326
2327
2328
2329
2330
    // Get common ancestor container
    var range = document.createRange();
    range.setStart(start, 0);
    range.setEnd(end, 0);
    var commonAncestorContainer = range.commonAncestorContainer;
Mark Otto's avatar
dist  
Mark Otto committed
2331

Mark Otto's avatar
dist    
Mark Otto committed
2332
    // Both nodes are inside #document
Mark Otto's avatar
dist  
Mark Otto committed
2333

Mark Otto's avatar
dist    
Mark Otto committed
2334
2335
2336
2337
    if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
      if (isOffsetContainer(commonAncestorContainer)) {
        return commonAncestorContainer;
      }
Mark Otto's avatar
dist  
Mark Otto committed
2338

Mark Otto's avatar
dist    
Mark Otto committed
2339
2340
      return getOffsetParent(commonAncestorContainer);
    }
Mark Otto's avatar
dist  
Mark Otto committed
2341

Mark Otto's avatar
dist    
Mark Otto committed
2342
2343
2344
2345
    // one of the nodes is inside shadowDOM, find which one
    var element1root = getRoot(element1);
    if (element1root.host) {
      return findCommonOffsetParent(element1root.host, element2);
Mark Otto's avatar
dist  
Mark Otto committed
2346
    } else {
Mark Otto's avatar
dist    
Mark Otto committed
2347
      return findCommonOffsetParent(element1, getRoot(element2).host);
Mark Otto's avatar
dist  
Mark Otto committed
2348
    }
Mark Otto's avatar
dist    
Mark Otto committed
2349
  }
Mark Otto's avatar
dist  
Mark Otto committed
2350

Mark Otto's avatar
dist    
Mark Otto committed
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
  /**
   * Gets the scroll value of the given element in the given side (top and left)
   * @method
   * @memberof Popper.Utils
   * @argument {Element} element
   * @argument {String} side `top` or `left`
   * @returns {number} amount of scrolled pixels
   */
  function getScroll(element) {
    var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
Mark Otto's avatar
dist  
Mark Otto committed
2361

Mark Otto's avatar
dist    
Mark Otto committed
2362
2363
    var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
    var nodeName = element.nodeName;
Mark Otto's avatar
dist  
Mark Otto committed
2364

Mark Otto's avatar
dist    
Mark Otto committed
2365
2366
2367
2368
    if (nodeName === 'BODY' || nodeName === 'HTML') {
      var html = element.ownerDocument.documentElement;
      var scrollingElement = element.ownerDocument.scrollingElement || html;
      return scrollingElement[upperSide];
Mark Otto's avatar
dist  
Mark Otto committed
2369
2370
    }

Mark Otto's avatar
dist    
Mark Otto committed
2371
    return element[upperSide];
Mark Otto's avatar
dist  
Mark Otto committed
2372
2373
  }

Mark Otto's avatar
dist    
Mark Otto committed
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
  /*
   * Sum or subtract the element scroll values (left and top) from a given rect object
   * @method
   * @memberof Popper.Utils
   * @param {Object} rect - Rect object you want to change
   * @param {HTMLElement} element - The element from the function reads the scroll values
   * @param {Boolean} subtract - set to true if you want to subtract the scroll values
   * @return {Object} rect - The modifier rect object
   */
  function includeScroll(rect, element) {
    var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

    var scrollTop = getScroll(element, 'top');
    var scrollLeft = getScroll(element, 'left');
    var modifier = subtract ? -1 : 1;
    rect.top += scrollTop * modifier;
    rect.bottom += scrollTop * modifier;
    rect.left += scrollLeft * modifier;
    rect.right += scrollLeft * modifier;
    return rect;
  }
Mark Otto's avatar
dist  
Mark Otto committed
2395

Mark Otto's avatar
dist    
Mark Otto committed
2396
2397
2398
2399
2400
2401
2402
2403
2404
  /*
   * Helper to detect borders of a given element
   * @method
   * @memberof Popper.Utils
   * @param {CSSStyleDeclaration} styles
   * Result of `getStyleComputedProperty` on the given element
   * @param {String} axis - `x` or `y`
   * @return {number} borders - The borders size of the given axis
   */
Mark Otto's avatar
dist  
Mark Otto committed
2405

Mark Otto's avatar
dist    
Mark Otto committed
2406
2407
2408
  function getBordersSize(styles, axis) {
    var sideA = axis === 'x' ? 'Left' : 'Top';
    var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
Mark Otto's avatar
dist  
Mark Otto committed
2409

XhmikosR's avatar
XhmikosR committed
2410
    return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
Mark Otto's avatar
dist  
Mark Otto committed
2411
2412
  }

Mark Otto's avatar
dist    
Mark Otto committed
2413
  function getSize(axis, body, html, computedStyle) {
Mark Otto's avatar
dist    
Mark Otto committed
2414
    return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0);
Mark Otto's avatar
dist  
Mark Otto committed
2415
2416
  }

Mark Otto's avatar
dist    
Mark Otto committed
2417
  function getWindowSizes(document) {
Mark Otto's avatar
dist    
Mark Otto committed
2418
2419
2420
    var body = document.body;
    var html = document.documentElement;
    var computedStyle = isIE(10) && getComputedStyle(html);
Mark Otto's avatar
dist  
Mark Otto committed
2421

Mark Otto's avatar
dist    
Mark Otto committed
2422
2423
2424
2425
    return {
      height: getSize('Height', body, html, computedStyle),
      width: getSize('Width', body, html, computedStyle)
    };
Mark Otto's avatar
dist  
Mark Otto committed
2426
2427
  }

Mark Otto's avatar
dist    
Mark Otto committed
2428
2429
2430
2431
  var classCallCheck = function (instance, Constructor) {
    if (!(instance instanceof Constructor)) {
      throw new TypeError("Cannot call a class as a function");
    }
Mark Otto's avatar
dist  
Mark Otto committed
2432
2433
  };

Mark Otto's avatar
dist    
Mark Otto committed
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
  var createClass = function () {
    function defineProperties(target, props) {
      for (var i = 0; i < props.length; i++) {
        var descriptor = props[i];
        descriptor.enumerable = descriptor.enumerable || false;
        descriptor.configurable = true;
        if ("value" in descriptor) descriptor.writable = true;
        Object.defineProperty(target, descriptor.key, descriptor);
      }
    }
Mark Otto's avatar
dist  
Mark Otto committed
2444

Mark Otto's avatar
dist    
Mark Otto committed
2445
2446
2447
2448
2449
2450
    return function (Constructor, protoProps, staticProps) {
      if (protoProps) defineProperties(Constructor.prototype, protoProps);
      if (staticProps) defineProperties(Constructor, staticProps);
      return Constructor;
    };
  }();
Mark Otto's avatar
dist  
Mark Otto committed
2451
2452
2453
2454
2455





Mark Otto's avatar
dist    
Mark Otto committed
2456
2457
2458
2459
2460
2461
2462
2463
  var defineProperty = function (obj, key, value) {
    if (key in obj) {
      Object.defineProperty(obj, key, {
        value: value,
        enumerable: true,
        configurable: true,
        writable: true
      });
Mark Otto's avatar
dist  
Mark Otto committed
2464
    } else {
Mark Otto's avatar
dist    
Mark Otto committed
2465
      obj[key] = value;
Mark Otto's avatar
dist  
Mark Otto committed
2466
2467
    }

Mark Otto's avatar
dist    
Mark Otto committed
2468
2469
    return obj;
  };
Mark Otto's avatar
dist  
Mark Otto committed
2470

XhmikosR's avatar
XhmikosR committed
2471
  var _extends$1 = Object.assign || function (target) {
Mark Otto's avatar
dist    
Mark Otto committed
2472
2473
    for (var i = 1; i < arguments.length; i++) {
      var source = arguments[i];
Mark Otto's avatar
dist  
Mark Otto committed
2474

Mark Otto's avatar
dist    
Mark Otto committed
2475
2476
2477
2478
2479
2480
      for (var key in source) {
        if (Object.prototype.hasOwnProperty.call(source, key)) {
          target[key] = source[key];
        }
      }
    }
Mark Otto's avatar
dist  
Mark Otto committed
2481

Mark Otto's avatar
dist    
Mark Otto committed
2482
    return target;
Mark Otto's avatar
dist  
Mark Otto committed
2483
2484
  };

Mark Otto's avatar
dist    
Mark Otto committed
2485
2486
2487
2488
2489
2490
2491
2492
  /**
   * Given element offsets, generate an output similar to getBoundingClientRect
   * @method
   * @memberof Popper.Utils
   * @argument {Object} offsets
   * @returns {Object} ClientRect like output
   */
  function getClientRect(offsets) {
XhmikosR's avatar
XhmikosR committed
2493
    return _extends$1({}, offsets, {
Mark Otto's avatar
dist    
Mark Otto committed
2494
2495
2496
      right: offsets.left + offsets.width,
      bottom: offsets.top + offsets.height
    });
Mark Otto's avatar
dist  
Mark Otto committed
2497
2498
  }

Mark Otto's avatar
dist    
Mark Otto committed
2499
2500
2501
2502
2503
2504
2505
2506
2507
  /**
   * Get bounding client rect of given element
   * @method
   * @memberof Popper.Utils
   * @param {HTMLElement} element
   * @return {Object} client rect
   */
  function getBoundingClientRect(element) {
    var rect = {};
Mark Otto's avatar
dist  
Mark Otto committed
2508

Mark Otto's avatar
dist    
Mark Otto committed
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
    // IE10 10 FIX: Please, don't ask, the element isn't
    // considered in DOM in some circumstances...
    // This isn't reproducible in IE10 compatibility mode of IE11
    try {
      if (isIE(10)) {
        rect = element.getBoundingClientRect();
        var scrollTop = getScroll(element, 'top');
        var scrollLeft = getScroll(element, 'left');
        rect.top += scrollTop;
        rect.left += scrollLeft;
        rect.bottom += scrollTop;
        rect.right += scrollLeft;
      } else {
        rect = element.getBoundingClientRect();
      }
    } catch (e) {}

    var result = {
      left: rect.left,
      top: rect.top,
      width: rect.right - rect.left,
      height: rect.bottom - rect.top
    };
Mark Otto's avatar
dist  
Mark Otto committed
2532

Mark Otto's avatar
dist    
Mark Otto committed
2533
    // subtract scrollbar size from sizes
Mark Otto's avatar
dist    
Mark Otto committed
2534
    var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
XhmikosR's avatar
XhmikosR committed
2535
2536
    var width = sizes.width || element.clientWidth || result.width;
    var height = sizes.height || element.clientHeight || result.height;
Mark Otto's avatar
dist  
Mark Otto committed
2537

Mark Otto's avatar
dist    
Mark Otto committed
2538
2539
    var horizScrollbar = element.offsetWidth - width;
    var vertScrollbar = element.offsetHeight - height;
Mark Otto's avatar
dist  
Mark Otto committed
2540

Mark Otto's avatar
dist    
Mark Otto committed
2541
2542
2543
2544
2545
2546
2547
2548
2549
    // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
    // we make this check conditional for performance reasons
    if (horizScrollbar || vertScrollbar) {
      var styles = getStyleComputedProperty(element);
      horizScrollbar -= getBordersSize(styles, 'x');
      vertScrollbar -= getBordersSize(styles, 'y');

      result.width -= horizScrollbar;
      result.height -= vertScrollbar;
Mark Otto's avatar
dist  
Mark Otto committed
2550
    }
Mark Otto's avatar
dist    
Mark Otto committed
2551
2552

    return getClientRect(result);
Mark Otto's avatar
dist  
Mark Otto committed
2553
2554
  }

Mark Otto's avatar
dist    
Mark Otto committed
2555
2556
  function getOffsetRectRelativeToArbitraryNode(children, parent) {
    var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
Mark Otto's avatar
dist  
Mark Otto committed
2557

Mark Otto's avatar
dist    
Mark Otto committed
2558
2559
2560
2561
2562
    var isIE10 = isIE(10);
    var isHTML = parent.nodeName === 'HTML';
    var childrenRect = getBoundingClientRect(children);
    var parentRect = getBoundingClientRect(parent);
    var scrollParent = getScrollParent(children);
Mark Otto's avatar
dist  
Mark Otto committed
2563

Mark Otto's avatar
dist    
Mark Otto committed
2564
    var styles = getStyleComputedProperty(parent);
XhmikosR's avatar
XhmikosR committed
2565
2566
    var borderTopWidth = parseFloat(styles.borderTopWidth);
    var borderLeftWidth = parseFloat(styles.borderLeftWidth);
Mark Otto's avatar
dist  
Mark Otto committed
2567

Mark Otto's avatar
dist    
Mark Otto committed
2568
    // In cases where the parent is fixed, we must ignore negative scroll in offset calc
Mark Otto's avatar
dist    
Mark Otto committed
2569
    if (fixedPosition && isHTML) {
Mark Otto's avatar
dist    
Mark Otto committed
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
      parentRect.top = Math.max(parentRect.top, 0);
      parentRect.left = Math.max(parentRect.left, 0);
    }
    var offsets = getClientRect({
      top: childrenRect.top - parentRect.top - borderTopWidth,
      left: childrenRect.left - parentRect.left - borderLeftWidth,
      width: childrenRect.width,
      height: childrenRect.height
    });
    offsets.marginTop = 0;
    offsets.marginLeft = 0;

    // Subtract margins of documentElement in case it's being used as parent
    // we do this only on HTML because it's the only element that behaves
    // differently when margins are applied to it. The margins are included in
    // the box of the documentElement, in the other cases not.
    if (!isIE10 && isHTML) {
XhmikosR's avatar
XhmikosR committed
2587
2588
      var marginTop = parseFloat(styles.marginTop);
      var marginLeft = parseFloat(styles.marginLeft);
Mark Otto's avatar
dist    
Mark Otto committed
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598

      offsets.top -= borderTopWidth - marginTop;
      offsets.bottom -= borderTopWidth - marginTop;
      offsets.left -= borderLeftWidth - marginLeft;
      offsets.right -= borderLeftWidth - marginLeft;

      // Attach marginTop and marginLeft because in some circumstances we may need them
      offsets.marginTop = marginTop;
      offsets.marginLeft = marginLeft;
    }
Mark Otto's avatar
dist  
Mark Otto committed
2599

Mark Otto's avatar
dist    
Mark Otto committed
2600
2601
2602
    if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
      offsets = includeScroll(offsets, parent);
    }
Mark Otto's avatar
dist  
Mark Otto committed
2603

Mark Otto's avatar
dist    
Mark Otto committed
2604
    return offsets;
Mark Otto's avatar
dist  
Mark Otto committed
2605
2606
  }

Mark Otto's avatar
dist    
Mark Otto committed
2607
2608
  function getViewportOffsetRectRelativeToArtbitraryNode(element) {
    var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
Mark Otto's avatar
dist  
Mark Otto committed
2609

Mark Otto's avatar
dist    
Mark Otto committed
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
    var html = element.ownerDocument.documentElement;
    var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
    var width = Math.max(html.clientWidth, window.innerWidth || 0);
    var height = Math.max(html.clientHeight, window.innerHeight || 0);

    var scrollTop = !excludeScroll ? getScroll(html) : 0;
    var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;

    var offset = {
      top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
      left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
      width: width,
      height: height
    };
Mark Otto's avatar
dist  
Mark Otto committed
2624

Mark Otto's avatar
dist    
Mark Otto committed
2625
    return getClientRect(offset);
Mark Otto's avatar
dist  
Mark Otto committed
2626
2627
  }

Mark Otto's avatar
dist    
Mark Otto committed
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
  /**
   * Check if the given element is fixed or is inside a fixed parent
   * @method
   * @memberof Popper.Utils
   * @argument {Element} element
   * @argument {Element} customContainer
   * @returns {Boolean} answer to "isFixed?"
   */
  function isFixed(element) {
    var nodeName = element.nodeName;
    if (nodeName === 'BODY' || nodeName === 'HTML') {
      return false;
Mark Otto's avatar
dist  
Mark Otto committed
2640
    }
Mark Otto's avatar
dist    
Mark Otto committed
2641
2642
2643
    if (getStyleComputedProperty(element, 'position') === 'fixed') {
      return true;
    }
Mark Otto's avatar
Mark Otto committed
2644
2645
2646
2647
2648
    var parentNode = getParentNode(element);
    if (!parentNode) {
      return false;
    }
    return isFixed(parentNode);
Mark Otto's avatar
dist    
Mark Otto committed
2649
  }
Mark Otto's avatar
dist  
Mark Otto committed
2650

Mark Otto's avatar
dist    
Mark Otto committed
2651
2652
2653
2654
2655
2656
2657
  /**
   * Finds the first parent of an element that has a transformed property defined
   * @method
   * @memberof Popper.Utils
   * @argument {Element} element
   * @returns {Element} first transformed parent or documentElement
   */
Mark Otto's avatar
dist  
Mark Otto committed
2658

Mark Otto's avatar
dist    
Mark Otto committed
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
  function getFixedPositionOffsetParent(element) {
    // This check is needed to avoid errors in case one of the elements isn't defined for any reason
    if (!element || !element.parentElement || isIE()) {
      return document.documentElement;
    }
    var el = element.parentElement;
    while (el && getStyleComputedProperty(el, 'transform') === 'none') {
      el = el.parentElement;
    }
    return el || document.documentElement;
  }
Mark Otto's avatar
dist  
Mark Otto committed
2670

Mark Otto's avatar
dist    
Mark Otto committed
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
  /**
   * Computed the boundaries limits and return them
   * @method
   * @memberof Popper.Utils
   * @param {HTMLElement} popper
   * @param {HTMLElement} reference
   * @param {number} padding
   * @param {HTMLElement} boundariesElement - Element used to define the boundaries
   * @param {Boolean} fixedPosition - Is in fixed position mode
   * @returns {Object} Coordinates of the boundaries
   */
  function getBoundaries(popper, reference, padding, boundariesElement) {
    var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
Mark Otto's avatar
dist  
Mark Otto committed
2684

Mark Otto's avatar
dist    
Mark Otto committed
2685
    // NOTE: 1 DOM access here
Mark Otto's avatar
dist  
Mark Otto committed
2686

Mark Otto's avatar
dist    
Mark Otto committed
2687
    var boundaries = { top: 0, left: 0 };
XhmikosR's avatar
XhmikosR committed
2688
    var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
Mark Otto's avatar
dist  
Mark Otto committed
2689

Mark Otto's avatar
dist    
Mark Otto committed
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
    // Handle viewport case
    if (boundariesElement === 'viewport') {
      boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
    } else {
      // Handle other cases based on DOM element used as boundaries
      var boundariesNode = void 0;
      if (boundariesElement === 'scrollParent') {
        boundariesNode = getScrollParent(getParentNode(reference));
        if (boundariesNode.nodeName === 'BODY') {
          boundariesNode = popper.ownerDocument.documentElement;
        }
      } else if (boundariesElement === 'window') {
        boundariesNode = popper.ownerDocument.documentElement;
      } else {
        boundariesNode = boundariesElement;
      }
Mark Otto's avatar
dist  
Mark Otto committed
2706

Mark Otto's avatar
dist    
Mark Otto committed
2707
      var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
Mark Otto's avatar
dist  
Mark Otto committed
2708

Mark Otto's avatar
dist    
Mark Otto committed
2709
2710
      // In case of HTML, we need a different computation
      if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
Mark Otto's avatar
dist    
Mark Otto committed
2711
        var _getWindowSizes = getWindowSizes(popper.ownerDocument),
Mark Otto's avatar
dist    
Mark Otto committed
2712
2713
            height = _getWindowSizes.height,
            width = _getWindowSizes.width;
Mark Otto's avatar
dist  
Mark Otto committed
2714

Mark Otto's avatar
dist    
Mark Otto committed
2715
2716
2717
2718
2719
2720
2721
        boundaries.top += offsets.top - offsets.marginTop;
        boundaries.bottom = height + offsets.top;
        boundaries.left += offsets.left - offsets.marginLeft;
        boundaries.right = width + offsets.left;
      } else {
        // for all the other DOM elements, this one is good
        boundaries = offsets;
Mark Otto's avatar
dist  
Mark Otto committed
2722
      }
Mark Otto's avatar
dist    
Mark Otto committed
2723
    }
Mark Otto's avatar
dist  
Mark Otto committed
2724

Mark Otto's avatar
dist    
Mark Otto committed
2725
    // Add paddings
Mark Otto's avatar
dist    
Mark Otto committed
2726
2727
2728
2729
2730
2731
    padding = padding || 0;
    var isPaddingNumber = typeof padding === 'number';
    boundaries.left += isPaddingNumber ? padding : padding.left || 0;
    boundaries.top += isPaddingNumber ? padding : padding.top || 0;
    boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
    boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
Mark Otto's avatar
dist  
Mark Otto committed
2732

Mark Otto's avatar
dist    
Mark Otto committed
2733
    return boundaries;
Mark Otto's avatar
dist  
Mark Otto committed
2734
2735
  }

Mark Otto's avatar
dist    
Mark Otto committed
2736
2737
2738
2739
2740
  function getArea(_ref) {
    var width = _ref.width,
        height = _ref.height;

    return width * height;
Mark Otto's avatar
dist  
Mark Otto committed
2741
2742
  }

Mark Otto's avatar
dist    
Mark Otto committed
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
  /**
   * Utility used to transform the `auto` placement to the placement with more
   * available space.
   * @method
   * @memberof Popper.Utils
   * @argument {Object} data - The data object generated by update method
   * @argument {Object} options - Modifiers configuration and options
   * @returns {Object} The data object, properly modified
   */
  function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
    var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
Mark Otto's avatar
dist  
Mark Otto committed
2754

Mark Otto's avatar
dist    
Mark Otto committed
2755
2756
    if (placement.indexOf('auto') === -1) {
      return placement;
Mark Otto's avatar
dist  
Mark Otto committed
2757
2758
    }

Mark Otto's avatar
dist    
Mark Otto committed
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
    var boundaries = getBoundaries(popper, reference, padding, boundariesElement);

    var rects = {
      top: {
        width: boundaries.width,
        height: refRect.top - boundaries.top
      },
      right: {
        width: boundaries.right - refRect.right,
        height: boundaries.height
      },
      bottom: {
        width: boundaries.width,
        height: boundaries.bottom - refRect.bottom
      },
      left: {
        width: refRect.left - boundaries.left,
        height: boundaries.height
Mark Otto's avatar
dist  
Mark Otto committed
2777
      }
Mark Otto's avatar
dist    
Mark Otto committed
2778
2779
2780
    };

    var sortedAreas = Object.keys(rects).map(function (key) {
XhmikosR's avatar
XhmikosR committed
2781
      return _extends$1({
Mark Otto's avatar
dist    
Mark Otto committed
2782
2783
2784
2785
2786
2787
        key: key
      }, rects[key], {
        area: getArea(rects[key])
      });
    }).sort(function (a, b) {
      return b.area - a.area;
Mark Otto's avatar
dist  
Mark Otto committed
2788
2789
    });

Mark Otto's avatar
dist    
Mark Otto committed
2790
2791
2792
2793
    var filteredAreas = sortedAreas.filter(function (_ref2) {
      var width = _ref2.width,
          height = _ref2.height;
      return width >= popper.clientWidth && height >= popper.clientHeight;
Mark Otto's avatar
dist  
Mark Otto committed
2794
2795
    });

Mark Otto's avatar
dist    
Mark Otto committed
2796
2797
2798
    var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;

    var variation = placement.split('-')[1];
Mark Otto's avatar
dist  
Mark Otto committed
2799

Mark Otto's avatar
dist    
Mark Otto committed
2800
    return computedPlacement + (variation ? '-' + variation : '');
Mark Otto's avatar
dist  
Mark Otto committed
2801
2802
  }

Mark Otto's avatar
dist    
Mark Otto committed
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
  /**
   * Get offsets to the reference element
   * @method
   * @memberof Popper.Utils
   * @param {Object} state
   * @param {Element} popper - the popper element
   * @param {Element} reference - the reference element (the popper will be relative to this)
   * @param {Element} fixedPosition - is in fixed position mode
   * @returns {Object} An object containing the offsets which will be applied to the popper
   */
  function getReferenceOffsets(state, popper, reference) {
    var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
Mark Otto's avatar
dist  
Mark Otto committed
2815

XhmikosR's avatar
XhmikosR committed
2816
    var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
Mark Otto's avatar
dist    
Mark Otto committed
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
    return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  }

  /**
   * Get the outer sizes of the given element (offset size + margins)
   * @method
   * @memberof Popper.Utils
   * @argument {Element} element
   * @returns {Object} object containing width and height properties
   */
  function getOuterSizes(element) {
XhmikosR's avatar
Dist    
XhmikosR committed
2828
2829
    var window = element.ownerDocument.defaultView;
    var styles = window.getComputedStyle(element);
Mark Otto's avatar
dist    
Mark Otto committed
2830
2831
    var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
    var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
Mark Otto's avatar
dist    
Mark Otto committed
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
    var result = {
      width: element.offsetWidth + y,
      height: element.offsetHeight + x
    };
    return result;
  }

  /**
   * Get the opposite placement of the given one
   * @method
   * @memberof Popper.Utils
   * @argument {String} placement
   * @returns {String} flipped placement
   */
  function getOppositePlacement(placement) {
    var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
    return placement.replace(/left|right|bottom|top/g, function (matched) {
      return hash[matched];
    });
  }

  /**
   * Get offsets to the popper
   * @method
   * @memberof Popper.Utils
   * @param {Object} position - CSS position the Popper will get applied
   * @param {HTMLElement} popper - the popper element
   * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
   * @param {String} placement - one of the valid placement options
   * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
   */
  function getPopperOffsets(popper, referenceOffsets, placement) {
    placement = placement.split('-')[0];

    // Get popper node sizes
    var popperRect = getOuterSizes(popper);
Mark Otto's avatar
dist  
Mark Otto committed
2868

Mark Otto's avatar
dist    
Mark Otto committed
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
    // Add position, width and height to our offsets object
    var popperOffsets = {
      width: popperRect.width,
      height: popperRect.height
    };

    // depending by the popper placement we have to compute its offsets slightly differently
    var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
    var mainSide = isHoriz ? 'top' : 'left';
    var secondarySide = isHoriz ? 'left' : 'top';
    var measurement = isHoriz ? 'height' : 'width';
    var secondaryMeasurement = !isHoriz ? 'height' : 'width';

    popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
    if (placement === secondarySide) {
      popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
    } else {
      popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
    }

    return popperOffsets;
  }

  /**
   * Mimics the `find` method of Array
   * @method
   * @memberof Popper.Utils
   * @argument {Array} arr
   * @argument prop
   * @argument value
   * @returns index or -1
   */
XhmikosR's avatar
XhmikosR committed
2901
  function find$1(arr, check) {
Mark Otto's avatar
dist    
Mark Otto committed
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
    // use native find if supported
    if (Array.prototype.find) {
      return arr.find(check);
    }

    // use `filter` to obtain the same behavior of `find`
    return arr.filter(check)[0];
  }

  /**
   * Return the index of the matching object
   * @method
   * @memberof Popper.Utils
   * @argument {Array} arr
   * @argument prop
   * @argument value
   * @returns index or -1
   */
  function findIndex(arr, prop, value) {
    // use native findIndex if supported
    if (Array.prototype.findIndex) {
      return arr.findIndex(function (cur) {
        return cur[prop] === value;
      });
    }

    // use `find` + `indexOf` if `findIndex` isn't supported
XhmikosR's avatar
XhmikosR committed
2929
    var match = find$1(arr, function (obj) {
Mark Otto's avatar
dist    
Mark Otto committed
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
      return obj[prop] === value;
    });
    return arr.indexOf(match);
  }

  /**
   * Loop trough the list of modifiers and run them in order,
   * each of them will then edit the data object.
   * @method
   * @memberof Popper.Utils
   * @param {dataObject} data
   * @param {Array} modifiers
   * @param {String} ends - Optional modifier name used as stopper
   * @returns {dataObject}
   */
  function runModifiers(modifiers, data, ends) {
    var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));

    modifiersToRun.forEach(function (modifier) {
      if (modifier['function']) {
        // eslint-disable-line dot-notation
        console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
Mark Otto's avatar
dist  
Mark Otto committed
2952
      }
Mark Otto's avatar
dist    
Mark Otto committed
2953
2954
2955
2956
2957
2958
2959
2960
2961
      var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
      if (modifier.enabled && isFunction(fn)) {
        // Add properties to offsets to make them a complete clientRect object
        // we do this before each modifier to make sure the previous one doesn't
        // mess with these values
        data.offsets.popper = getClientRect(data.offsets.popper);
        data.offsets.reference = getClientRect(data.offsets.reference);

        data = fn(data, modifier);
Mark Otto's avatar
dist  
Mark Otto committed
2962
      }
Mark Otto's avatar
dist    
Mark Otto committed
2963
    });
Mark Otto's avatar
dist  
Mark Otto committed
2964

Mark Otto's avatar
dist    
Mark Otto committed
2965
2966
    return data;
  }
Mark Otto's avatar
dist  
Mark Otto committed
2967

Mark Otto's avatar
dist    
Mark Otto committed
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
  /**
   * Updates the position of the popper, computing the new offsets and applying
   * the new style.<br />
   * Prefer `scheduleUpdate` over `update` because of performance reasons.
   * @method
   * @memberof Popper
   */
  function update() {
    // if popper is destroyed, don't perform any further update
    if (this.state.isDestroyed) {
      return;
    }
Mark Otto's avatar
dist  
Mark Otto committed
2980

Mark Otto's avatar
dist    
Mark Otto committed
2981
2982
2983
2984
2985
2986
2987
    var data = {
      instance: this,
      styles: {},
      arrowStyles: {},
      attributes: {},
      flipped: false,
      offsets: {}
Mark Otto's avatar
dist  
Mark Otto committed
2988
2989
    };

Mark Otto's avatar
dist    
Mark Otto committed
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
    // compute reference element offsets
    data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);

    // compute auto placement, store placement inside the data object,
    // modifiers will be able to edit `placement` if needed
    // and refer to originalPlacement to know the original value
    data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);

    // store the computed placement inside `originalPlacement`
    data.originalPlacement = data.placement;

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