ngx-bootstrap-ci
Version:
Native Angular Bootstrap Components
2 lines • 13.5 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("rxjs")):"function"==typeof define&&define.amd?define("ngx-bootstrap/positioning",["exports","@angular/core","@angular/common","rxjs"],e):e((t["ngx-bootstrap"]=t["ngx-bootstrap"]||{},t["ngx-bootstrap"].positioning={}),t.ng.core,t.ng.common,t.rxjs)}(this,function(t,e,r,n){"use strict";var d=function(){return(d=Object.assign||function(t){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};function v(t,e){if(1!==t.nodeType)return[];var o=t.ownerDocument.defaultView.getComputedStyle(t,null);return e?o[e]:o}function h(t){return"HTML"===t.nodeName?t:t.parentNode||t.host}function g(t){if(!t)return document.body;switch(t.nodeName){case"HTML":case"BODY":return t.ownerDocument.body;case"#document":return t.body}var e=v(t),o=e.overflow,r=e.overflowX,n=e.overflowY;return/(auto|scroll|overlay)/.test(String(o)+String(n)+String(r))?t:g(h(t))}var o="undefined"!=typeof window&&"undefined"!=typeof document,i=o&&!(!window.MSInputMethodContext||!document.documentMode),a=o&&/MSIE 10/.test(navigator.userAgent);function b(t){return 11===t?i:10===t?a:i||a}function l(t){if(!t)return document.documentElement;for(var e,o=b(10)?document.body:null,r=t.offsetParent||null;r===o&&t.nextElementSibling;)r=(e=t.nextElementSibling).offsetParent;var n=r&&r.nodeName;return n&&"BODY"!==n&&"HTML"!==n?-1!==["TH","TD","TABLE"].indexOf(r.nodeName)&&"static"===v(r,"position")?l(r):r:e?e.ownerDocument.documentElement:document.documentElement}function u(t){return null!==t.parentNode?u(t.parentNode):t}function w(t,e){if(!(t&&t.nodeType&&e&&e.nodeType))return document.documentElement;var o=t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING,r=o?t:e,n=o?e:t,i=document.createRange();i.setStart(r,0),i.setEnd(n,0);var a=i.commonAncestorContainer;if(t!==a&&e!==a||r.contains(n))return function f(t){var e=t.nodeName;return"BODY"!==e&&("HTML"===e||l(t.firstElementChild)===t)}(a)?a:l(a);var s=u(t);return s.host?w(s.host,e):w(t,u(e).host)}function p(t,e){var o="x"===e?"Left":"Top",r="Left"===o?"Right":"Bottom";return parseFloat(t["border"+o+"Width"])+parseFloat(t["border"+r+"Width"])}function s(t,e,o,r){return Math.max(e["offset"+t],e["scroll"+t],o["client"+t],o["offset"+t],o["scroll"+t],b(10)?parseInt(o["offset"+t],10)+parseInt(r["margin"+("Height"===t?"Top":"Left")],10)+parseInt(r["margin"+("Height"===t?"Bottom":"Right")],10):0)}function N(t){var e=t.body,o=t.documentElement,r=b(10)&&getComputedStyle(o);return{height:s("Height",e,o,r),width:s("Width",e,o,r)}}function y(t,e){void 0===e&&(e="top");var o="top"===e?"scrollTop":"scrollLeft",r=t.nodeName;if("BODY"!==r&&"HTML"!==r)return t[o];var n=t.ownerDocument.documentElement;return(t.ownerDocument.scrollingElement||n)[o]}function M(t){return d({},t,{right:t.left+t.width,bottom:t.top+t.height})}function E(t){var e={};try{if(b(10)){e=t.getBoundingClientRect();var o=y(t,"top"),r=y(t,"left");e.top+=o,e.left+=r,e.bottom+=o,e.right+=r}else e=t.getBoundingClientRect()}catch(c){return undefined}var n={left:e.left,top:e.top,width:e.right-e.left,height:e.bottom-e.top},i="HTML"===t.nodeName?N(t.ownerDocument):{},a=i.width||t.clientWidth||n.right-n.left,s=i.height||t.clientHeight||n.bottom-n.top,f=t.offsetWidth-a,l=t.offsetHeight-s;if(f||l){var u=v(t);f-=p(u,"x"),l-=p(u,"y"),n.width-=f,n.height-=l}return M(n)}function x(t,e,o){void 0===o&&(o=!1);var r=b(10),n="HTML"===e.nodeName,i=E(t),a=E(e),s=g(t),f=v(e),l=parseFloat(f.borderTopWidth),u=parseFloat(f.borderLeftWidth);o&&n&&(a.top=Math.max(a.top,0),a.left=Math.max(a.left,0));var c=M({top:i.top-a.top-l,left:i.left-a.left-u,width:i.width,height:i.height});if(c.marginTop=0,c.marginLeft=0,!r&&n){var p=parseFloat(f.marginTop),m=parseFloat(f.marginLeft);c.top-=l-p,c.bottom-=l-p,c.left-=u-m,c.right-=u-m,c.marginTop=p,c.marginLeft=m}return(r&&!o?e.contains(s):e===s&&"BODY"!==s.nodeName)&&(c=function h(t,e,o){void 0===o&&(o=!1);var r=y(e,"top"),n=y(e,"left"),i=o?-1:1;return t.top+=r*i,t.bottom+=r*i,t.left+=n*i,t.right+=n*i,t}(c,e)),c}function T(t){if(!t||!t.parentElement||b())return document.documentElement;for(var e=t.parentElement;e&&"none"===v(e,"transform");)e=e.parentElement;return e||document.documentElement}function L(t,e,o,r,n){void 0===o&&(o=0),void 0===n&&(n=!1);var i={top:0,left:0},a=n?T(t):w(t,e);if("viewport"===r)i=function p(t,e){void 0===e&&(e=!1);var o=t.ownerDocument.documentElement,r=x(t,o),n=Math.max(o.clientWidth,window.innerWidth||0),i=Math.max(o.clientHeight,window.innerHeight||0),a=e?0:y(o),s=e?0:y(o,"left");return M({top:a-Number(r.top)+Number(r.marginTop),left:s-Number(r.left)+Number(r.marginLeft),width:n,height:i})}(a,n);else{var s=void 0;"scrollParent"===r?"BODY"===(s=g(h(e))).nodeName&&(s=t.ownerDocument.documentElement):s="window"===r?t.ownerDocument.documentElement:r;var f=x(s,a,n);if("HTML"!==s.nodeName||function m(t){var e=t.nodeName;return"BODY"!==e&&"HTML"!==e&&("fixed"===v(t,"position")||m(h(t)))}(a))i=f;else{var l=N(t.ownerDocument),u=l.height,c=l.width;i.top+=f.top-f.marginTop,i.bottom=Number(u)+Number(f.top),i.left+=f.left-f.marginLeft,i.right=Number(c)+Number(f.left)}}return i.left+=o,i.top+=o,i.right-=o,i.bottom-=o,i}function f(t,e,r,o,n,i,a){if(void 0===n&&(n=["top","left","bottom","right"]),void 0===i&&(i="viewport"),void 0===a&&(a=0),-1===t.indexOf("auto"))return t;var s=L(r,o,a,i),f={top:{width:s.width,height:e.top-s.top},right:{width:s.right-e.right,height:s.height},bottom:{width:s.width,height:s.bottom-e.bottom},left:{width:e.left-s.left,height:s.height}},l=Object.keys(f).map(function(t){return d({key:t},f[t],{area:function e(t){return t.width*t.height}(f[t])})}).sort(function(t,e){return e.area-t.area}),u=l.filter(function(t){var e=t.width,o=t.height;return e>=r.clientWidth&&o>=r.clientHeight}),c=0<(u=n.reduce(function(t,e){return d({},t,((o={})[e]=u[e],o));var o},{})).length?u[0].key:l[0].key,p=t.split(" ")[1];return r.className=r.className.replace(/auto/g,c),c+(p?"-"+p:"")}function O(t){var e=t.ownerDocument.defaultView.getComputedStyle(t),o=parseFloat(e.marginTop||0)+parseFloat(e.marginBottom||0),r=parseFloat(e.marginLeft||0)+parseFloat(e.marginRight||0);return{width:Number(t.offsetWidth)+r,height:Number(t.offsetHeight)+o}}function c(t,e,o){return void 0===o&&(o=null),x(e,o?T(t):w(t,e),o)}function D(t,e,o){var r=o.split(" ")[0],n=O(t),i={width:n.width,height:n.height},a=-1!==["right","left"].indexOf(r),s=a?"top":"left",f=a?"left":"top",l=a?"height":"width",u=a?"width":"height";return i[s]=e[s]+e[l]/2-n[l]/2,i[f]=r===f?e[f]-n[u]:e[function c(t){var e={left:"right",right:"left",bottom:"top",top:"bottom"};return t.replace(/left|right|bottom|top/g,function(t){return e[t]})}(f)],i}function m(t,e){var o=t.instance.target,r=function n(t){return{width:t.offsets.target.width,height:t.offsets.target.height,left:Math.floor(t.offsets.target.left),top:Math.round(t.offsets.target.top),bottom:Math.round(t.offsets.target.bottom),right:Math.floor(t.offsets.target.right)}}(t);S(o,{"will-change":"transform",top:"0px",left:"0px",transform:"translate3d("+r.left+"px, "+r.top+"px, 0px)"},e),t.instance.arrow&&S(t.instance.arrow,t.offsets.arrow,e),t.placementAuto&&(e?(e.setAttribute(o,"class",o.className.replace(/bs-popover-auto/g,"bs-popover-"+t.placement)),e.setAttribute(o,"class",o.className.replace(/bs-tooltip-auto/g,"bs-tooltip-"+t.placement)),e.setAttribute(o,"class",o.className.replace(/\sauto/g,"s"+t.placement)),o.className.match(/popover/g)&&e.addClass(o,"popover-auto"),o.className.match(/tooltip/g)&&e.addClass(o,"tooltip-auto")):(o.className=o.className.replace(/bs-popover-auto/g,"bs-popover-"+t.placement),o.className=o.className.replace(/bs-tooltip-auto/g,"bs-tooltip-"+t.placement),o.className=o.className.replace(/\sauto/g,"s"+t.placement),o.className.match(/popover/g)&&o.classList.add("popover-auto"),o.className.match(/tooltip/g)&&o.classList.add("tooltip-auto"))),e?e.setAttribute(o,"class",o.className.replace(/left|right|top|bottom/g,""+t.placement)):o.className=o.className.replace(/left|right|top|bottom/g,""+t.placement)}function S(r,n,i){Object.keys(n).forEach(function(t){var e="";-1!==["width","height","top","right","bottom","left"].indexOf(t)&&function o(t){return""!==t&&!isNaN(parseFloat(t))&&isFinite(t)}(n[t])&&(e="px"),i?i.setStyle(r,t,""+String(n[t])+e):r.style[t]=String(n[t])+e})}function F(t){var e=t.offsets.target,o=t.instance.target.querySelector(".arrow");if(!o)return t;var r=-1!==["left","right"].indexOf(t.placement),n=r?"height":"width",i=r?"Top":"Left",a=i.toLowerCase(),s=r?"left":"top",f=r?"bottom":"right",l=O(o)[n];t.offsets.host[f]-l<e[a]&&(e[a]-=e[a]-(t.offsets.host[f]-l)),Number(t.offsets.host[a])+Number(l)>e[f]&&(e[a]+=Number(t.offsets.host[a])+Number(l)-Number(e[f])),e=M(e);var u,c=Number(t.offsets.host[a])+Number(t.offsets.host[n]/2-l/2),p=v(t.instance.target),m=parseFloat(p["margin"+i]),h=parseFloat(p["border"+i+"Width"]),g=c-e[a]-m-h;return g=Math.max(Math.min(e[n]-l,g),0),t.offsets.arrow=((u={})[a]=Math.round(g),u[s]="",u),t.instance.arrow=o,t}function H(c){if(c.offsets.target=M(c.offsets.target),!function n(t,e){return t&&t.modifiers&&t.modifiers[e]&&t.modifiers[e].enabled}(c.options,"flip"))return c.offsets.target=d({},c.offsets.target,D(c.instance.target,c.offsets.host,c.placement)),c;var p=L(c.instance.target,c.instance.host,0,"viewport",!1),m=c.placement.split(" ")[0],h=c.placement.split(" ")[1]||"",t=c.offsets.host,e=c.instance.target,o=c.instance.host,r=h?f("auto",t,e,o,["top","bottom"]):f("auto",t,e,o),g=[m,r];return g.forEach(function(t,e){if(m!==t||g.length===e+1)return c;var o="left"===(m=c.placement.split(" ")[0])&&Math.floor(c.offsets.target.right)>Math.floor(c.offsets.host.left)||"right"===m&&Math.floor(c.offsets.target.left)<Math.floor(c.offsets.host.right)||"top"===m&&Math.floor(c.offsets.target.bottom)>Math.floor(c.offsets.host.top)||"bottom"===m&&Math.floor(c.offsets.target.top)<Math.floor(c.offsets.host.bottom),r=Math.floor(c.offsets.target.left)<Math.floor(p.left),n=Math.floor(c.offsets.target.right)>Math.floor(p.right),i=Math.floor(c.offsets.target.top)<Math.floor(p.top),a=Math.floor(c.offsets.target.bottom)>Math.floor(p.bottom),s="left"===m&&r||"right"===m&&n||"top"===m&&i||"bottom"===m&&a,f=-1!==["top","bottom"].indexOf(m),l=f&&"left"===h&&r||f&&"right"===h&&n||!f&&"left"===h&&i||!f&&"right"===h&&a;(o||s||l)&&((o||s)&&(m=g[e+1]),l&&(h=function u(t){return"right"===t?"left":"left"===t?"right":t}(h)),c.placement=m+(h?" "+h:""),c.offsets.target=d({},c.offsets.target,D(c.instance.target,c.offsets.host,c.placement)))}),c}function P(n){var t="transform",e=n.instance.target.style,o=e.top,r=e.left,i=e.transform;e.top="",e.left="",e[t]="";var a=L(n.instance.target,n.instance.host,0,"scrollParent",!1);e.top=o,e.left=r,e[t]=i;var s,f={primary:function(t){var e,o=n.offsets.target[t];return n.offsets.target[t]<a[t]&&(o=Math.max(n.offsets.target[t],a[t])),(e={})[t]=o,e},secondary:function(t){var e,o="right"===t?"left":"top",r=n.offsets.target[o];return n.offsets.target[t]>a[t]&&(r=Math.min(n.offsets.target[o],a[t]-("right"===t?n.offsets.target.width:n.offsets.target.height))),(e={})[o]=r,e}};return["left","right","top","bottom"].forEach(function(t){s=-1!==["left","top"].indexOf(t)?"primary":"secondary",n.offsets.target=d({},n.offsets.target,f[s](t))}),n}function B(t){var e,o,r=t.placement,n=r.split(" ")[0],i=r.split(" ")[1];if(i){var a=t.offsets,s=a.host,f=a.target,l=-1!==["bottom","top"].indexOf(n),u=l?"left":"top",c=l?"width":"height",p={left:(e={},e[u]=s[u],e),right:(o={},o[u]=s[u]+s[c]-s[c],o)};t.offsets.target=d({},f,p[i])}return t}var W=function(){function t(){}return t.prototype.position=function(t,e,o){return void 0===o&&(o=!0),this.offset(t,e,!1)},t.prototype.offset=function(t,e,o){return void 0===o&&(o=!0),c(e,t)},t.prototype.positionElements=function(t,e,o,r,n){return[H,B,P,F].reduce(function(t,e){return e(t)},function s(t,e,o,r){var n=c(t,e),i=!!o.match(/auto/g),a=o.match(/auto\s(left|right|top|bottom)/g)?o.split(" ")[1]||"":o;return{options:r,instance:{target:t,host:e,arrow:null},offsets:{target:D(t,n,a),host:n,arrow:null},positionFixed:!1,placement:a=f(a,n,t,e),placementAuto:i}}(e,t,o,n))},t}(),j=new W;function C(t,e,o,r,n,i){m(j.positionElements(t,e,o,r,n),i)}var I=function(){function t(e,t){var o=this;this.update$$=new n.Subject,this.positionElements=new Map,r.isPlatformBrowser(t)&&n.merge(n.fromEvent(window,"scroll"),n.fromEvent(window,"resize"),n.of(0,n.animationFrameScheduler),this.update$$).subscribe(function(){o.positionElements.forEach(function(t){C(A(t.target),A(t.element),t.attachment,t.appendToBody,o.options,e.createRenderer(null,null))})})}return t.prototype.position=function(t){this.addPositionElement(t),this.update$$.next()},t.prototype.addPositionElement=function(t){this.positionElements.set(A(t.element),t)},t.prototype.deletePositionElement=function(t){this.positionElements["delete"](A(t))},t.prototype.setOptions=function(t){this.options=t},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:e.RendererFactory2},{type:undefined,decorators:[{type:e.Inject,args:[e.PLATFORM_ID]}]}]},t}();function A(t){return"string"==typeof t?document.querySelector(t):t instanceof e.ElementRef?t.nativeElement:t}t.positionElements=C,t.Positioning=W,t.PositioningService=I,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ngx-bootstrap-positioning.umd.min.js.map