cleanup of edit flight page; added deps
This commit is contained in:
+48
-51
@@ -1,6 +1,6 @@
|
||||
/**!
|
||||
* @fileOverview Kickass library to create and place poppers near their reference elements.
|
||||
* @version 1.12.2
|
||||
* @version 1.12.6
|
||||
* @license
|
||||
* Copyright (c) 2016 Federico Zivolo and contributors
|
||||
*
|
||||
@@ -61,10 +61,18 @@ function getParentNode(element) {
|
||||
*/
|
||||
function getScrollParent(element) {
|
||||
// Return body, `getScroll` will take care to get the correct `scrollTop` from it
|
||||
if (!element || ['HTML', 'BODY', '#document'].indexOf(element.nodeName) !== -1) {
|
||||
if (!element) {
|
||||
return window.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
|
||||
const { overflow, overflowX, overflowY } = getStyleComputedProperty(element);
|
||||
if (/(auto|scroll)/.test(overflow + overflowY + overflowX)) {
|
||||
@@ -87,6 +95,10 @@ function getOffsetParent(element) {
|
||||
const nodeName = offsetParent && offsetParent.nodeName;
|
||||
|
||||
if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
|
||||
if (element) {
|
||||
return element.ownerDocument.documentElement;
|
||||
}
|
||||
|
||||
return window.document.documentElement;
|
||||
}
|
||||
|
||||
@@ -178,8 +190,8 @@ function getScroll(element, side = 'top') {
|
||||
const nodeName = element.nodeName;
|
||||
|
||||
if (nodeName === 'BODY' || nodeName === 'HTML') {
|
||||
const html = window.document.documentElement;
|
||||
const scrollingElement = window.document.scrollingElement || html;
|
||||
const html = element.ownerDocument.documentElement;
|
||||
const scrollingElement = element.ownerDocument.scrollingElement || html;
|
||||
return scrollingElement[upperSide];
|
||||
}
|
||||
|
||||
@@ -239,7 +251,7 @@ var isIE10$1 = function () {
|
||||
};
|
||||
|
||||
function getSize(axis, body, html, computedStyle) {
|
||||
return Math.max(body[`offset${axis}`], html[`client${axis}`], html[`offset${axis}`], isIE10$1() ? 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}`], isIE10$1() ? html[`offset${axis}`] + computedStyle[`margin${axis === 'Height' ? 'Top' : 'Left'}`] + computedStyle[`margin${axis === 'Height' ? 'Bottom' : 'Right'}`] : 0);
|
||||
}
|
||||
|
||||
function getWindowSizes() {
|
||||
@@ -383,7 +395,7 @@ function getOffsetRectRelativeToArbitraryNode(children, parent) {
|
||||
}
|
||||
|
||||
function getViewportOffsetRectRelativeToArtbitraryNode(element) {
|
||||
const html = window.document.documentElement;
|
||||
const html = element.ownerDocument.documentElement;
|
||||
const relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
|
||||
const width = Math.max(html.clientWidth, window.innerWidth || 0);
|
||||
const height = Math.max(html.clientHeight, window.innerHeight || 0);
|
||||
@@ -444,10 +456,10 @@ function getBoundaries(popper, reference, padding, boundariesElement) {
|
||||
if (boundariesElement === 'scrollParent') {
|
||||
boundariesNode = getScrollParent(getParentNode(popper));
|
||||
if (boundariesNode.nodeName === 'BODY') {
|
||||
boundariesNode = window.document.documentElement;
|
||||
boundariesNode = popper.ownerDocument.documentElement;
|
||||
}
|
||||
} else if (boundariesElement === 'window') {
|
||||
boundariesNode = window.document.documentElement;
|
||||
boundariesNode = popper.ownerDocument.documentElement;
|
||||
} else {
|
||||
boundariesNode = boundariesElement;
|
||||
}
|
||||
@@ -530,18 +542,7 @@ function computeAutoPlacement(placement, refRect, popper, reference, boundariesE
|
||||
return computedPlacement + (variation ? `-${variation}` : '');
|
||||
}
|
||||
|
||||
const nativeHints = ['native code', '[object MutationObserverConstructor]'];
|
||||
|
||||
/**
|
||||
* Determine if a function is implemented natively (as opposed to a polyfill).
|
||||
* @method
|
||||
* @memberof Popper.Utils
|
||||
* @argument {Function | undefined} fn the function to check
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
var isNative = (fn => nativeHints.some(hint => (fn || '').toString().indexOf(hint) > -1));
|
||||
|
||||
const isBrowser = typeof window !== 'undefined';
|
||||
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
||||
const longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
|
||||
let timeoutDuration = 0;
|
||||
for (let i = 0; i < longerTimeoutBrowsers.length; i += 1) {
|
||||
@@ -552,26 +553,16 @@ for (let i = 0; i < longerTimeoutBrowsers.length; i += 1) {
|
||||
}
|
||||
|
||||
function microtaskDebounce(fn) {
|
||||
let scheduled = false;
|
||||
let i = 0;
|
||||
const elem = document.createElement('span');
|
||||
|
||||
// MutationObserver provides a mechanism for scheduling microtasks, which
|
||||
// are scheduled *before* the next task. This gives us a way to debounce
|
||||
// a function but ensure it's called *before* the next paint.
|
||||
const observer = new MutationObserver(() => {
|
||||
fn();
|
||||
scheduled = false;
|
||||
});
|
||||
|
||||
observer.observe(elem, { attributes: true });
|
||||
|
||||
let called = false;
|
||||
return () => {
|
||||
if (!scheduled) {
|
||||
scheduled = true;
|
||||
elem.setAttribute('x-index', i);
|
||||
i = i + 1; // don't use compund (+=) because it doesn't get optimized in V8
|
||||
if (called) {
|
||||
return;
|
||||
}
|
||||
called = true;
|
||||
Promise.resolve().then(() => {
|
||||
called = false;
|
||||
fn();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -588,11 +579,7 @@ function taskDebounce(fn) {
|
||||
};
|
||||
}
|
||||
|
||||
// It's common for MutationObserver polyfills to be seen in the wild, however
|
||||
// these rely on Mutation Events which only occur when an element is connected
|
||||
// to the DOM. The algorithm used in this module does not use a connected element,
|
||||
// and so we must ensure that a *native* MutationObserver is available.
|
||||
const supportsNativeMutationObserver = isBrowser && isNative(window.MutationObserver);
|
||||
const supportsMicroTasks = isBrowser && window.Promise;
|
||||
|
||||
/**
|
||||
* Create a debounced version of a method, that's asynchronously deferred
|
||||
@@ -603,7 +590,7 @@ const supportsNativeMutationObserver = isBrowser && isNative(window.MutationObse
|
||||
* @argument {Function} fn
|
||||
* @returns {Function}
|
||||
*/
|
||||
var debounce = supportsNativeMutationObserver ? microtaskDebounce : taskDebounce;
|
||||
var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
|
||||
|
||||
/**
|
||||
* Mimics the `find` method of Array
|
||||
@@ -836,6 +823,16 @@ function isNumeric(n) {
|
||||
return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the window associated with the element
|
||||
* @argument {Element} element
|
||||
* @returns {Window}
|
||||
*/
|
||||
function getWindow(element) {
|
||||
const ownerDocument = element.ownerDocument;
|
||||
return ownerDocument ? ownerDocument.defaultView : window;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove event listeners used to update the popper position
|
||||
* @method
|
||||
@@ -844,7 +841,7 @@ function isNumeric(n) {
|
||||
*/
|
||||
function removeEventListeners(reference, state) {
|
||||
// Remove resize event listener on window
|
||||
window.removeEventListener('resize', state.updateBound);
|
||||
getWindow(reference).removeEventListener('resize', state.updateBound);
|
||||
|
||||
// Remove scroll event listener on scroll parents
|
||||
state.scrollParents.forEach(target => {
|
||||
@@ -873,10 +870,11 @@ function runModifiers(modifiers, data, ends) {
|
||||
const modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
|
||||
|
||||
modifiersToRun.forEach(modifier => {
|
||||
if (modifier.function) {
|
||||
if (modifier['function']) {
|
||||
// eslint-disable-line dot-notation
|
||||
console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
|
||||
}
|
||||
const fn = modifier.function || modifier.fn;
|
||||
const 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
|
||||
@@ -931,7 +929,7 @@ function setStyles(element, styles) {
|
||||
|
||||
function attachToScrollParents(scrollParent, event, callback, scrollParents) {
|
||||
const isBody = scrollParent.nodeName === 'BODY';
|
||||
const target = isBody ? window : scrollParent;
|
||||
const target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
|
||||
target.addEventListener(event, callback, { passive: true });
|
||||
|
||||
if (!isBody) {
|
||||
@@ -949,7 +947,7 @@ function attachToScrollParents(scrollParent, event, callback, scrollParents) {
|
||||
function setupEventListeners(reference, options, state, updateBound) {
|
||||
// Resize event listener on window
|
||||
state.updateBound = updateBound;
|
||||
window.addEventListener('resize', state.updateBound, { passive: true });
|
||||
getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
|
||||
|
||||
// Scroll event listener on scroll parents
|
||||
const scrollElement = getScrollParent(reference);
|
||||
@@ -990,7 +988,6 @@ var index = {
|
||||
isFunction,
|
||||
isModifierEnabled,
|
||||
isModifierRequired,
|
||||
isNative,
|
||||
isNumeric,
|
||||
removeEventListeners,
|
||||
runModifiers,
|
||||
@@ -999,5 +996,5 @@ var index = {
|
||||
setupEventListeners
|
||||
};
|
||||
|
||||
export { computeAutoPlacement, debounce, findIndex, getBordersSize, getBoundaries, getBoundingClientRect, getClientRect, getOffsetParent, getOffsetRect, getOffsetRectRelativeToArbitraryNode, getOuterSizes, getParentNode, getPopperOffsets, getReferenceOffsets, getScroll, getScrollParent, getStyleComputedProperty, getSupportedPropertyName, getWindowSizes, isFixed, isFunction, isModifierEnabled, isModifierRequired, isNative, isNumeric, removeEventListeners, runModifiers, setAttributes, setStyles, setupEventListeners };export default index;
|
||||
export { computeAutoPlacement, debounce, findIndex, getBordersSize, getBoundaries, getBoundingClientRect, getClientRect, getOffsetParent, getOffsetRect, getOffsetRectRelativeToArbitraryNode, getOuterSizes, getParentNode, getPopperOffsets, getReferenceOffsets, getScroll, getScrollParent, getStyleComputedProperty, getSupportedPropertyName, getWindowSizes, isFixed, isFunction, isModifierEnabled, isModifierRequired, isNumeric, removeEventListeners, runModifiers, setAttributes, setStyles, setupEventListeners };export default index;
|
||||
//# sourceMappingURL=popper-utils.js.map
|
||||
|
||||
Reference in New Issue
Block a user