ngx-bootstrap-ci
Version:
Native Angular Bootstrap Components
2 lines • 14.2 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("ngx-bootstrap/utils"),require("ngx-bootstrap/component-loader"),require("ngx-bootstrap/positioning")):"function"==typeof define&&define.amd?define("ngx-bootstrap/modal",["exports","@angular/core","ngx-bootstrap/utils","ngx-bootstrap/component-loader","ngx-bootstrap/positioning"],t):t((e["ngx-bootstrap"]=e["ngx-bootstrap"]||{},e["ngx-bootstrap"].modal={}),e.ng.core,e.utils,e.componentLoader,e.positioning)}(this,function(e,n,o,t,i){"use strict";var s=function(){function e(){this.hide=Function,this.setClass=Function}return e.decorators=[{type:n.Injectable}],e}(),r=function v(e){this.animate=!0,Object.assign(this,e)},d=function(){function e(){}return e.decorators=[{type:n.Injectable}],e}(),a={backdrop:!0,keyboard:!0,focus:!0,show:!1,ignoreBackdropClick:!1,"class":"",animated:!0,initialState:{}},h={SCROLLBAR_MEASURER:"modal-scrollbar-measure",BACKDROP:"modal-backdrop",OPEN:"modal-open",FADE:"fade",IN:"in",SHOW:"show"},c=300,l=150,p="backdrop-click",m="esc",u=function(){function e(e,t,i){this._element=t,this._renderer=i,this.isShown=!1,this.isModalHiding=!1,this.config=Object.assign({},e)}return e.prototype.ngOnInit=function(){var e=this;this.isAnimated&&this._renderer.addClass(this._element.nativeElement,h.FADE),this._renderer.setStyle(this._element.nativeElement,"display","block"),setTimeout(function(){e.isShown=!0,e._renderer.addClass(e._element.nativeElement,o.isBs3()?h.IN:h.SHOW)},this.isAnimated?l:0),document&&document.body&&(1===this.bsModalService.getModalsCount()&&(this.bsModalService.checkScrollbar(),this.bsModalService.setScrollbar()),this._renderer.addClass(document.body,h.OPEN)),this._element.nativeElement&&this._element.nativeElement.focus()},e.prototype.onClick=function(e){this.config.ignoreBackdropClick||"static"===this.config.backdrop||e.target!==this._element.nativeElement||(this.bsModalService.setDismissReason(p),this.hide())},e.prototype.onEsc=function(e){this.isShown&&(27!==e.keyCode&&"Escape"!==e.key||e.preventDefault(),this.config.keyboard&&this.level===this.bsModalService.getModalsCount()&&(this.bsModalService.setDismissReason(m),this.hide()))},e.prototype.ngOnDestroy=function(){this.isShown&&this.hide()},e.prototype.hide=function(){var e=this;!this.isModalHiding&&this.isShown&&(this.isModalHiding=!0,this._renderer.removeClass(this._element.nativeElement,o.isBs3()?h.IN:h.SHOW),setTimeout(function(){e.isShown=!1,document&&document.body&&1===e.bsModalService.getModalsCount()&&e._renderer.removeClass(document.body,h.OPEN),e.bsModalService.hide(e.level),e.isModalHiding=!1},this.isAnimated?c:0))},e.decorators=[{type:n.Component,args:[{selector:"modal-container",template:"\n <div [class]=\"'modal-dialog' + (config.class ? ' ' + config.class : '')\" role=\"document\">\n <div class=\"modal-content\">\n <ng-content></ng-content>\n </div>\n </div>\n ",host:{"class":"modal",role:"dialog",tabindex:"-1","[attr.aria-modal]":"true"}}]}],e.ctorParameters=function(){return[{type:d},{type:n.ElementRef},{type:n.Renderer2}]},e.propDecorators={onClick:[{type:n.HostListener,args:["click",["$event"]]}],onEsc:[{type:n.HostListener,args:["window:keydown.esc",["$event"]]}]},e}(),f=function(){function e(e,t){this._isShown=!1,this.element=e,this.renderer=t}return Object.defineProperty(e.prototype,"isAnimated",{get:function(){return this._isAnimated},set:function(e){this._isAnimated=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isShown",{get:function(){return this._isShown},set:function(e){(this._isShown=e)?this.renderer.addClass(this.element.nativeElement,""+h.IN):this.renderer.removeClass(this.element.nativeElement,""+h.IN),o.isBs3()||(e?this.renderer.addClass(this.element.nativeElement,""+h.SHOW):this.renderer.removeClass(this.element.nativeElement,""+h.SHOW))},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){this.isAnimated&&(this.renderer.addClass(this.element.nativeElement,""+h.FADE),o.Utils.reflow(this.element.nativeElement)),this.isShown=!0},e.decorators=[{type:n.Component,args:[{selector:"bs-modal-backdrop",template:" ",host:{"class":h.BACKDROP}}]}],e.ctorParameters=function(){return[{type:n.ElementRef},{type:n.Renderer2}]},e}(),y=function(){function e(e,t,i,o){this._element=e,this._renderer=i,this.onShow=new n.EventEmitter,this.onShown=new n.EventEmitter,this.onHide=new n.EventEmitter,this.onHidden=new n.EventEmitter,this._isShown=!1,this.isBodyOverflowing=!1,this.originalBodyPadding=0,this.scrollbarWidth=0,this.timerHideModal=0,this.timerRmBackDrop=0,this.isNested=!1,this._backdrop=o.createLoader(e,t,i)}return Object.defineProperty(e.prototype,"config",{get:function(){return this._config},set:function(e){this._config=this.getConfig(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isShown",{get:function(){return this._isShown},enumerable:!0,configurable:!0}),e.prototype.onClick=function(e){this.config.ignoreBackdropClick||"static"===this.config.backdrop||e.target!==this._element.nativeElement||(this.dismissReason=p,this.hide(e))},e.prototype.onEsc=function(e){this._isShown&&(27!==e.keyCode&&"Escape"!==e.key||e.preventDefault(),this.config.keyboard&&(this.dismissReason=m,this.hide()))},e.prototype.ngOnDestroy=function(){this.config=void 0,this._isShown&&(this._isShown=!1,this.hideModal(),this._backdrop.dispose())},e.prototype.ngOnInit=function(){var e=this;this._config=this._config||this.getConfig(),setTimeout(function(){e._config.show&&e.show()},0)},e.prototype.toggle=function(){return this._isShown?this.hide():this.show()},e.prototype.show=function(){var e=this;this.dismissReason=null,this.onShow.emit(this),this._isShown||(clearTimeout(this.timerHideModal),clearTimeout(this.timerRmBackDrop),this._isShown=!0,this.checkScrollbar(),this.setScrollbar(),o.document&&o.document.body&&(o.document.body.classList.contains(h.OPEN)?this.isNested=!0:this._renderer.addClass(o.document.body,h.OPEN)),this.showBackdrop(function(){e.showElement()}))},e.prototype.hide=function(e){var t=this;e&&e.preventDefault(),this.onHide.emit(this),this._isShown&&(o.window.clearTimeout(this.timerHideModal),o.window.clearTimeout(this.timerRmBackDrop),this._isShown=!1,this._renderer.removeClass(this._element.nativeElement,h.IN),o.isBs3()||this._renderer.removeClass(this._element.nativeElement,h.SHOW),this._config.animated?this.timerHideModal=o.window.setTimeout(function(){return t.hideModal()},300):this.hideModal())},e.prototype.getConfig=function(e){return Object.assign({},a,e)},e.prototype.showElement=function(){var e=this;this._element.nativeElement.parentNode&&this._element.nativeElement.parentNode.nodeType===Node.ELEMENT_NODE||o.document&&o.document.body&&o.document.body.appendChild(this._element.nativeElement),this._renderer.setAttribute(this._element.nativeElement,"aria-hidden","false"),this._renderer.setAttribute(this._element.nativeElement,"aria-modal","true"),this._renderer.setStyle(this._element.nativeElement,"display","block"),this._renderer.setProperty(this._element.nativeElement,"scrollTop",0),this._config.animated&&o.Utils.reflow(this._element.nativeElement),this._renderer.addClass(this._element.nativeElement,h.IN),o.isBs3()||this._renderer.addClass(this._element.nativeElement,h.SHOW);var t=function(){e._config.focus&&e._element.nativeElement.focus(),e.onShown.emit(e)};this._config.animated?setTimeout(t,300):t()},e.prototype.hideModal=function(){var e=this;this._renderer.setAttribute(this._element.nativeElement,"aria-hidden","true"),this._renderer.setStyle(this._element.nativeElement,"display","none"),this.showBackdrop(function(){e.isNested||(o.document&&o.document.body&&e._renderer.removeClass(o.document.body,h.OPEN),e.resetScrollbar()),e.resetAdjustments(),e.focusOtherModal(),e.onHidden.emit(e)})},e.prototype.showBackdrop=function(e){var t=this;if(!this._isShown||!this.config.backdrop||this.backdrop&&this.backdrop.instance.isShown)if(!this._isShown&&this.backdrop){this.backdrop.instance.isShown=!1;var i=function(){t.removeBackdrop(),e&&e()};this.backdrop.instance.isAnimated?this.timerRmBackDrop=o.window.setTimeout(i,150):i()}else e&&e();else{if(this.removeBackdrop(),this._backdrop.attach(f).to("body").show({isAnimated:this._config.animated}),this.backdrop=this._backdrop._componentRef,!e)return;if(!this._config.animated)return void e();setTimeout(e,150)}},e.prototype.removeBackdrop=function(){this._backdrop.hide()},e.prototype.focusOtherModal=function(){if(null!=this._element.nativeElement.parentElement){var e=this._element.nativeElement.parentElement.querySelectorAll(".in[bsModal]");e.length&&e[e.length-1].focus()}},e.prototype.resetAdjustments=function(){this._renderer.setStyle(this._element.nativeElement,"paddingLeft",""),this._renderer.setStyle(this._element.nativeElement,"paddingRight","")},e.prototype.checkScrollbar=function(){this.isBodyOverflowing=o.document.body.clientWidth<o.window.innerWidth,this.scrollbarWidth=this.getScrollbarWidth()},e.prototype.setScrollbar=function(){o.document&&(this.originalBodyPadding=parseInt(o.window.getComputedStyle(o.document.body).getPropertyValue("padding-right")||0,10),this.isBodyOverflowing&&(o.document.body.style.paddingRight=this.originalBodyPadding+this.scrollbarWidth+"px"))},e.prototype.resetScrollbar=function(){o.document.body.style.paddingRight=this.originalBodyPadding+"px"},e.prototype.getScrollbarWidth=function(){var e=this._renderer.createElement("div");this._renderer.addClass(e,h.SCROLLBAR_MEASURER),this._renderer.appendChild(o.document.body,e);var t=e.offsetWidth-e.clientWidth;return this._renderer.removeChild(o.document.body,e),t},e.decorators=[{type:n.Directive,args:[{selector:"[bsModal]",exportAs:"bs-modal"}]}],e.ctorParameters=function(){return[{type:n.ElementRef},{type:n.ViewContainerRef},{type:n.Renderer2},{type:t.ComponentLoaderFactory}]},e.propDecorators={config:[{type:n.Input}],onShow:[{type:n.Output}],onShown:[{type:n.Output}],onHide:[{type:n.Output}],onHidden:[{type:n.Output}],onClick:[{type:n.HostListener,args:["click",["$event"]]}],onEsc:[{type:n.HostListener,args:["keydown.esc",["$event"]]}]},e}(),g=function(){function e(e,t){this.clf=t,this.config=a,this.onShow=new n.EventEmitter,this.onShown=new n.EventEmitter,this.onHide=new n.EventEmitter,this.onHidden=new n.EventEmitter,this.isBodyOverflowing=!1,this.originalBodyPadding=0,this.scrollbarWidth=0,this.modalsCount=0,this.lastDismissReason="",this.loaders=[],this._backdropLoader=this.clf.createLoader(null,null,null),this._renderer=e.createRenderer(null,null)}return e.prototype.show=function(e,t){return this.modalsCount++,this._createLoaders(),this.config=Object.assign({},a,t),this._showBackdrop(),this.lastDismissReason=null,this._showModal(e)},e.prototype.hide=function(e){var t=this;1===this.modalsCount&&(this._hideBackdrop(),this.resetScrollbar()),this.modalsCount=1<=this.modalsCount?this.modalsCount-1:0,setTimeout(function(){t._hideModal(e),t.removeLoaders(e)},this.config.animated?l:0)},e.prototype._showBackdrop=function(){var e=this.config.backdrop||"static"===this.config.backdrop,t=!this.backdropRef||!this.backdropRef.instance.isShown;1===this.modalsCount&&(this.removeBackdrop(),e&&t&&(this._backdropLoader.attach(f).to("body").show({isAnimated:this.config.animated}),this.backdropRef=this._backdropLoader._componentRef))},e.prototype._hideBackdrop=function(){var e=this;if(this.backdropRef){this.backdropRef.instance.isShown=!1;var t=this.config.animated?l:0;setTimeout(function(){return e.removeBackdrop()},t)}},e.prototype._showModal=function(e){var t=this.loaders[this.loaders.length-1],i=new s,o=t.provide({provide:d,useValue:this.config}).provide({provide:s,useValue:i}).attach(u).to("body").show({content:e,isAnimated:this.config.animated,initialState:this.config.initialState,bsModalService:this});return o.instance.level=this.getModalsCount(),i.hide=function(){o.instance.hide()},i.content=t.getInnerComponent()||null,i.setClass=function(e){o.instance.config["class"]=e},i},e.prototype._hideModal=function(e){var t=this.loaders[e-1];t&&t.hide()},e.prototype.getModalsCount=function(){return this.modalsCount},e.prototype.setDismissReason=function(e){this.lastDismissReason=e},e.prototype.removeBackdrop=function(){this._backdropLoader.hide(),this.backdropRef=null},e.prototype.checkScrollbar=function(){this.isBodyOverflowing=document.body.clientWidth<window.innerWidth,this.scrollbarWidth=this.getScrollbarWidth()},e.prototype.setScrollbar=function(){document&&(this.originalBodyPadding=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right")||"0",10),this.isBodyOverflowing&&(document.body.style.paddingRight=this.originalBodyPadding+this.scrollbarWidth+"px"))},e.prototype.resetScrollbar=function(){document.body.style.paddingRight=this.originalBodyPadding+"px"},e.prototype.getScrollbarWidth=function(){var e=this._renderer.createElement("div");this._renderer.addClass(e,h.SCROLLBAR_MEASURER),this._renderer.appendChild(document.body,e);var t=e.offsetWidth-e.clientWidth;return this._renderer.removeChild(document.body,e),t},e.prototype._createLoaders=function(){var e=this.clf.createLoader(null,null,null);this.copyEvent(e.onBeforeShow,this.onShow),this.copyEvent(e.onShown,this.onShown),this.copyEvent(e.onBeforeHide,this.onHide),this.copyEvent(e.onHidden,this.onHidden),this.loaders.push(e)},e.prototype.removeLoaders=function(e){this.loaders.splice(e-1,1),this.loaders.forEach(function(e,t){e.instance.level=t+1})},e.prototype.copyEvent=function(e,t){var i=this;e.subscribe(function(){t.emit(i.lastDismissReason)})},e.decorators=[{type:n.Injectable}],e.ctorParameters=function(){return[{type:n.RendererFactory2},{type:t.ComponentLoaderFactory}]},e}(),b=function(){function e(){}return e.forRoot=function(){return{ngModule:e,providers:[g,t.ComponentLoaderFactory,i.PositioningService]}},e.decorators=[{type:n.NgModule,args:[{declarations:[f,y,u],exports:[f,y],entryComponents:[f,u]}]}],e}();e.BsModalRef=s,e.ModalBackdropOptions=r,e.ModalContainerComponent=u,e.ModalBackdropComponent=f,e.ModalOptions=d,e.ModalDirective=y,e.ModalModule=b,e.BsModalService=g,e.ɵa=h,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ngx-bootstrap-modal.umd.min.js.map