Migrate to bootstrap 4 in LeafWeb
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/**!
|
||||
* @fileOverview Kickass library to create and place poppers near their reference elements.
|
||||
* @version 1.14.3
|
||||
* @version 1.16.0
|
||||
* @license
|
||||
* Copyright (c) 2016 Federico Zivolo and contributors
|
||||
*
|
||||
@@ -34,7 +34,8 @@ function getStyleComputedProperty(element, property) {
|
||||
return [];
|
||||
}
|
||||
// NOTE: 1 DOM access here
|
||||
var css = getComputedStyle(element, null);
|
||||
var window = element.ownerDocument.defaultView;
|
||||
var css = window.getComputedStyle(element, null);
|
||||
return property ? css[property] : css;
|
||||
}
|
||||
|
||||
@@ -87,7 +88,18 @@ function getScrollParent(element) {
|
||||
return getScrollParent(getParentNode(element));
|
||||
}
|
||||
|
||||
var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
|
||||
|
||||
var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
|
||||
var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
|
||||
@@ -124,7 +136,7 @@ function getOffsetParent(element) {
|
||||
var noOffsetParent = isIE(10) ? document.body : null;
|
||||
|
||||
// NOTE: 1 DOM access here
|
||||
var offsetParent = element.offsetParent;
|
||||
var offsetParent = element.offsetParent || null;
|
||||
// Skip hidden elements which don't have an offsetParent
|
||||
while (offsetParent === noOffsetParent && element.nextElementSibling) {
|
||||
offsetParent = (element = element.nextElementSibling).offsetParent;
|
||||
@@ -136,9 +148,9 @@ function getOffsetParent(element) {
|
||||
return element ? element.ownerDocument.documentElement : document.documentElement;
|
||||
}
|
||||
|
||||
// .offsetParent will return the closest TD or TABLE in case
|
||||
// .offsetParent will return the closest TH, TD or TABLE in case
|
||||
// no offsetParent is present, I hate this job...
|
||||
if (['TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
|
||||
if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
|
||||
return getOffsetParent(offsetParent);
|
||||
}
|
||||
|
||||
@@ -276,10 +288,10 @@ function getBordersSize(styles, axis) {
|
||||
}
|
||||
|
||||
function getSize(axis, body, html, computedStyle) {
|
||||
return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? html['offset' + axis] + computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')] + computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')] : 0);
|
||||
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);
|
||||
}
|
||||
|
||||
function getWindowSizes() {
|
||||
function getWindowSizes(document) {
|
||||
var body = document.body;
|
||||
var html = document.documentElement;
|
||||
var computedStyle = isIE(10) && getComputedStyle(html);
|
||||
@@ -353,9 +365,9 @@ function getBoundingClientRect(element) {
|
||||
};
|
||||
|
||||
// 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 sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
|
||||
var width = sizes.width || element.clientWidth || result.width;
|
||||
var height = sizes.height || element.clientHeight || result.height;
|
||||
|
||||
var horizScrollbar = element.offsetWidth - width;
|
||||
var vertScrollbar = element.offsetHeight - height;
|
||||
@@ -388,7 +400,7 @@ function getOffsetRectRelativeToArbitraryNode(children, parent) {
|
||||
var borderLeftWidth = parseFloat(styles.borderLeftWidth, 10);
|
||||
|
||||
// In cases where the parent is fixed, we must ignore negative scroll in offset calc
|
||||
if (fixedPosition && parent.nodeName === 'HTML') {
|
||||
if (fixedPosition && isHTML) {
|
||||
parentRect.top = Math.max(parentRect.top, 0);
|
||||
parentRect.left = Math.max(parentRect.left, 0);
|
||||
}
|
||||
@@ -463,7 +475,11 @@ function isFixed(element) {
|
||||
if (getStyleComputedProperty(element, 'position') === 'fixed') {
|
||||
return true;
|
||||
}
|
||||
return isFixed(getParentNode(element));
|
||||
var parentNode = getParentNode(element);
|
||||
if (!parentNode) {
|
||||
return false;
|
||||
}
|
||||
return isFixed(parentNode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -503,7 +519,7 @@ function getBoundaries(popper, reference, padding, boundariesElement) {
|
||||
// NOTE: 1 DOM access here
|
||||
|
||||
var boundaries = { top: 0, left: 0 };
|
||||
var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference);
|
||||
var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
|
||||
|
||||
// Handle viewport case
|
||||
if (boundariesElement === 'viewport') {
|
||||
@@ -526,7 +542,7 @@ function getBoundaries(popper, reference, padding, boundariesElement) {
|
||||
|
||||
// In case of HTML, we need a different computation
|
||||
if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
|
||||
var _getWindowSizes = getWindowSizes(),
|
||||
var _getWindowSizes = getWindowSizes(popper.ownerDocument),
|
||||
height = _getWindowSizes.height,
|
||||
width = _getWindowSizes.width;
|
||||
|
||||
@@ -541,10 +557,12 @@ function getBoundaries(popper, reference, padding, boundariesElement) {
|
||||
}
|
||||
|
||||
// Add paddings
|
||||
boundaries.left += padding;
|
||||
boundaries.top += padding;
|
||||
boundaries.right -= padding;
|
||||
boundaries.bottom -= padding;
|
||||
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;
|
||||
|
||||
return boundaries;
|
||||
}
|
||||
@@ -616,14 +634,15 @@ function computeAutoPlacement(placement, refRect, popper, reference, boundariesE
|
||||
return computedPlacement + (variation ? '-' + variation : '');
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}();
|
||||
|
||||
function microtaskDebounce(fn) {
|
||||
var called = false;
|
||||
@@ -718,7 +737,7 @@ function findIndex(arr, prop, value) {
|
||||
function getOffsetRect(element) {
|
||||
var elementRect = void 0;
|
||||
if (element.nodeName === 'HTML') {
|
||||
var _getWindowSizes = getWindowSizes(),
|
||||
var _getWindowSizes = getWindowSizes(element.ownerDocument),
|
||||
width = _getWindowSizes.width,
|
||||
height = _getWindowSizes.height;
|
||||
|
||||
@@ -749,9 +768,10 @@ function getOffsetRect(element) {
|
||||
* @returns {Object} object containing width and height properties
|
||||
*/
|
||||
function getOuterSizes(element) {
|
||||
var styles = getComputedStyle(element);
|
||||
var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
|
||||
var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
|
||||
var window = element.ownerDocument.defaultView;
|
||||
var styles = window.getComputedStyle(element);
|
||||
var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
|
||||
var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
|
||||
var result = {
|
||||
width: element.offsetWidth + y,
|
||||
height: element.offsetHeight + x
|
||||
@@ -825,7 +845,7 @@ function getPopperOffsets(popper, referenceOffsets, placement) {
|
||||
function getReferenceOffsets(state, popper, reference) {
|
||||
var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
||||
|
||||
var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference);
|
||||
var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
|
||||
return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user