UNPKG

ngx-bootstrap-fix-datepicker

Version:
16 lines (14 loc) 16.4 kB
!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=e||self)["ngx-bootstrap"]=e["ngx-bootstrap"]||{},e["ngx-bootstrap"].modal={}),e.ng.core,e.utils,e.componentLoader,e.positioning)}(this,(function(e,t,i,n,o){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */function s(e){var t="function"==typeof Symbol&&e[Symbol.iterator],i=0;return t?t.call(e):{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}}}var r=function(){function e(){this.hide=Function,this.setClass=Function}return e.decorators=[{type:t.Injectable}],e}();var a=function(e){this.animate=!0,Object.assign(this,e)};var d=function(){function e(){}return e.decorators=[{type:t.Injectable}],e}();var c={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"},l=300,p=150,u="backdrop-click",m="esc",f=function(){function e(e,t,i){this._element=t,this._renderer=i,this.isShown=!1,this.isModalHiding=!1,this.clickStartedInContent=!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,i.isBs3()?h.IN:h.SHOW)}),this.isAnimated?p: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.onClickStarted=function(e){this.clickStartedInContent=e.target!==this._element.nativeElement},e.prototype.onClickStop=function(e){var t=e.target===this._element.nativeElement&&!this.clickStartedInContent;!this.config.ignoreBackdropClick&&"static"!==this.config.backdrop&&t?(this.bsModalService.setDismissReason(u),this.hide()):this.clickStartedInContent=!1},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,i.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?l:0))},e.decorators=[{type:t.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","[attr.aria-labelledby]":"config.ariaLabelledBy","[attr.aria-describedby]":"config.ariaDescribedby"}}]}],e.ctorParameters=function(){return[{type:d},{type:t.ElementRef},{type:t.Renderer2}]},e.propDecorators={onClickStarted:[{type:t.HostListener,args:["mousedown",["$event"]]}],onClickStop:[{type:t.HostListener,args:["mouseup",["$event"]]}],onEsc:[{type:t.HostListener,args:["window:keydown.esc",["$event"]]}]},e}();var y=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,e?this.renderer.addClass(this.element.nativeElement,""+h.IN):this.renderer.removeClass(this.element.nativeElement,""+h.IN),i.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),i.Utils.reflow(this.element.nativeElement)),this.isShown=!0},e.decorators=[{type:t.Component,args:[{selector:"bs-modal-backdrop",template:" ",host:{class:h.BACKDROP}}]}],e.ctorParameters=function(){return[{type:t.ElementRef},{type:t.Renderer2}]},e}();var g=function(){function e(e,i,n,o){this._element=e,this._renderer=n,this.onShow=new t.EventEmitter,this.onShown=new t.EventEmitter,this.onHide=new t.EventEmitter,this.onHidden=new t.EventEmitter,this._isShown=!1,this.isBodyOverflowing=!1,this.originalBodyPadding=0,this.scrollbarWidth=0,this.timerHideModal=0,this.timerRmBackDrop=0,this.isNested=!1,this.clickStartedInContent=!1,this._backdrop=o.createLoader(e,i,n)}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.onClickStarted=function(e){this.clickStartedInContent=e.target!==this._element.nativeElement},e.prototype.onClickStop=function(e){var t=e.target===this._element.nativeElement&&!this.clickStartedInContent;!this.config.ignoreBackdropClick&&"static"!==this.config.backdrop&&t?(this.dismissReason=u,this.hide(e)):this.clickStartedInContent=!1},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(),i.document&&i.document.body&&(i.document.body.classList.contains(h.OPEN)?this.isNested=!0:this._renderer.addClass(i.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&&(i.window.clearTimeout(this.timerHideModal),i.window.clearTimeout(this.timerRmBackDrop),this._isShown=!1,this._renderer.removeClass(this._element.nativeElement,h.IN),i.isBs3()||this._renderer.removeClass(this._element.nativeElement,h.SHOW),this._config.animated?this.timerHideModal=i.window.setTimeout((function(){return t.hideModal()}),300):this.hideModal())},e.prototype.getConfig=function(e){return Object.assign({},c,e)},e.prototype.showElement=function(){var e=this;this._element.nativeElement.parentNode&&this._element.nativeElement.parentNode.nodeType===Node.ELEMENT_NODE||i.document&&i.document.body&&i.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&&i.Utils.reflow(this._element.nativeElement),this._renderer.addClass(this._element.nativeElement,h.IN),i.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||(i.document&&i.document.body&&e._renderer.removeClass(i.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 n=function(){t.removeBackdrop(),e&&e()};this.backdrop.instance.isAnimated?this.timerRmBackDrop=i.window.setTimeout(n,150):n()}else e&&e();else{if(this.removeBackdrop(),this._backdrop.attach(y).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=i.document.body.clientWidth<i.window.innerWidth,this.scrollbarWidth=this.getScrollbarWidth()},e.prototype.setScrollbar=function(){i.document&&(this.originalBodyPadding=parseInt(i.window.getComputedStyle(i.document.body).getPropertyValue("padding-right")||0,10),this.isBodyOverflowing&&(i.document.body.style.paddingRight=this.originalBodyPadding+this.scrollbarWidth+"px"))},e.prototype.resetScrollbar=function(){i.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(i.document.body,e);var t=e.offsetWidth-e.clientWidth;return this._renderer.removeChild(i.document.body,e),t},e.decorators=[{type:t.Directive,args:[{selector:"[bsModal]",exportAs:"bs-modal"}]}],e.ctorParameters=function(){return[{type:t.ElementRef},{type:t.ViewContainerRef},{type:t.Renderer2},{type:n.ComponentLoaderFactory}]},e.propDecorators={config:[{type:t.Input}],onShow:[{type:t.Output}],onShown:[{type:t.Output}],onHide:[{type:t.Output}],onHidden:[{type:t.Output}],onClickStarted:[{type:t.HostListener,args:["mousedown",["$event"]]}],onClickStop:[{type:t.HostListener,args:["mouseup",["$event"]]}],onEsc:[{type:t.HostListener,args:["keydown.esc",["$event"]]}]},e}();var v=function(){function e(e,i){this.clf=i,this.config=c,this.onShow=new t.EventEmitter,this.onShown=new t.EventEmitter,this.onHide=new t.EventEmitter,this.onHidden=new t.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({},c,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=this.modalsCount>=1?this.modalsCount-1:0,setTimeout((function(){t._hideModal(e),t.removeLoaders(e)}),this.config.animated?p: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(y).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?p:0;setTimeout((function(){return e.removeBackdrop()}),t)}},e.prototype._showModal=function(e){var t,i,n=this,o=this.loaders[this.loaders.length-1];if(this.config&&this.config.providers)try{for(var a=s(this.config.providers),c=a.next();!c.done;c=a.next()){var h=c.value;o.provide(h)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(t)throw t.error}}var p=new r,u=o.provide({provide:d,useValue:this.config}).provide({provide:r,useValue:p}).attach(f).to("body").show({content:e,isAnimated:this.config.animated,initialState:this.config.initialState,bsModalService:this});return u.instance.level=this.getModalsCount(),p.hide=function(){var e=n.config.animated?l:0;setTimeout((function(){return u.instance.hide()}),e)},p.content=o.getInnerComponent()||null,p.setClass=function(e){u.instance.config.class=e},p},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:t.Injectable}],e.ctorParameters=function(){return[{type:t.RendererFactory2},{type:n.ComponentLoaderFactory}]},e}();var b=function(){function e(){}return e.forRoot=function(){return{ngModule:e,providers:[v,n.ComponentLoaderFactory,o.PositioningService]}},e.forChild=function(){return{ngModule:e,providers:[v,n.ComponentLoaderFactory,o.PositioningService]}},e.decorators=[{type:t.NgModule,args:[{declarations:[y,g,f],exports:[y,g],entryComponents:[y,f]}]}],e}();e.BsModalRef=r,e.BsModalService=v,e.ModalBackdropComponent=y,e.ModalBackdropOptions=a,e.ModalContainerComponent=f,e.ModalDirective=g,e.ModalModule=b,e.ModalOptions=d,e.ɵa=h,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ngx-bootstrap-modal.umd.min.js.map