UNPKG

9.97 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/animations"),require("@angular/common"),require("primeng/dom"),require("rxjs")):"function"==typeof define&&define.amd?define("primeng/dynamicdialog",["exports","@angular/core","@angular/animations","@angular/common","primeng/dom","rxjs"],t):t(((e=e||self).primeng=e.primeng||{},e.primeng.dynamicdialog={}),e.ng.core,e.ng.animations,e.ng.common,e.primeng.dom,e.rxjs)}(this,(function(e,t,n,o,i,s){"use strict";var r=this&&this.__decorate||function(e,t,n,o){var i,s=arguments.length,r=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(r=(s<3?i(r):s>3?i(t,n,r):i(t,n))||r);return s>3&&r&&Object.defineProperty(t,n,r),r},a=function(){function e(e){this.viewContainerRef=e}return e.ctorParameters=function(){return[{type:t.ViewContainerRef}]},e=r([t.Directive({selector:"[pDynamicDialogContent]"})],e)}(),c=function(){},l=function(){function e(){this._onClose=new s.Subject,this.onClose=this._onClose.asObservable(),this._onDestroy=new s.Subject,this.onDestroy=this._onDestroy.asObservable()}return e.prototype.close=function(e){this._onClose.next(e)},e.prototype.destroy=function(){this._onDestroy.next()},e}(),d=this&&this.__decorate||function(e,t,n,o){var i,s=arguments.length,r=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(r=(s<3?i(r):s>3?i(t,n,r):i(t,n))||r);return s>3&&r&&Object.defineProperty(t,n,r),r},u=n.animation([n.style({transform:"{{transform}}",opacity:0}),n.animate("{{transition}}",n.style({transform:"none",opacity:1}))]),p=n.animation([n.animate("{{transition}}",n.style({transform:"{{transform}}",opacity:0}))]),f=function(){function e(e,t,n,o,i,s){this.componentFactoryResolver=e,this.cd=t,this.renderer=n,this.config=o,this.dialogRef=i,this.zone=s,this.visible=!0,this.transformOptions="scale(0.7)"}return e.prototype.ngAfterViewInit=function(){this.loadChildComponent(this.childComponentType),this.cd.detectChanges()},e.prototype.loadChildComponent=function(e){var t=this.componentFactoryResolver.resolveComponentFactory(e),n=this.insertionPoint.viewContainerRef;n.clear(),this.componentRef=n.createComponent(t)},e.prototype.moveOnTop=function(){if(!1!==this.config.autoZIndex){var e=(this.config.baseZIndex||0)+ ++i.DomHandler.zindex;this.container.style.zIndex=String(e),this.maskViewChild.nativeElement.style.zIndex=String(e-1)}},e.prototype.onAnimationStart=function(e){switch(e.toState){case"visible":this.container=e.element,this.wrapper=this.container.parentElement,this.moveOnTop(),this.bindGlobalListeners(),!1!==this.config.modal&&this.enableModality(),this.focus();break;case"void":this.onContainerDestroy()}},e.prototype.onAnimationEnd=function(e){"void"===e.toState&&this.dialogRef.destroy()},e.prototype.onContainerDestroy=function(){this.unbindGlobalListeners(),!1!==this.config.modal&&this.disableModality(),this.container=null},e.prototype.close=function(){this.visible=!1},e.prototype.enableModality=function(){var e=this;!1!==this.config.closable&&!1!==this.config.dismissableMask&&(this.maskClickListener=this.renderer.listen(this.wrapper,"click",(function(t){!e.container||e.container.isSameNode(t.target)||e.container.contains(t.target)||e.close()}))),!1!==this.config.modal&&i.DomHandler.addClass(document.body,"ui-overflow-hidden")},e.prototype.disableModality=function(){this.wrapper&&(this.config.dismissableMask&&this.unbindMaskClickListener(),!1!==this.config.modal&&i.DomHandler.removeClass(document.body,"ui-overflow-hidden"),this.cd.destroyed||this.cd.detectChanges())},e.prototype.onKeydown=function(e){if(9===e.which){e.preventDefault();var t=i.DomHandler.getFocusableElements(this.container);if(t&&t.length>0)if(document.activeElement){var n=t.indexOf(document.activeElement);e.shiftKey?-1==n||0===n?t[t.length-1].focus():t[n-1].focus():-1==n||n===t.length-1?t[0].focus():t[n+1].focus()}else t[0].focus()}},e.prototype.focus=function(){var e=i.DomHandler.findSingle(this.container,"a");e&&this.zone.runOutsideAngular((function(){setTimeout((function(){return e.focus()}),5)}))},e.prototype.bindGlobalListeners=function(){this.bindDocumentKeydownListener(),!1!==this.config.closeOnEscape&&!1!==this.config.closable&&this.bindDocumentEscapeListener()},e.prototype.unbindGlobalListeners=function(){this.unbindDocumentKeydownListener(),this.unbindDocumentEscapeListener()},e.prototype.bindDocumentKeydownListener=function(){var e=this;this.zone.runOutsideAngular((function(){e.documentKeydownListener=e.onKeydown.bind(e),window.document.addEventListener("keydown",e.documentKeydownListener)}))},e.prototype.unbindDocumentKeydownListener=function(){this.documentKeydownListener&&(window.document.removeEventListener("keydown",this.documentKeydownListener),this.documentKeydownListener=null)},e.prototype.bindDocumentEscapeListener=function(){var e=this;this.documentEscapeListener=this.renderer.listen("document","keydown",(function(t){27==t.which&&parseInt(e.container.style.zIndex)==i.DomHandler.zindex+(e.config.baseZIndex?e.config.baseZIndex:0)&&e.close()}))},e.prototype.unbindDocumentEscapeListener=function(){this.documentEscapeListener&&(this.documentEscapeListener(),this.documentEscapeListener=null)},e.prototype.unbindMaskClickListener=function(){this.maskClickListener&&(this.maskClickListener(),this.maskClickListener=null)},e.prototype.ngOnDestroy=function(){this.onContainerDestroy(),this.componentRef&&this.componentRef.destroy()},e.ctorParameters=function(){return[{type:t.ComponentFactoryResolver},{type:t.ChangeDetectorRef},{type:t.Renderer2},{type:c},{type:l},{type:t.NgZone}]},d([t.ViewChild(a)],e.prototype,"insertionPoint",void 0),d([t.ViewChild("mask")],e.prototype,"maskViewChild",void 0),e=d([t.Component({selector:"p-dynamicDialog",template:'\n <div #mask [ngClass]="{\'ui-dialog-mask ui-dialog-visible\':true, \'ui-widget-overlay ui-dialog-mask-scrollblocker\': config.modal !== false}">\n <div [ngClass]="{\'ui-dialog ui-dynamicdialog ui-widget ui-widget-content ui-corner-all ui-shadow\':true, \'ui-dialog-rtl\': config.rtl}" [ngStyle]="config.style" [class]="config.styleClass"\n [@animation]="{value: \'visible\', params: {transform: transformOptions, transition: config.transitionOptions || \'150ms cubic-bezier(0, 0, 0.2, 1)\'}}"\n (@animation.start)="onAnimationStart($event)" (@animation.done)="onAnimationEnd($event)" role="dialog" *ngIf="visible"\n [style.width]="config.width" [style.height]="config.height">\n <div class="ui-dialog-titlebar ui-widget-header ui-helper-clearfix ui-corner-top" *ngIf="config.showHeader === false ? false: true">\n <span class="ui-dialog-title">{{config.header}}</span>\n <div class="ui-dialog-titlebar-icons">\n <a [ngClass]="\'ui-dialog-titlebar-icon ui-dialog-titlebar-close ui-corner-all\'" tabindex="0" role="button" (click)="close()" (keydown.enter)="close()" *ngIf="config.closable !== false">\n <span class="pi pi-times"></span>\n </a>\n </div>\n </div>\n <div class="ui-dialog-content ui-widget-content" [ngStyle]="config.contentStyle">\n <ng-template pDynamicDialogContent></ng-template>\n </div>\n <div class="ui-dialog-footer ui-widget-content" *ngIf="config.footer">\n {{config.footer}}\n </div>\n </div>\n </div>\n\t',animations:[n.trigger("animation",[n.transition("void => visible",[n.useAnimation(u)]),n.transition("visible => void",[n.useAnimation(p)])])],changeDetection:t.ChangeDetectionStrategy.Default})],e)}(),m=function(){function e(){}return e=d([t.NgModule({imports:[o.CommonModule],declarations:[f,a],entryComponents:[f]})],e)}(),h=function(){function e(e,t){this._parentInjector=e,this._additionalTokens=t}return e.prototype.get=function(e,t,n){var o=this._additionalTokens.get(e);return o||this._parentInjector.get(e,t)},e}(),g=this&&this.__decorate||function(e,t,n,o){var i,s=arguments.length,r=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(r=(s<3?i(r):s>3?i(t,n,r):i(t,n))||r);return s>3&&r&&Object.defineProperty(t,n,r),r},y=function(){function e(e,t,n){this.componentFactoryResolver=e,this.appRef=t,this.injector=n}return e.prototype.open=function(e,t){var n=this.appendDialogComponentToBody(t);return this.dialogComponentRef.instance.childComponentType=e,n},e.prototype.appendDialogComponentToBody=function(e){var t=this,n=new WeakMap;n.set(c,e);var o=new l;n.set(l,o);var i=o.onClose.subscribe((function(){t.dialogComponentRef.instance.close()})),s=o.onDestroy.subscribe((function(){t.removeDialogComponentFromBody(),s.unsubscribe(),i.unsubscribe()})),r=this.componentFactoryResolver.resolveComponentFactory(f).create(new h(this.injector,n));this.appRef.attachView(r.hostView);var a=r.hostView.rootNodes[0];return document.body.appendChild(a),this.dialogComponentRef=r,o},e.prototype.removeDialogComponentFromBody=function(){this.appRef.detachView(this.dialogComponentRef.hostView),this.dialogComponentRef.destroy()},e.ctorParameters=function(){return[{type:t.ComponentFactoryResolver},{type:t.ApplicationRef},{type:t.Injector}]},e=g([t.Injectable()],e)}();e.DialogService=y,e.DynamicDialogComponent=f,e.DynamicDialogConfig=c,e.DynamicDialogInjector=h,e.DynamicDialogModule=m,e.DynamicDialogRef=l,e.ɵa=a,Object.defineProperty(e,"__esModule",{value:!0})}));
2//# sourceMappingURL=primeng-dynamicdialog.umd.min.js.map
\No newline at end of file