6 lines
9.6 KiB
JavaScript
6 lines
9.6 KiB
JavaScript
/*
|
|
Copyright (C) Federico Zivolo 2017
|
|
Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT).
|
|
*/(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?b(exports):'function'==typeof define&&define.amd?define(['exports'],b):b(a.PopperUtils=a.PopperUtils||{})})(this,function(a){'use strict';function b(a,b){if(1!==a.nodeType)return[];var c=window.getComputedStyle(a,null);return b?c[b]:c}function c(a){return'HTML'===a.nodeName?a:a.parentNode||a.host}function d(a){if(!a)return window.document.body;switch(a.nodeName){case'HTML':case'BODY':return a.ownerDocument.body;case'#document':return a.body;}var e=b(a),f=e.overflow,g=e.overflowX,h=e.overflowY;return /(auto|scroll)/.test(f+h+g)?a:d(c(a))}function e(a){var c=a&&a.offsetParent,d=c&&c.nodeName;return d&&'BODY'!==d&&'HTML'!==d?-1!==['TD','TABLE'].indexOf(c.nodeName)&&'static'===b(c,'position')?e(c):c:a?a.ownerDocument.documentElement:window.document.documentElement}function f(a){var b=a.nodeName;return'BODY'!==b&&('HTML'===b||e(a.firstElementChild)===a)}function g(a){return null===a.parentNode?a:g(a.parentNode)}function h(a,b){if(!a||!a.nodeType||!b||!b.nodeType)return window.document.documentElement;var c=a.compareDocumentPosition(b)&Node.DOCUMENT_POSITION_FOLLOWING,d=c?a:b,i=c?b:a,j=document.createRange();j.setStart(d,0),j.setEnd(i,0);var k=j.commonAncestorContainer;if(a!==k&&b!==k||d.contains(i))return f(k)?k:e(k);var l=g(a);return l.host?h(l.host,b):h(a,g(b).host)}function j(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:'top',c='top'===b?'scrollTop':'scrollLeft',d=a.nodeName;if('BODY'===d||'HTML'===d){var e=a.ownerDocument.documentElement,f=a.ownerDocument.scrollingElement||e;return f[c]}return a[c]}function k(a,b){var c=2<arguments.length&&void 0!==arguments[2]&&arguments[2],d=j(b,'top'),e=j(b,'left'),f=c?-1:1;return a.top+=d*f,a.bottom+=d*f,a.left+=e*f,a.right+=e*f,a}function l(a,b){var c='x'===b?'Left':'Top',d='Left'==c?'Right':'Bottom';return+a['border'+c+'Width'].split('px')[0]+ +a['border'+d+'Width'].split('px')[0]}function m(a,b,c,d){return P(b['offset'+a],b['scroll'+a],c['client'+a],c['offset'+a],c['scroll'+a],R()?c['offset'+a]+d['margin'+('Height'===a?'Top':'Left')]+d['margin'+('Height'===a?'Bottom':'Right')]:0)}function n(){var a=window.document.body,b=window.document.documentElement,c=R()&&window.getComputedStyle(b);return{height:m('Height',a,b,c),width:m('Width',a,b,c)}}function o(a){return S({},a,{right:a.left+a.width,bottom:a.top+a.height})}function p(a){var c={};if(R())try{c=a.getBoundingClientRect();var d=j(a,'top'),e=j(a,'left');c.top+=d,c.left+=e,c.bottom+=d,c.right+=e}catch(a){}else c=a.getBoundingClientRect();var f={left:c.left,top:c.top,width:c.right-c.left,height:c.bottom-c.top},g='HTML'===a.nodeName?n():{},h=g.width||a.clientWidth||f.right-f.left,i=g.height||a.clientHeight||f.bottom-f.top,k=a.offsetWidth-h,m=a.offsetHeight-i;if(k||m){var p=b(a);k-=l(p,'x'),m-=l(p,'y'),f.width-=k,f.height-=m}return o(f)}function q(a,c){var e=R(),f='HTML'===c.nodeName,g=p(a),h=p(c),i=d(a),j=b(c),l=+j.borderTopWidth.split('px')[0],m=+j.borderLeftWidth.split('px')[0],n=o({top:g.top-h.top-l,left:g.left-h.left-m,width:g.width,height:g.height});if(n.marginTop=0,n.marginLeft=0,!e&&f){var q=+j.marginTop.split('px')[0],r=+j.marginLeft.split('px')[0];n.top-=l-q,n.bottom-=l-q,n.left-=m-r,n.right-=m-r,n.marginTop=q,n.marginLeft=r}return(e?c.contains(i):c===i&&'BODY'!==i.nodeName)&&(n=k(n,c)),n}function r(a){var b=a.ownerDocument.documentElement,c=q(a,b),d=P(b.clientWidth,window.innerWidth||0),e=P(b.clientHeight,window.innerHeight||0),f=j(b),g=j(b,'left'),h={top:f-c.top+c.marginTop,left:g-c.left+c.marginLeft,width:d,height:e};return o(h)}function s(a){var d=a.nodeName;return'BODY'===d||'HTML'===d?!1:!('fixed'!==b(a,'position'))||s(c(a))}function t(a,b,e,f){var g={top:0,left:0},i=h(a,b);if('viewport'===f)g=r(i);else{var j;'scrollParent'===f?(j=d(c(a)),'BODY'===j.nodeName&&(j=a.ownerDocument.documentElement)):'window'===f?j=a.ownerDocument.documentElement:j=f;var k=q(j,i);if('HTML'===j.nodeName&&!s(i)){var l=n(),m=l.height,o=l.width;g.top+=k.top-k.marginTop,g.bottom=m+k.top,g.left+=k.left-k.marginLeft,g.right=o+k.left}else g=k}return g.left+=e,g.top+=e,g.right-=e,g.bottom-=e,g}function u(a){var b=a.width,c=a.height;return b*c}function v(a,b,c,d,e){var f=5<arguments.length&&arguments[5]!==void 0?arguments[5]:0;if(-1===a.indexOf('auto'))return a;var g=t(c,d,f,e),h={top:{width:g.width,height:b.top-g.top},right:{width:g.right-b.right,height:g.height},bottom:{width:g.width,height:g.bottom-b.bottom},left:{width:b.left-g.left,height:g.height}},i=Object.keys(h).map(function(a){return S({key:a},h[a],{area:u(h[a])})}).sort(function(c,a){return a.area-c.area}),j=i.filter(function(a){var b=a.width,d=a.height;return b>=c.clientWidth&&d>=c.clientHeight}),k=0<j.length?j[0].key:i[0].key,l=a.split('-')[1];return k+(l?'-'+l:'')}function w(a,b){return Array.prototype.find?a.find(b):a.filter(b)[0]}function x(a,b,c){if(Array.prototype.findIndex)return a.findIndex(function(a){return a[b]===c});var d=w(a,function(a){return a[b]===c});return a.indexOf(d)}function y(a){var b;if('HTML'===a.nodeName){var c=n(),d=c.width,e=c.height;b={width:d,height:e,left:0,top:0}}else b={width:a.offsetWidth,height:a.offsetHeight,left:a.offsetLeft,top:a.offsetTop};return o(b)}function z(a){var b=window.getComputedStyle(a),c=parseFloat(b.marginTop)+parseFloat(b.marginBottom),d=parseFloat(b.marginLeft)+parseFloat(b.marginRight),e={width:a.offsetWidth+d,height:a.offsetHeight+c};return e}function A(a){var b={left:'right',right:'left',bottom:'top',top:'bottom'};return a.replace(/left|right|bottom|top/g,function(a){return b[a]})}function B(a,b,c){c=c.split('-')[0];var d=z(a),e={width:d.width,height:d.height},f=-1!==['right','left'].indexOf(c),g=f?'top':'left',h=f?'left':'top',i=f?'height':'width',j=f?'width':'height';return e[g]=b[g]+b[i]/2-d[i]/2,e[h]=c===h?b[h]-d[j]:b[A(h)],e}function C(a,b,c){var d=h(b,c);return q(c,d)}function D(a){for(var b=[!1,'ms','Webkit','Moz','O'],c=a.charAt(0).toUpperCase()+a.slice(1),d=0;d<b.length-1;d++){var e=b[d],f=e?''+e+c:a;if('undefined'!=typeof window.document.body.style[f])return f}return null}function E(a){return a&&'[object Function]'==={}.toString.call(a)}function F(a,b){return a.some(function(a){var c=a.name,d=a.enabled;return d&&c===b})}function G(a,b,c){var d=w(a,function(a){var c=a.name;return c===b}),e=!!d&&a.some(function(a){return a.name===c&&a.enabled&&a.order<d.order});if(!e){var f='`'+b+'`';console.warn('`'+c+'`'+' modifier is required by '+f+' modifier in order to work, be sure to include it before '+f+'!')}return e}function H(a){return''!==a&&!isNaN(parseFloat(a))&&isFinite(a)}function I(a){var b=a.ownerDocument;return b?b.defaultView:window}function J(a,b){return I(a).removeEventListener('resize',b.updateBound),b.scrollParents.forEach(function(a){a.removeEventListener('scroll',b.updateBound)}),b.updateBound=null,b.scrollParents=[],b.scrollElement=null,b.eventsEnabled=!1,b}function K(a,b,c){var d=void 0===c?a:a.slice(0,x(a,'name',c));return d.forEach(function(a){a['function']&&console.warn('`modifier.function` is deprecated, use `modifier.fn`!');var c=a['function']||a.fn;a.enabled&&E(c)&&(b.offsets.popper=o(b.offsets.popper),b.offsets.reference=o(b.offsets.reference),b=c(b,a))}),b}function L(a,b){Object.keys(b).forEach(function(c){var d=b[c];!1===d?a.removeAttribute(c):a.setAttribute(c,b[c])})}function M(a,b){Object.keys(b).forEach(function(c){var d='';-1!==['width','height','top','right','bottom','left'].indexOf(c)&&H(b[c])&&(d='px'),a.style[c]=b[c]+d})}function N(a,b,c,e){var f='BODY'===a.nodeName,g=f?a.ownerDocument.defaultView:a;g.addEventListener(b,c,{passive:!0}),f||N(d(g.parentNode),b,c,e),e.push(g)}function O(a,b,c,e){c.updateBound=e,I(a).addEventListener('resize',c.updateBound,{passive:!0});var f=d(a);return N(f,'scroll',c.updateBound,c.scrollParents),c.scrollElement=f,c.eventsEnabled=!0,c}for(var P=Math.max,Q=void 0,R=function(){return void 0==Q&&(Q=-1!==navigator.appVersion.indexOf('MSIE 10')),Q},S=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},T='undefined'!=typeof window&&'undefined'!=typeof window.document,U=['Edge','Trident','Firefox'],V=0,W=0;W<U.length;W+=1)if(T&&0<=navigator.userAgent.indexOf(U[W])){V=1;break}var i=T&&window.Promise,X=i?function(a){var b=!1;return function(){b||(b=!0,Promise.resolve().then(function(){b=!1,a()}))}}:function(a){var b=!1;return function(){b||(b=!0,setTimeout(function(){b=!1,a()},V))}};a.computeAutoPlacement=v,a.debounce=X,a.findIndex=x,a.getBordersSize=l,a.getBoundaries=t,a.getBoundingClientRect=p,a.getClientRect=o,a.getOffsetParent=e,a.getOffsetRect=y,a.getOffsetRectRelativeToArbitraryNode=q,a.getOuterSizes=z,a.getParentNode=c,a.getPopperOffsets=B,a.getReferenceOffsets=C,a.getScroll=j,a.getScrollParent=d,a.getStyleComputedProperty=b,a.getSupportedPropertyName=D,a.getWindowSizes=n,a.isFixed=s,a.isFunction=E,a.isModifierEnabled=F,a.isModifierRequired=G,a.isNumeric=H,a.removeEventListeners=J,a.runModifiers=K,a.setAttributes=L,a.setStyles=M,a.setupEventListeners=O,a['default']={computeAutoPlacement:v,debounce:X,findIndex:x,getBordersSize:l,getBoundaries:t,getBoundingClientRect:p,getClientRect:o,getOffsetParent:e,getOffsetRect:y,getOffsetRectRelativeToArbitraryNode:q,getOuterSizes:z,getParentNode:c,getPopperOffsets:B,getReferenceOffsets:C,getScroll:j,getScrollParent:d,getStyleComputedProperty:b,getSupportedPropertyName:D,getWindowSizes:n,isFixed:s,isFunction:E,isModifierEnabled:F,isModifierRequired:G,isNumeric:H,removeEventListeners:J,runModifiers:K,setAttributes:L,setStyles:M,setupEventListeners:O},Object.defineProperty(a,'__esModule',{value:!0})});
|
|
//# sourceMappingURL=popper-utils.min.js.map
|