UNPKG

6.45 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("ngx-bootstrap/component-loader"),require("ngx-bootstrap/utils"),require("ngx-bootstrap/positioning"),require("rxjs"),require("@angular/common")):"function"==typeof define&&define.amd?define("ngx-bootstrap/popover",["exports","@angular/core","ngx-bootstrap/component-loader","ngx-bootstrap/utils","ngx-bootstrap/positioning","rxjs","@angular/common"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self)["ngx-bootstrap"]=e["ngx-bootstrap"]||{},e["ngx-bootstrap"].popover={}),e.ng.core,e.componentLoader,e.utils,e.positioning,e.rxjs,e.ng.common)}(this,(function(e,t,o,n,i,r,s){"use strict";var p=function(){this.adaptivePosition=!0,this.placement="top",this.triggers="click",this.outsideClick=!1,this.delay=0};p.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new p},token:p,providedIn:"root"}),p.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}];var a=function(){function e(e){this._placement="top",Object.assign(this,e)}return Object.defineProperty(e.prototype,"placement",{set:function(e){this._bsVersions.isBs5?this._placement=i.PlacementForBs5[e]:this._placement=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_bsVersions",{get:function(){return n.getBsVer()},enumerable:!1,configurable:!0}),e.prototype.checkMarginNecessity=function(){return i.checkMargins(this._placement)},e}();a.decorators=[{type:t.Component,args:[{selector:"popover-container",changeDetection:t.ChangeDetectionStrategy.OnPush,host:{"[attr.id]":"popoverId","[class]":'"popover in popover-" + _placement + " " + "bs-popover-" + _placement + " " + _placement + " " + containerClass + checkMarginNecessity()',"[class.show]":"!_bsVersions.isBs3","[class.bs3]":"_bsVersions.isBs3",role:"tooltip",style:"display:block;"},template:'<div class="popover-arrow arrow"></div>\n<h3 class="popover-title popover-header" *ngIf="title">{{ title }}</h3>\n<div class="popover-content popover-body">\n <ng-content></ng-content>\n</div>\n',styles:["\n :host.bs3.popover-top {\n margin-bottom: 10px;\n }\n :host.bs3.popover.top>.arrow {\n margin-left: -2px;\n }\n :host.bs3.popover.top {\n margin-bottom: 10px;\n }\n :host.popover.bottom>.arrow {\n margin-left: -4px;\n }\n :host.bs3.bs-popover-left {\n margin-right: .5rem;\n }\n :host.bs3.bs-popover-right .arrow, :host.bs3.bs-popover-left .arrow{\n margin: .3rem 0;\n }\n "]}]}],a.ctorParameters=function(){return[{type:p}]},a.propDecorators={placement:[{type:t.Input}],title:[{type:t.Input}]};var c=0,l=function(){function e(e,t,o,n,i,r){this._elementRef=t,this._renderer=o,this._positionService=r,this.popoverId=c++,this.adaptivePosition=!0,this.placement="top",this.outsideClick=!1,this.triggers="click",this.containerClass="",this.delay=0,this._isInited=!1,this._popover=i.createLoader(t,n,o).provide({provide:p,useValue:e}),Object.assign(this,e),this.onShown=this._popover.onShown,this.onHidden=this._popover.onHidden,"undefined"!=typeof window&&t.nativeElement.addEventListener("click",(function(){try{t.nativeElement.focus()}catch(e){return}}))}return Object.defineProperty(e.prototype,"isOpen",{get:function(){return this._popover.isShown},set:function(e){e?this.show():this.hide()},enumerable:!1,configurable:!0}),e.prototype.setAriaDescribedBy=function(){this._ariaDescribedby=this.isOpen?"ngx-popover-"+this.popoverId:void 0,this._ariaDescribedby?(this._popover.instance&&(this._popover.instance.popoverId=this._ariaDescribedby),this._renderer.setAttribute(this._elementRef.nativeElement,"aria-describedby",this._ariaDescribedby)):this._renderer.removeAttribute(this._elementRef.nativeElement,"aria-describedby")},e.prototype.show=function(){var e=this;if(!this._popover.isShown&&this.popover&&!this._delayTimeoutId){this._positionService.setOptions({modifiers:{flip:{enabled:this.adaptivePosition},preventOverflow:{enabled:this.adaptivePosition}}});var t=function(){e._delayTimeoutId&&(e._delayTimeoutId=void 0),e._popover.attach(a).to(e.container).position({attachment:e.placement}).show({content:e.popover,context:e.popoverContext,placement:e.placement,title:e.popoverTitle,containerClass:e.containerClass}),!e.adaptivePosition&&e._popover._componentRef&&(e._positionService.calcPosition(),e._positionService.deletePositionElement(e._popover._componentRef.location)),e.isOpen=!0,e.setAriaDescribedBy()},o=function(){e._popoverCancelShowFn&&e._popoverCancelShowFn()};if(this.delay){var i=r.timer(this.delay).subscribe((function(){t(),o()}));this.triggers&&n.parseTriggers(this.triggers).forEach((function(t){t.close&&(e._popoverCancelShowFn=e._renderer.listen(e._elementRef.nativeElement,t.close,(function(){i.unsubscribe(),o()})))}))}else t()}},e.prototype.hide=function(){this._delayTimeoutId&&(clearTimeout(this._delayTimeoutId),this._delayTimeoutId=void 0),this.isOpen&&(this._popover.hide(),this.setAriaDescribedBy(),this.isOpen=!1)},e.prototype.toggle=function(){if(this.isOpen)return this.hide();this.show()},e.prototype.ngOnInit=function(){var e=this;this._isInited||(this._isInited=!0,this._popover.listen({triggers:this.triggers,outsideClick:this.outsideClick,show:function(){return e.show()},hide:function(){return e.hide()}}))},e.prototype.ngOnDestroy=function(){this._popover.dispose()},e}();l.decorators=[{type:t.Directive,args:[{selector:"[popover]",exportAs:"bs-popover"}]}],l.ctorParameters=function(){return[{type:p},{type:t.ElementRef},{type:t.Renderer2},{type:t.ViewContainerRef},{type:o.ComponentLoaderFactory},{type:i.PositioningService}]},l.propDecorators={adaptivePosition:[{type:t.Input}],popover:[{type:t.Input}],popoverContext:[{type:t.Input}],popoverTitle:[{type:t.Input}],placement:[{type:t.Input}],outsideClick:[{type:t.Input}],triggers:[{type:t.Input}],container:[{type:t.Input}],containerClass:[{type:t.Input}],isOpen:[{type:t.Input}],delay:[{type:t.Input}],onShown:[{type:t.Output}],onHidden:[{type:t.Output}]};var d=function(){function e(){}return e.forRoot=function(){return{ngModule:e,providers:[o.ComponentLoaderFactory,i.PositioningService]}},e}();d.decorators=[{type:t.NgModule,args:[{imports:[s.CommonModule],declarations:[l,a],exports:[l],entryComponents:[a]}]}],e.PopoverConfig=p,e.PopoverContainerComponent=a,e.PopoverDirective=l,e.PopoverModule=d,Object.defineProperty(e,"__esModule",{value:!0})}));
2//# sourceMappingURL=ngx-bootstrap-popover.umd.min.js.map
\No newline at end of file