2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-14 18:42:30 +03:00
Files
bootstrap/docs/assets/js/vendor/popper.min.js
T

3 lines
18 KiB
JavaScript

var _Mathfloor=Math.floor,_Mathmin=Math.min,_Mathround=Math.round,_Mathmax=Math.max;const nativeHints=['native code','[object MutationObserverConstructor]'];var isNative=(c)=>nativeHints.some((d)=>-1<(c||'').toString().indexOf(d));const isBrowser='undefined'!=typeof window,longerTimeoutBrowsers=['Edge','Trident','Firefox'];let timeoutDuration=0;for(let c=0;c<longerTimeoutBrowsers.length;c+=1)if(isBrowser&&0<=navigator.userAgent.indexOf(longerTimeoutBrowsers[c])){timeoutDuration=1;break}function microtaskDebounce(c){let d=!1,e=0;const f=document.createElement('span'),g=new MutationObserver(()=>{c(),d=!1});return g.observe(f,{attributes:!0}),()=>{d||(d=!0,f.setAttribute('x-index',e),++e)}}function taskDebounce(c){let d=!1;return()=>{d||(d=!0,setTimeout(()=>{d=!1,c()},timeoutDuration))}}const supportsNativeMutationObserver=isBrowser&&isNative(window.MutationObserver);var debounce=supportsNativeMutationObserver?microtaskDebounce:taskDebounce;function isNumeric(c){return''!==c&&!isNaN(parseFloat(c))&&isFinite(c)}function setStyles(c,d){Object.keys(d).forEach((e)=>{let f='';-1!==['width','height','top','right','bottom','left'].indexOf(e)&&isNumeric(d[e])&&(f='px'),c.style[e]=d[e]+f})}function getSupportedPropertyName(c){const d=[!1,'ms','webkit','moz','o'],e=c.charAt(0).toUpperCase()+c.slice(1);for(let f=0;f<d.length-1;f++){const g=d[f],h=g?`${g}${e}`:c;if('undefined'!=typeof window.document.body.style[h])return h}return null}function isOffsetContainer(c){const{nodeName:d}=c;return'BODY'!==d&&('HTML'===d||c.firstElementChild.offsetParent===c)}function getRoot(c){return null===c.parentNode?c:getRoot(c.parentNode)}function getOffsetParent(c){const d=c&&c.offsetParent,e=d&&d.nodeName;return e&&'BODY'!==e&&'HTML'!==e?d:window.document.documentElement}function findCommonOffsetParent(c,d){if(!c||!c.nodeType||!d||!d.nodeType)return window.document.documentElement;const e=c.compareDocumentPosition(d)&Node.DOCUMENT_POSITION_FOLLOWING,f=e?c:d,g=e?d:c,h=document.createRange();h.setStart(f,0),h.setEnd(g,0);const{commonAncestorContainer:j}=h;if(c!==j&&d!==j)return isOffsetContainer(j)?j:getOffsetParent(j);const k=getRoot(c);return k.host?findCommonOffsetParent(k.host,d):findCommonOffsetParent(c,getRoot(d).host)}function getStyleComputedProperty(c,d){if(1!==c.nodeType)return[];const e=window.getComputedStyle(c,null);return d?e[d]:e}function getScroll(c,d='top'){const e='top'===d?'scrollTop':'scrollLeft',f=c.nodeName;if('BODY'===f||'HTML'===f){const g=window.document.documentElement,h=window.document.scrollingElement||g;return h[e]}return c[e]}function includeScroll(c,d,e=!1){const f=getScroll(d,'top'),g=getScroll(d,'left'),h=e?-1:1;return c.top+=f*h,c.bottom+=f*h,c.left+=g*h,c.right+=g*h,c}function getParentNode(c){return'HTML'===c.nodeName?c:c.parentNode||c.host}function getScrollParent(c){if(!c||-1!==['HTML','BODY','#document'].indexOf(c.nodeName))return window.document.body;const{overflow:d,overflowX:e,overflowY:f}=getStyleComputedProperty(c);return /(auto|scroll)/.test(d+f+e)?c:getScrollParent(getParentNode(c))}function getBordersSize(c,d){const e='x'===d?'Left':'Top',f='Left'==e?'Right':'Bottom';return+c[`border${e}Width`].split('px')[0]+ +c[`border${f}Width`].split('px')[0]}function getWindowSizes(){const c=window.document.body,d=window.document.documentElement;return{height:_Mathmax(c.scrollHeight,c.offsetHeight,d.clientHeight,d.scrollHeight,d.offsetHeight),width:_Mathmax(c.scrollWidth,c.offsetWidth,d.clientWidth,d.scrollWidth,d.offsetWidth)}}var _extends=Object.assign||function(c){for(var e,d=1;d<arguments.length;d++)for(var f in e=arguments[d],e)Object.prototype.hasOwnProperty.call(e,f)&&(c[f]=e[f]);return c};function getClientRect(c){return _extends({},c,{right:c.left+c.width,bottom:c.top+c.height})}var runIsIE10=function(){return-1!==navigator.appVersion.indexOf('MSIE 10')};const isIE10$1=runIsIE10();function getBoundingClientRect(c){let d={};if(isIE10$1)try{d=c.getBoundingClientRect();const l=getScroll(c,'top'),m=getScroll(c,'left');d.top+=l,d.left+=m,d.bottom+=l,d.right+=m}catch(l){}else d=c.getBoundingClientRect();const e={left:d.left,top:d.top,width:d.right-d.left,height:d.bottom-d.top},f='HTML'===c.nodeName?getWindowSizes():{},g=f.width||c.clientWidth||e.right-e.left,h=f.height||c.clientHeight||e.bottom-e.top;let j=c.offsetWidth-g,k=c.offsetHeight-h;if(j||k){const l=getStyleComputedProperty(c);j-=getBordersSize(l,'x'),k-=getBordersSize(l,'y'),e.width-=j,e.height-=k}return getClientRect(e)}const isIE10=runIsIE10();function getOffsetRectRelativeToArbitraryNode(c,d){const e='HTML'===d.nodeName,f=getBoundingClientRect(c),g=getBoundingClientRect(d),h=getScrollParent(c);let j=getClientRect({top:f.top-g.top,left:f.left-g.left,width:f.width,height:f.height});if(e||'BODY'===d.nodeName){const k=getStyleComputedProperty(d),l=isIE10&&e?0:+k.borderTopWidth.split('px')[0],m=isIE10&&e?0:+k.borderLeftWidth.split('px')[0],o=isIE10&&e?0:+k.marginTop.split('px')[0],p=isIE10&&e?0:+k.marginLeft.split('px')[0];j.top-=l-o,j.bottom-=l-o,j.left-=m-p,j.right-=m-p,j.marginTop=o,j.marginLeft=p}return d.contains(h)&&(isIE10||'BODY'!==h.nodeName)&&(j=includeScroll(j,d)),j}function getReferenceOffsets(c,d,e){const f=findCommonOffsetParent(d,e);return getOffsetRectRelativeToArbitraryNode(e,f)}function getOuterSizes(c){const d=window.getComputedStyle(c),e=parseFloat(d.marginTop)+parseFloat(d.marginBottom),f=parseFloat(d.marginLeft)+parseFloat(d.marginRight),g={width:c.offsetWidth+f,height:c.offsetHeight+e};return g}function getOppositePlacement(c){const d={left:'right',right:'left',bottom:'top',top:'bottom'};return c.replace(/left|right|bottom|top/g,(e)=>d[e])}function getPopperOffsets(c,d,e,f){f=f.split('-')[0];const g=getOuterSizes(d),h={position:c,width:g.width,height:g.height},j=-1!==['right','left'].indexOf(f),k=j?'top':'left',l=j?'left':'top',m=j?'height':'width',o=j?'width':'height';return h[k]=e[k]+e[m]/2-g[m]/2,h[l]=f===l?e[l]-g[o]:e[getOppositePlacement(l)],h}function isFunction(c){return c&&'[object Function]'==={}.toString.call(c)}function attachToScrollParents(c,d,e,f){const g='BODY'===c.nodeName,h=g?window:c;h.addEventListener(d,e,{passive:!0}),g||attachToScrollParents(getScrollParent(h.parentNode),d,e,f),f.push(h)}function setupEventListeners(c,d,e,f){e.updateBound=f,window.addEventListener('resize',e.updateBound,{passive:!0});const g=getScrollParent(c);return attachToScrollParents(g,'scroll',e.updateBound,e.scrollParents),e.scrollElement=g,e.eventsEnabled=!0,e}function removeEventListeners(c,d){return window.removeEventListener('resize',d.updateBound),d.scrollParents.forEach((e)=>{e.removeEventListener('scroll',d.updateBound)}),d.updateBound=null,d.scrollParents=[],d.scrollElement=null,d.eventsEnabled=!1,d}function find(c,d){return Array.prototype.find?c.find(d):c.filter(d)[0]}function findIndex(c,d,e){if(Array.prototype.findIndex)return c.findIndex((g)=>g[d]===e);const f=find(c,(g)=>g[d]===e);return c.indexOf(f)}function runModifiers(c,d,e){const f=void 0===e?c:c.slice(0,findIndex(c,'name',e));return f.forEach((g)=>{g.enabled&&isFunction(g.function)&&(d=g.function(d,g))}),d}function isModifierEnabled(c,d){return c.some(({name:e,enabled:f})=>f&&e===d)}function getViewportOffsetRectRelativeToArtbitraryNode(c){const d=window.document.documentElement,e=getOffsetRectRelativeToArbitraryNode(c,d),f=_Mathmax(d.clientWidth,window.innerWidth||0),g=_Mathmax(d.clientHeight,window.innerHeight||0),h=getScroll(d),j=getScroll(d,'left'),k={top:h-e.top+e.marginTop,left:j-e.left+e.marginLeft,width:f,height:g};return getClientRect(k)}function isFixed(c){const d=c.nodeName;return'BODY'===d||'HTML'===d?!1:!('fixed'!==getStyleComputedProperty(c,'position'))||isFixed(getParentNode(c))}function getBoundaries(c,d,e,f){let g={top:0,left:0};const h=findCommonOffsetParent(c,d);if('viewport'===f)g=getViewportOffsetRectRelativeToArtbitraryNode(h);else{let j;'scrollParent'===f?(j=getScrollParent(getParentNode(c)),'BODY'===j.nodeName&&(j=window.document.documentElement)):'window'===f?j=window.document.documentElement:j=f;const k=getOffsetRectRelativeToArbitraryNode(j,h);if('HTML'===j.nodeName&&!isFixed(h)){const{height:l,width:m}=getWindowSizes();g.top+=k.top-k.marginTop,g.bottom=l+k.top,g.left+=k.left-k.marginLeft,g.right=m+k.left}else g=k}return g.left+=e,g.top+=e,g.right-=e,g.bottom-=e,g}function computeAutoPlacement(c,d,e,f){if(-1===c.indexOf('auto'))return c;const g=getBoundaries(e,f,0,'scrollParent'),h={top:d.top-g.top,right:g.right-d.right,bottom:g.bottom-d.bottom,left:d.left-g.left},j=Object.keys(h).sort((l,m)=>h[m]-h[l])[0],k=c.split('-')[1];return j+(k?`-${k}`:'')}const placements=['auto-start','auto','auto-end','top-start','top','top-end','right-start','right','right-end','bottom-end','bottom','bottom-start','left-end','left','left-start'];function setAttributes(c,d){Object.keys(d).forEach(function(e){const f=d[e];!1===f?c.removeAttribute(e):c.setAttribute(e,d[e])})}function applyStyle(c,d){const e={position:c.offsets.popper.position},f={'x-placement':c.placement},g=_Mathround(c.offsets.popper.left),h=_Mathround(c.offsets.popper.top),j=getSupportedPropertyName('transform');return d.gpuAcceleration&&j?(e[j]='translate3d('+g+'px, '+h+'px, 0)',e.top=0,e.left=0,e.willChange='transform'):(e.left=g,e.top=h,e.willChange='top, left'),setStyles(c.instance.popper,_extends({},e,c.styles)),setAttributes(c.instance.popper,_extends({},f,c.attributes)),c.offsets.arrow&&setStyles(c.arrowElement,c.offsets.arrow),c}function applyStyleOnLoad(c,d,e,f,g){const h=getReferenceOffsets(g,d,c);return e.placement=computeAutoPlacement(e.placement,h,d,c),d.setAttribute('x-placement',e.placement),e}function isModifierRequired(c,d,e){const f=find(c,({name:g})=>g===d);return!!f&&c.some((g)=>{return g.name===e&&g.enabled&&g.order<f.order})}function arrow(c,d){if(!isModifierRequired(c.instance.modifiers,'arrow','keepTogether'))return console.warn('WARNING: `keepTogether` modifier is required by arrow modifier in order to work, be sure to include it before `arrow`!'),c;let e=d.element;if('string'==typeof e){if(e=c.instance.popper.querySelector(e),!e)return c;}else if(!c.instance.popper.contains(e))return console.warn('WARNING: `arrow.element` must be child of its popper element!'),c;const f=c.placement.split('-')[0],g=getClientRect(c.offsets.popper),h=c.offsets.reference,j=-1!==['left','right'].indexOf(f),k=j?'height':'width',l=j?'top':'left',m=j?'left':'top',o=j?'bottom':'right',p=getOuterSizes(e)[k];h[o]-p<g[l]&&(c.offsets.popper[l]-=g[l]-(h[o]-p)),h[l]+p>g[o]&&(c.offsets.popper[l]+=h[l]+p-g[o]);const q=h[l]+h[k]/2-p/2;let r=q-getClientRect(c.offsets.popper)[l];return r=_Mathmax(_Mathmin(g[k]-p,r),0),c.arrowElement=e,c.offsets.arrow={},c.offsets.arrow[l]=r,c.offsets.arrow[m]='',c}function getOppositeVariation(c){if('end'===c)return'start';return'start'===c?'end':c}const validPlacements=placements.slice(3);function clockwise(c,d=!1){const e=validPlacements.indexOf(c),f=validPlacements.slice(e+1).concat(validPlacements.slice(0,e));return d?f.reverse():f}const BEHAVIORS={FLIP:'flip',CLOCKWISE:'clockwise',COUNTERCLOCKWISE:'counterclockwise'};function flip(c,d){if(isModifierEnabled(c.instance.modifiers,'inner'))return c;if(c.flipped&&c.placement===c.originalPlacement)return c;const e=getBoundaries(c.instance.popper,c.instance.reference,d.padding,d.boundariesElement);let f=c.placement.split('-')[0],g=getOppositePlacement(f),h=c.placement.split('-')[1]||'',j=[];switch(d.behavior){case BEHAVIORS.FLIP:j=[f,g];break;case BEHAVIORS.CLOCKWISE:j=clockwise(f);break;case BEHAVIORS.COUNTERCLOCKWISE:j=clockwise(f,!0);break;default:j=d.behavior;}return j.forEach((k,l)=>{if(f!==k||j.length===l+1)return c;f=c.placement.split('-')[0],g=getOppositePlacement(f);const m=getClientRect(c.offsets.popper),o=c.offsets.reference,p=_Mathfloor,q='left'===f&&p(m.right)>p(o.left)||'right'===f&&p(m.left)<p(o.right)||'top'===f&&p(m.bottom)>p(o.top)||'bottom'===f&&p(m.top)<p(o.bottom),r=p(m.left)<p(e.left),s=p(m.right)>p(e.right),t=p(m.top)<p(e.top),u=p(m.bottom)>p(e.bottom),v='left'===f&&r||'right'===f&&s||'top'===f&&t||'bottom'===f&&u,w=-1!==['top','bottom'].indexOf(f),z=!!d.flipVariations&&(w&&'start'===h&&r||w&&'end'===h&&s||!w&&'start'===h&&t||!w&&'end'===h&&u);(q||v||z)&&(c.flipped=!0,(q||v)&&(f=j[l+1]),z&&(h=getOppositeVariation(h)),c.placement=f+(h?'-'+h:''),c.offsets.popper=getPopperOffsets(c.instance.state.position,c.instance.popper,c.offsets.reference,c.placement),c=runModifiers(c.instance.modifiers,c,'flip'))}),c}function keepTogether(c){const d=getClientRect(c.offsets.popper),e=c.offsets.reference,f=c.placement.split('-')[0],g=_Mathfloor,h=-1!==['top','bottom'].indexOf(f),j=h?'right':'bottom',k=h?'left':'top',l=h?'width':'height';return d[j]<g(e[k])&&(c.offsets.popper[k]=g(e[k])-d[l]),d[k]>g(e[j])&&(c.offsets.popper[k]=g(e[j])),c}function offset(c,d){const e=c.placement,f=c.offsets.popper;let g;return isNumeric(d.offset)?g=[d.offset,0]:(g=d.offset.split(' '),g=g.map((h,j)=>{const k=h.match(/(\d*\.?\d*)(.*)/),l=+k[1],m=k[2];let o=-1!==e.indexOf('right')||-1!==e.indexOf('left');1===j&&(o=!o);const p=o?'height':'width';if(0===m.indexOf('%')){let q;switch(m){case'%p':q=c.offsets.popper;break;case'%':case'$r':default:q=c.offsets.reference;}const r=getClientRect(q),s=r[p];return s/100*l}if('vh'===m||'vw'===m){let q;return q='vh'===m?_Mathmax(document.documentElement.clientHeight,window.innerHeight||0):_Mathmax(document.documentElement.clientWidth,window.innerWidth||0),q/100*l}return'px'===m?+l:+h})),-1===c.placement.indexOf('left')?-1===c.placement.indexOf('right')?-1===c.placement.indexOf('top')?-1!==c.placement.indexOf('bottom')&&(f.left+=g[0],f.top+=g[1]||0):(f.left+=g[0],f.top-=g[1]||0):(f.top+=g[0],f.left+=g[1]||0):(f.top+=g[0],f.left-=g[1]||0),c}function preventOverflow(c,d){const e=d.boundariesElement||getOffsetParent(c.instance.popper),f=getBoundaries(c.instance.popper,c.instance.reference,d.padding,e);d.boundaries=f;const g=d.priority;let h=getClientRect(c.offsets.popper);const j={primary(k){let l=h[k];return h[k]<f[k]&&!d.escapeWithReference&&(l=_Mathmax(h[k],f[k])),{[k]:l}},secondary(k){const l='right'===k?'left':'top';let m=h[l];return h[k]>f[k]&&!d.escapeWithReference&&(m=_Mathmin(h[l],f[k]-('right'===k?h.width:h.height))),{[l]:m}}};return g.forEach((k)=>{const l=-1===['left','top'].indexOf(k)?'secondary':'primary';h=_extends({},h,j[l](k))}),c.offsets.popper=h,c}function shift(c){const d=c.placement,e=d.split('-')[0],f=d.split('-')[1];if(f){const g=c.offsets.reference,h=getClientRect(c.offsets.popper),j=-1!==['bottom','top'].indexOf(e),k=j?'left':'top',l=j?'width':'height',m={start:{[k]:g[k]},end:{[k]:g[k]+g[l]-h[l]}};c.offsets.popper=_extends({},h,m[f])}return c}function hide(c){if(!isModifierRequired(c.instance.modifiers,'hide','preventOverflow'))return console.warn('WARNING: preventOverflow modifier is required by hide modifier in order to work, be sure to include it before hide!'),c;const d=c.offsets.reference,e=find(c.instance.modifiers,(f)=>'preventOverflow'===f.name).boundaries;if(d.bottom<e.top||d.left>e.right||d.top>e.bottom||d.right<e.left){if(!0===c.hide)return c;c.hide=!0,c.attributes['x-out-of-boundaries']=''}else{if(!1===c.hide)return c;c.hide=!1,c.attributes['x-out-of-boundaries']=!1}return c}function inner(c){const d=c.placement,e=d.split('-')[0],f=getClientRect(c.offsets.popper),g=getClientRect(c.offsets.reference),h=-1!==['left','right'].indexOf(e),j=-1===['top','left'].indexOf(e);return f[h?'left':'top']=g[d]-(j?f[h?'width':'height']:0),c.placement=getOppositePlacement(d),c.offsets.popper=getClientRect(f),c}var modifiers={shift:{order:100,enabled:!0,function:shift},offset:{order:200,enabled:!0,function:offset,offset:0},preventOverflow:{order:300,enabled:!0,function:preventOverflow,priority:['left','right','top','bottom'],padding:5,boundariesElement:'scrollParent'},keepTogether:{order:400,enabled:!0,function:keepTogether},arrow:{order:500,enabled:!0,function:arrow,element:'[x-arrow]'},flip:{order:600,enabled:!0,function:flip,behavior:'flip',padding:5,boundariesElement:'viewport'},inner:{order:700,enabled:!1,function:inner},hide:{order:800,enabled:!0,function:hide},applyStyle:{order:900,enabled:!0,function:applyStyle,onLoad:applyStyleOnLoad,gpuAcceleration:!0}};const DEFAULTS={placement:'bottom',eventsEnabled:!0,removeOnDestroy:!1,onCreate:()=>{},onUpdate:()=>{},modifiers};class Popper{constructor(c,d,e={}){this.scheduleUpdate=()=>requestAnimationFrame(this.update),this.update=debounce(this.update.bind(this)),this.options=_extends({},Popper.Defaults,e),this.state={isDestroyed:!1,isCreated:!1,scrollParents:[]},this.reference=c.jquery?c[0]:c,this.popper=d.jquery?d[0]:d,setStyles(this.popper,{position:'absolute'}),this.modifiers=Object.keys(Popper.Defaults.modifiers).map((g)=>_extends({name:g},Popper.Defaults.modifiers[g])),this.modifiers=this.modifiers.map((g)=>{const h=e.modifiers&&e.modifiers[g.name]||{};return _extends({},g,h)}),e.modifiers&&(this.options.modifiers=_extends({},Popper.Defaults.modifiers,e.modifiers),Object.keys(e.modifiers).forEach((g)=>{if(Popper.Defaults.modifiers[g]===void 0){const h=e.modifiers[g];h.name=g,this.modifiers.push(h)}})),this.modifiers=this.modifiers.sort((g,h)=>g.order-h.order),this.modifiers.forEach((g)=>{g.enabled&&isFunction(g.onLoad)&&g.onLoad(this.reference,this.popper,this.options,g,this.state)}),this.update();const f=this.options.eventsEnabled;f&&this.enableEventListeners(),this.state.eventsEnabled=f}update(){if(this.state.isDestroyed)return;let c={instance:this,styles:{},attributes:{},flipped:!1,offsets:{}};c.offsets.reference=getReferenceOffsets(this.state,this.popper,this.reference),c.placement=computeAutoPlacement(this.options.placement,c.offsets.reference,this.popper,this.reference),c.originalPlacement=this.options.placement,c.offsets.popper=getPopperOffsets(this.state,this.popper,c.offsets.reference,c.placement),c=runModifiers(this.modifiers,c),this.state.isCreated?this.options.onUpdate(c):(this.state.isCreated=!0,this.options.onCreate(c))}destroy(){return this.state.isDestroyed=!0,isModifierEnabled(this.modifiers,'applyStyle')&&(this.popper.removeAttribute('x-placement'),this.popper.style.left='',this.popper.style.position='',this.popper.style.top='',this.popper.style[getSupportedPropertyName('transform')]=''),this.disableEventListeners(),this.options.removeOnDestroy&&this.popper.parentNode.removeChild(this.popper),this}enableEventListeners(){this.state.eventsEnabled||(this.state=setupEventListeners(this.reference,this.options,this.state,this.scheduleUpdate))}disableEventListeners(){this.state.eventsEnabled&&(window.cancelAnimationFrame(this.scheduleUpdate),this.state=removeEventListeners(this.reference,this.state))}}Popper.Utils=window.PopperUtils,Popper.placements=placements,Popper.Defaults=DEFAULTS;export default Popper;
//# sourceMappingURL=popper.min.js.map