UNPKG

7.1 kBJavaScriptView Raw
1!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("primeng/dom"),require("primeng/api"),require("@angular/animations")):"function"==typeof define&&define.amd?define("primeng/overlaypanel",["exports","@angular/core","@angular/common","primeng/dom","primeng/api","@angular/animations"],e):e(((t=t||self).primeng=t.primeng||{},t.primeng.overlaypanel={}),t.ng.core,t.ng.common,t.primeng.dom,t.primeng.api,t.ng.animations)}(this,(function(t,e,n,i,o,r){"use strict";var s=this&&this.__decorate||function(t,e,n,i){var o,r=arguments.length,s=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,n,s):o(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s},a=function(){function t(t,n,i,o){this.el=t,this.renderer=n,this.cd=i,this.zone=o,this.dismissable=!0,this.autoZIndex=!0,this.baseZIndex=0,this.showTransitionOptions="225ms ease-out",this.hideTransitionOptions="195ms ease-in",this.onShow=new e.EventEmitter,this.onHide=new e.EventEmitter,this.overlayVisible=!1,this.render=!1,this.isContainerClicked=!0}return t.prototype.ngAfterContentInit=function(){var t=this;this.templates.forEach((function(e){switch(e.getType()){case"content":default:t.contentTemplate=e.template}}))},t.prototype.onContainerClick=function(){this.isContainerClicked=!0},t.prototype.bindDocumentClickListener=function(){var t=this;!this.documentClickListener&&this.dismissable&&this.zone.runOutsideAngular((function(){var e=i.DomHandler.isIOS()?"touchstart":"click";t.documentClickListener=t.renderer.listen("document",e,(function(e){t.container.contains(e.target)||t.target===e.target||t.target.contains(e.target)||t.isContainerClicked||t.zone.run((function(){t.hide()})),t.isContainerClicked=!1,t.cd.markForCheck()}))}))},t.prototype.unbindDocumentClickListener=function(){this.documentClickListener&&(this.documentClickListener(),this.documentClickListener=null)},t.prototype.toggle=function(t,e){var n=this;this.overlayVisible?(this.hasTargetChanged(t,e)&&(this.destroyCallback=function(){n.show(null,e||t.currentTarget||t.target)}),this.overlayVisible=!1):this.show(t,e)},t.prototype.show=function(t,e){this.target=e||t.currentTarget||t.target,this.overlayVisible=!0,this.render=!0},t.prototype.hasTargetChanged=function(t,e){return null!=this.target&&this.target!==(e||t.currentTarget||t.target)},t.prototype.appendContainer=function(){this.appendTo&&("body"===this.appendTo?document.body.appendChild(this.container):i.DomHandler.appendChild(this.container,this.appendTo))},t.prototype.restoreAppend=function(){this.container&&this.appendTo&&this.el.nativeElement.appendChild(this.container)},t.prototype.align=function(){this.autoZIndex&&(this.container.style.zIndex=String(this.baseZIndex+ ++i.DomHandler.zindex)),i.DomHandler.absolutePosition(this.container,this.target),i.DomHandler.getOffset(this.container).top<i.DomHandler.getOffset(this.target).top&&i.DomHandler.addClass(this.container,"ui-overlaypanel-flipped"),Math.floor(i.DomHandler.getOffset(this.container).left)<Math.floor(i.DomHandler.getOffset(this.target).left)&&i.DomHandler.getOffset(this.container).left>0&&i.DomHandler.addClass(this.container,"ui-overlaypanel-shifted")},t.prototype.onAnimationStart=function(t){"open"===t.toState&&(this.container=t.element,this.onShow.emit(null),this.appendContainer(),this.align(),this.bindDocumentClickListener(),this.bindDocumentResizeListener())},t.prototype.onAnimationEnd=function(t){switch(t.toState){case"void":this.destroyCallback&&(this.destroyCallback(),this.destroyCallback=null);break;case"close":this.onContainerDestroy(),this.onHide.emit({}),this.render=!1}},t.prototype.hide=function(){this.overlayVisible=!1},t.prototype.onCloseClick=function(t){this.hide(),t.preventDefault()},t.prototype.onWindowResize=function(t){this.hide()},t.prototype.bindDocumentResizeListener=function(){this.documentResizeListener=this.onWindowResize.bind(this),window.addEventListener("resize",this.documentResizeListener)},t.prototype.unbindDocumentResizeListener=function(){this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)},t.prototype.onContainerDestroy=function(){this.target=null,this.unbindDocumentClickListener(),this.unbindDocumentResizeListener()},t.prototype.ngOnDestroy=function(){this.target=null,this.destroyCallback=null,this.container&&(this.restoreAppend(),this.onContainerDestroy())},t.ctorParameters=function(){return[{type:e.ElementRef},{type:e.Renderer2},{type:e.ChangeDetectorRef},{type:e.NgZone}]},s([e.Input()],t.prototype,"dismissable",void 0),s([e.Input()],t.prototype,"showCloseIcon",void 0),s([e.Input()],t.prototype,"style",void 0),s([e.Input()],t.prototype,"styleClass",void 0),s([e.Input()],t.prototype,"appendTo",void 0),s([e.Input()],t.prototype,"autoZIndex",void 0),s([e.Input()],t.prototype,"ariaCloseLabel",void 0),s([e.Input()],t.prototype,"baseZIndex",void 0),s([e.Input()],t.prototype,"showTransitionOptions",void 0),s([e.Input()],t.prototype,"hideTransitionOptions",void 0),s([e.Output()],t.prototype,"onShow",void 0),s([e.Output()],t.prototype,"onHide",void 0),s([e.ContentChildren(o.PrimeTemplate)],t.prototype,"templates",void 0),t=s([e.Component({selector:"p-overlayPanel",template:'\n <div *ngIf="render" [ngClass]="\'ui-overlaypanel ui-widget ui-widget-content ui-corner-all ui-shadow\'" [ngStyle]="style" [class]="styleClass" (click)="onContainerClick()"\n [@animation]="{value: (overlayVisible ? \'open\': \'close\'), params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}" \n (@animation.start)="onAnimationStart($event)" (@animation.done)="onAnimationEnd($event)">\n <div class="ui-overlaypanel-content">\n <ng-content></ng-content>\n <ng-container *ngTemplateOutlet="contentTemplate"></ng-container>\n </div>\n <a tabindex="0" *ngIf="showCloseIcon" class="ui-overlaypanel-close ui-state-default" (click)="onCloseClick($event)" (keydown.enter)="hide()" [attr.aria-label]="ariaCloseLabel">\n <span class="ui-overlaypanel-close-icon pi pi-times"></span>\n </a>\n </div>\n ',animations:[r.trigger("animation",[r.state("void",r.style({transform:"translateY(5%)",opacity:0})),r.state("close",r.style({transform:"translateY(5%)",opacity:0})),r.state("open",r.style({transform:"translateY(0)",opacity:1})),r.transition("void => open",r.animate("{{showTransitionParams}}")),r.transition("open => close",r.animate("{{hideTransitionParams}}"))])],changeDetection:e.ChangeDetectionStrategy.Default})],t)}(),l=function(){function t(){}return t=s([e.NgModule({imports:[n.CommonModule],exports:[a],declarations:[a]})],t)}();t.OverlayPanel=a,t.OverlayPanelModule=l,Object.defineProperty(t,"__esModule",{value:!0})}));
2//# sourceMappingURL=primeng-overlaypanel.umd.min.js.map
\No newline at end of file