2445 lines · 79.3 KB · JavaScript
RawDownload
/**! * @fileOverview Kickass library to create and place poppers near their reference elements. * @version 1.12.9 * @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. */(function (global, factory) {	typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :	typeof define === 'function' && define.amd ? define(factory) :	(global.Popper = factory());}(this, (function () { 'use strict'; var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];var timeoutDuration = 0;for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {  if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {    timeoutDuration = 1;    break;  }} function microtaskDebounce(fn) {  var called = false;  return function () {    if (called) {      return;    }    called = true;    window.Promise.resolve().then(function () {      called = false;      fn();    });  };} function taskDebounce(fn) {  var scheduled = false;  return function () {    if (!scheduled) {      scheduled = true;      setTimeout(function () {        scheduled = false;        fn();      }, timeoutDuration);    }  };} var supportsMicroTasks = isBrowser && window.Promise; /*** 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; /** * 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]';} /** * 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 [];  }  // NOTE: 1 DOM access here  var css = getComputedStyle(element, null);  return property ? css[property] : css;} /** * 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;} /** * 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;  }   switch (element.nodeName) {    case 'HTML':    case 'BODY':      return element.ownerDocument.body;    case '#document':      return element.body;  }   // Firefox want us to check `-x` and `-y` variations as well   var _getStyleComputedProp = getStyleComputedProperty(element),      overflow = _getStyleComputedProp.overflow,      overflowX = _getStyleComputedProp.overflowX,      overflowY = _getStyleComputedProp.overflowY;   if (/(auto|scroll)/.test(overflow + overflowY + overflowX)) {    return element;  }   return getScrollParent(getParentNode(element));} /** * Returns the offset parent of the given element * @method * @memberof Popper.Utils * @argument {Element} element * @returns {Element} offset parent */function getOffsetParent(element) {  // NOTE: 1 DOM access here  var offsetParent = element && element.offsetParent;  var nodeName = offsetParent && offsetParent.nodeName;   if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {    if (element) {      return element.ownerDocument.documentElement;    }     return document.documentElement;  }   // .offsetParent will return the closest TD or TABLE in case  // no offsetParent is present, I hate this job...  if (['TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {    return getOffsetParent(offsetParent);  }   return offsetParent;} function isOffsetContainer(element) {  var nodeName = element.nodeName;   if (nodeName === 'BODY') {    return false;  }  return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;} /** * 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);  }   return node;} /** * 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;  }   // 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;   // Get common ancestor container  var range = document.createRange();  range.setStart(start, 0);  range.setEnd(end, 0);  var commonAncestorContainer = range.commonAncestorContainer;   // Both nodes are inside #document   if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {    if (isOffsetContainer(commonAncestorContainer)) {      return commonAncestorContainer;    }     return getOffsetParent(commonAncestorContainer);  }   // one of the nodes is inside shadowDOM, find which one  var element1root = getRoot(element1);  if (element1root.host) {    return findCommonOffsetParent(element1root.host, element2);  } else {    return findCommonOffsetParent(element1, getRoot(element2).host);  }} /** * 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';   var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';  var nodeName = element.nodeName;   if (nodeName === 'BODY' || nodeName === 'HTML') {    var html = element.ownerDocument.documentElement;    var scrollingElement = element.ownerDocument.scrollingElement || html;    return scrollingElement[upperSide];  }   return element[upperSide];} /* * 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;} /* * 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 */ function getBordersSize(styles, axis) {  var sideA = axis === 'x' ? 'Left' : 'Top';  var sideB = sideA === 'Left' ? 'Right' : 'Bottom';   return parseFloat(styles['border' + sideA + 'Width'], 10) + parseFloat(styles['border' + sideB + 'Width'], 10);} /** * Tells if you are running Internet Explorer 10 * @method * @memberof Popper.Utils * @returns {Boolean} isIE10 */var isIE10 = undefined; var isIE10$1 = function () {  if (isIE10 === undefined) {    isIE10 = navigator.appVersion.indexOf('MSIE 10') !== -1;  }  return isIE10;}; function getSize(axis, body, html, computedStyle) {  return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE10$1() ? html['offset' + axis] + computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')] + computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')] : 0);} function getWindowSizes() {  var body = document.body;  var html = document.documentElement;  var computedStyle = isIE10$1() && getComputedStyle(html);   return {    height: getSize('Height', body, html, computedStyle),    width: getSize('Width', body, html, computedStyle)  };} var classCallCheck = function (instance, Constructor) {  if (!(instance instanceof Constructor)) {    throw new TypeError("Cannot call a class as a function");  }}; 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);    }  }   return function (Constructor, protoProps, staticProps) {    if (protoProps) defineProperties(Constructor.prototype, protoProps);    if (staticProps) defineProperties(Constructor, staticProps);    return Constructor;  };}();     var defineProperty = function (obj, key, value) {  if (key in obj) {    Object.defineProperty(obj, key, {      value: value,      enumerable: true,      configurable: true,      writable: true    });  } else {    obj[key] = value;  }   return obj;}; var _extends = Object.assign || function (target) {  for (var i = 1; i < arguments.length; i++) {    var source = arguments[i];     for (var key in source) {      if (Object.prototype.hasOwnProperty.call(source, key)) {        target[key] = source[key];      }    }  }   return target;}; /** * Given element offsets, generate an output similar to getBoundingClientRect * @method * @memberof Popper.Utils * @argument {Object} offsets * @returns {Object} ClientRect like output */function getClientRect(offsets) {  return _extends({}, offsets, {    right: offsets.left + offsets.width,    bottom: offsets.top + offsets.height  });} /** * Get bounding client rect of given element * @method * @memberof Popper.Utils * @param {HTMLElement} element * @return {Object} client rect */function getBoundingClientRect(element) {  var rect = {};   // 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  if (isIE10$1()) {    try {      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;    } catch (err) {}  } else {    rect = element.getBoundingClientRect();  }   var result = {    left: rect.left,    top: rect.top,    width: rect.right - rect.left,    height: rect.bottom - rect.top  };   // subtract scrollbar size from sizes  var sizes = element.nodeName === 'HTML' ? getWindowSizes() : {};  var width = sizes.width || element.clientWidth || result.right - result.left;  var height = sizes.height || element.clientHeight || result.bottom - result.top;   var horizScrollbar = element.offsetWidth - width;  var vertScrollbar = element.offsetHeight - height;   // 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;  }   return getClientRect(result);} function getOffsetRectRelativeToArbitraryNode(children, parent) {  var isIE10 = isIE10$1();  var isHTML = parent.nodeName === 'HTML';  var childrenRect = getBoundingClientRect(children);  var parentRect = getBoundingClientRect(parent);  var scrollParent = getScrollParent(children);   var styles = getStyleComputedProperty(parent);  var borderTopWidth = parseFloat(styles.borderTopWidth, 10);  var borderLeftWidth = parseFloat(styles.borderLeftWidth, 10);   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) {    var marginTop = parseFloat(styles.marginTop, 10);    var marginLeft = parseFloat(styles.marginLeft, 10);

Lines 1–500 of 2445.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t