g6/demos/assets/popper.js-1.12.5/popper-utils.min.js
2018-06-05 23:58:10 +08:00

6 lines
9.7 KiB
JavaScript
Executable File

/*
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||-1!==['HTML','BODY','#document'].indexOf(a.nodeName))return window.document.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: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=window.document.documentElement,f=window.document.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 O(b['offset'+a],b['scroll'+a],c['client'+a],c['offset'+a],c['scroll'+a],Q()?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=Q()&&window.getComputedStyle(b);return{height:m('Height',a,b,c),width:m('Width',a,b,c)}}function o(a){return R({},a,{right:a.left+a.width,bottom:a.top+a.height})}function p(a){var c={};if(Q())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=Q(),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=window.document.documentElement,c=q(a,b),d=O(b.clientWidth,window.innerWidth||0),e=O(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=window.document.documentElement)):'window'===f?j=window.document.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 R({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,b){return window.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 J(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 K(a,b){Object.keys(b).forEach(function(c){var d=b[c];!1===d?a.removeAttribute(c):a.setAttribute(c,b[c])})}function L(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 M(a,b,c,e){var f='BODY'===a.nodeName,g=f?window:a;g.addEventListener(b,c,{passive:!0}),f||M(d(g.parentNode),b,c,e),e.push(g)}function N(a,b,c,e){c.updateBound=e,window.addEventListener('resize',c.updateBound,{passive:!0});var f=d(a);return M(f,'scroll',c.updateBound,c.scrollParents),c.scrollElement=f,c.eventsEnabled=!0,c}for(var O=Math.max,P=void 0,Q=function(){return void 0==P&&(P=-1!==navigator.appVersion.indexOf('MSIE 10')),P},R=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},S=['native code','[object MutationObserverConstructor]'],T=function(a){return S.some(function(b){return-1<(a||'').toString().indexOf(b)})},U='undefined'!=typeof window,V=['Edge','Trident','Firefox'],W=0,X=0;X<V.length;X+=1)if(U&&0<=navigator.userAgent.indexOf(V[X])){W=1;break}var i=U&&T(window.MutationObserver),Y=i?function(a){var b=!1,c=0,d=document.createElement('span'),e=new MutationObserver(function(){a(),b=!1});return e.observe(d,{attributes:!0}),function(){b||(b=!0,d.setAttribute('x-index',c),++c)}}:function(a){var b=!1;return function(){b||(b=!0,setTimeout(function(){b=!1,a()},W))}};a.computeAutoPlacement=v,a.debounce=Y,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.isNative=T,a.isNumeric=H,a.removeEventListeners=I,a.runModifiers=J,a.setAttributes=K,a.setStyles=L,a.setupEventListeners=N,a['default']={computeAutoPlacement:v,debounce:Y,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,isNative:T,isNumeric:H,removeEventListeners:I,runModifiers:J,setAttributes:K,setStyles:L,setupEventListeners:N},Object.defineProperty(a,'__esModule',{value:!0})});
//# sourceMappingURL=popper-utils.min.js.map