UNPKG

12 kBJavaScriptView Raw
1!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/animations"),require("@angular/common"),require("primeng/dom"),require("primeng/api"),require("primeng/button")):"function"==typeof define&&define.amd?define("primeng/confirmdialog",["exports","@angular/core","@angular/animations","@angular/common","primeng/dom","primeng/api","primeng/button"],e):e(((t=t||self).primeng=t.primeng||{},t.primeng.confirmdialog={}),t.ng.core,t.ng.animations,t.ng.common,t.primeng.dom,t.primeng.api,t.primeng.button)}(this,(function(t,e,o,i,n,r,s){"use strict";var a=this&&this.__decorate||function(t,e,o,i){var n,r=arguments.length,s=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,i);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(r<3?n(s):r>3?n(e,o,s):n(e,o))||s);return r>3&&s&&Object.defineProperty(e,o,s),s},c=o.animation([o.style({transform:"{{transform}}",opacity:0}),o.animate("{{transition}}",o.style({transform:"none",opacity:1}))]),l=o.animation([o.animate("{{transition}}",o.style({transform:"{{transform}}",opacity:0}))]),p=function(){function t(t,o,i,n,r){var s=this;this.el=t,this.renderer=o,this.confirmationService=i,this.zone=n,this.cd=r,this.acceptIcon="pi pi-check",this.acceptLabel="Yes",this.acceptVisible=!0,this.rejectIcon="pi pi-times",this.rejectLabel="No",this.rejectVisible=!0,this.closeOnEscape=!0,this.blockScroll=!0,this.closable=!0,this.autoZIndex=!0,this.baseZIndex=0,this.transitionOptions="150ms cubic-bezier(0, 0, 0.2, 1)",this.focusTrap=!0,this.defaultFocus="accept",this._position="center",this.transformOptions="scale(0.7)",this.subscription=this.confirmationService.requireConfirmation$.subscribe((function(t){t?t.key===s.key&&(s.confirmation=t,s.confirmationOptions={message:s.confirmation.message||s.message,icon:s.confirmation.icon||s.icon,header:s.confirmation.header||s.header,rejectVisible:null==s.confirmation.rejectVisible?s.rejectVisible:s.confirmation.rejectVisible,acceptVisible:null==s.confirmation.acceptVisible?s.acceptVisible:s.confirmation.acceptVisible,acceptLabel:s.confirmation.acceptLabel||s.acceptLabel,rejectLabel:s.confirmation.rejectLabel||s.rejectLabel,acceptIcon:s.confirmation.acceptIcon||s.acceptIcon,rejectIcon:s.confirmation.rejectIcon||s.rejectIcon,acceptButtonStyleClass:s.confirmation.acceptButtonStyleClass||s.acceptButtonStyleClass,rejectButtonStyleClass:s.confirmation.rejectButtonStyleClass||s.rejectButtonStyleClass,defaultFocus:s.confirmation.defaultFocus||s.defaultFocus,blockScroll:!1===s.confirmation.blockScroll||!0===s.confirmation.blockScroll?s.confirmation.blockScroll:s.blockScroll},s.confirmation.accept&&(s.confirmation.acceptEvent=new e.EventEmitter,s.confirmation.acceptEvent.subscribe(s.confirmation.accept)),s.confirmation.reject&&(s.confirmation.rejectEvent=new e.EventEmitter,s.confirmation.rejectEvent.subscribe(s.confirmation.reject)),s.visible=!0):s.hide()}))}return Object.defineProperty(t.prototype,"visible",{get:function(){return this._visible},set:function(t){this._visible=t,this._visible&&!this.maskVisible&&(this.maskVisible=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(t){switch(this._position=t,t){case"topleft":case"bottomleft":case"left":this.transformOptions="translate3d(-100%, 0px, 0px)";break;case"topright":case"bottomright":case"right":this.transformOptions="translate3d(100%, 0px, 0px)";break;case"bottom":this.transformOptions="translate3d(0px, 100%, 0px)";break;case"top":this.transformOptions="translate3d(0px, -100%, 0px)";break;default:this.transformOptions="scale(0.7)"}},enumerable:!0,configurable:!0}),t.prototype.option=function(t){var e=this.confirmationOptions||this;if(e.hasOwnProperty(t))return e[t]},t.prototype.onAnimationStart=function(t){switch(t.toState){case"visible":this.container=t.element,this.wrapper=this.container.parentElement,this.contentContainer=n.DomHandler.findSingle(this.container,".ui-dialog-content");var e=this.getElementToFocus();e&&e.focus(),this.appendContainer(),this.moveOnTop(),this.bindGlobalListeners(),this.enableModality()}},t.prototype.onAnimationEnd=function(t){switch(t.toState){case"void":this.onOverlayHide()}},t.prototype.getElementToFocus=function(){switch(this.option("defaultFocus")){case"accept":return n.DomHandler.findSingle(this.container,"button.ui-confirmdialog-acceptbutton");case"reject":return n.DomHandler.findSingle(this.container,"button.ui-confirmdialog-rejectbutton");case"close":return n.DomHandler.findSingle(this.container,"a.ui-dialog-titlebar-close");case"none":return null;default:return n.DomHandler.findSingle(this.container,"button.ui-confirmdialog-acceptbutton")}},t.prototype.appendContainer=function(){this.appendTo&&("body"===this.appendTo?document.body.appendChild(this.wrapper):n.DomHandler.appendChild(this.wrapper,this.appendTo))},t.prototype.restoreAppend=function(){this.wrapper&&this.appendTo&&this.el.nativeElement.appendChild(this.wrapper)},t.prototype.enableModality=function(){this.option("blockScroll")&&n.DomHandler.addClass(document.body,"ui-overflow-hidden")},t.prototype.disableModality=function(){this.maskVisible=!1,this.option("blockScroll")&&n.DomHandler.removeClass(document.body,"ui-overflow-hidden"),this.container&&this.cd.detectChanges()},t.prototype.close=function(t){this.confirmation.rejectEvent&&this.confirmation.rejectEvent.emit(),this.hide(),t.preventDefault()},t.prototype.hide=function(){this.visible=!1,this.confirmation=null,this.confirmationOptions=null},t.prototype.moveOnTop=function(){this.autoZIndex&&(this.container.style.zIndex=String(this.baseZIndex+ ++n.DomHandler.zindex),this.wrapper.style.zIndex=String(this.baseZIndex+(n.DomHandler.zindex-1)))},t.prototype.getMaskClass=function(){var t={"ui-widget-overlay ui-dialog-mask":!0,"ui-dialog-visible":this.maskVisible,"ui-dialog-mask-scrollblocker":this.blockScroll};return t[this.getPositionClass().toString()]=!0,t},t.prototype.getPositionClass=function(){var t=this,e=["left","right","top","topleft","topright","bottom","bottomleft","bottomright"].find((function(e){return e===t.position}));return e?"ui-dialog-"+e:""},t.prototype.bindGlobalListeners=function(){var t=this;(this.closeOnEscape&&this.closable||this.focusTrap&&!this.documentEscapeListener)&&(this.documentEscapeListener=this.renderer.listen("document","keydown",(function(e){if(27==e.which&&t.closeOnEscape&&t.closable&&parseInt(t.container.style.zIndex)===n.DomHandler.zindex+t.baseZIndex&&t.visible&&t.close(e),9===e.which&&t.focusTrap){e.preventDefault();var o=n.DomHandler.getFocusableElements(t.container);if(o&&o.length>0)if(document.activeElement){var i=o.indexOf(document.activeElement);e.shiftKey?-1==i||0===i?o[o.length-1].focus():o[i-1].focus():-1==i||i===o.length-1?o[0].focus():o[i+1].focus()}else o[0].focus()}})))},t.prototype.unbindGlobalListeners=function(){this.documentEscapeListener&&(this.documentEscapeListener(),this.documentEscapeListener=null)},t.prototype.onOverlayHide=function(){this.disableModality(),this.unbindGlobalListeners(),this.container=null},t.prototype.ngOnDestroy=function(){this.restoreAppend(),this.onOverlayHide(),this.subscription.unsubscribe()},t.prototype.accept=function(){this.confirmation.acceptEvent&&this.confirmation.acceptEvent.emit(),this.hide()},t.prototype.reject=function(){this.confirmation.rejectEvent&&this.confirmation.rejectEvent.emit(),this.hide()},t.ctorParameters=function(){return[{type:e.ElementRef},{type:e.Renderer2},{type:r.ConfirmationService},{type:e.NgZone},{type:e.ChangeDetectorRef}]},a([e.Input()],t.prototype,"header",void 0),a([e.Input()],t.prototype,"icon",void 0),a([e.Input()],t.prototype,"message",void 0),a([e.Input()],t.prototype,"style",void 0),a([e.Input()],t.prototype,"styleClass",void 0),a([e.Input()],t.prototype,"maskStyleClass",void 0),a([e.Input()],t.prototype,"acceptIcon",void 0),a([e.Input()],t.prototype,"acceptLabel",void 0),a([e.Input()],t.prototype,"acceptVisible",void 0),a([e.Input()],t.prototype,"rejectIcon",void 0),a([e.Input()],t.prototype,"rejectLabel",void 0),a([e.Input()],t.prototype,"rejectVisible",void 0),a([e.Input()],t.prototype,"acceptButtonStyleClass",void 0),a([e.Input()],t.prototype,"rejectButtonStyleClass",void 0),a([e.Input()],t.prototype,"closeOnEscape",void 0),a([e.Input()],t.prototype,"blockScroll",void 0),a([e.Input()],t.prototype,"rtl",void 0),a([e.Input()],t.prototype,"closable",void 0),a([e.Input()],t.prototype,"appendTo",void 0),a([e.Input()],t.prototype,"key",void 0),a([e.Input()],t.prototype,"autoZIndex",void 0),a([e.Input()],t.prototype,"baseZIndex",void 0),a([e.Input()],t.prototype,"transitionOptions",void 0),a([e.Input()],t.prototype,"focusTrap",void 0),a([e.Input()],t.prototype,"defaultFocus",void 0),a([e.Input()],t.prototype,"visible",null),a([e.Input()],t.prototype,"position",null),a([e.ContentChild(r.Footer)],t.prototype,"footer",void 0),a([e.ViewChild("content")],t.prototype,"contentViewChild",void 0),t=a([e.Component({selector:"p-confirmDialog",template:'\n <div [class]="maskStyleClass" [ngClass]="getMaskClass()" *ngIf="maskVisible">\n <div [ngClass]="{\'ui-dialog ui-confirmdialog ui-widget ui-widget-content ui-corner-all ui-shadow\':true,\'ui-dialog-rtl\':rtl}" [ngStyle]="style" [class]="styleClass" (mousedown)="moveOnTop()"\n [@animation]="{value: \'visible\', params: {transform: transformOptions, transition: transitionOptions}}" (@animation.start)="onAnimationStart($event)" (@animation.done)="onAnimationEnd($event)" *ngIf="visible">\n <div class="ui-dialog-titlebar ui-widget-header ui-helper-clearfix ui-corner-top">\n <span class="ui-dialog-title" *ngIf="option(\'header\')">{{option(\'header\')}}</span>\n <div class="ui-dialog-titlebar-icons">\n <a *ngIf="closable" [ngClass]="{\'ui-dialog-titlebar-icon ui-dialog-titlebar-close ui-corner-all\':true}" tabindex="0" role="button" (click)="close($event)" (keydown.enter)="close($event)">\n <span class="pi pi-times"></span>\n </a>\n </div>\n </div>\n <div #content class="ui-dialog-content ui-widget-content">\n <i [ngClass]="\'ui-confirmdialog-icon\'" [class]="option(\'icon\')" *ngIf="option(\'icon\')"></i>\n <span class="ui-confirmdialog-message" [innerHTML]="option(\'message\')"></span>\n </div>\n <div class="ui-dialog-footer ui-widget-content" *ngIf="footer">\n <ng-content select="p-footer"></ng-content>\n </div>\n <div class="ui-dialog-footer ui-widget-content" *ngIf="!footer">\n <button type="button" pButton [icon]="option(\'acceptIcon\')" [label]="option(\'acceptLabel\')" (click)="accept()" [ngClass]="\'ui-confirmdialog-acceptbutton\'" [class]="option(\'acceptButtonStyleClass\')" *ngIf="option(\'acceptVisible\')"></button>\n <button type="button" pButton [icon]="option(\'rejectIcon\')" [label]="option(\'rejectLabel\')" (click)="reject()" [ngClass]="\'ui-confirmdialog-rejectbutton\'" [class]="option(\'rejectButtonStyleClass\')" *ngIf="option(\'rejectVisible\')"></button>\n </div>\n </div>\n </div>\n ',animations:[o.trigger("animation",[o.transition("void => visible",[o.useAnimation(c)]),o.transition("visible => void",[o.useAnimation(l)])])],changeDetection:e.ChangeDetectionStrategy.Default})],t)}(),u=function(){function t(){}return t=a([e.NgModule({imports:[i.CommonModule,s.ButtonModule],exports:[p,s.ButtonModule,r.SharedModule],declarations:[p]})],t)}();t.ConfirmDialog=p,t.ConfirmDialogModule=u,Object.defineProperty(t,"__esModule",{value:!0})}));
2//# sourceMappingURL=primeng-confirmdialog.umd.min.js.map
\No newline at end of file