UNPKG

ngx-bootstrap

Version:
1,149 lines (1,135 loc) 103 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('ngx-bootstrap/utils'), require('ngx-bootstrap/component-loader'), require('ngx-bootstrap/positioning')) : typeof define === 'function' && define.amd ? define('ngx-bootstrap/modal', ['exports', '@angular/core', 'ngx-bootstrap/utils', 'ngx-bootstrap/component-loader', 'ngx-bootstrap/positioning'], factory) : (factory((global['ngx-bootstrap'] = global['ngx-bootstrap'] || {}, global['ngx-bootstrap'].modal = {}),global.ng.core,global.utils,global.componentLoader,global.positioning)); }(this, (function (exports,core,utils,componentLoader,positioning) { 'use strict'; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var BsModalRef = (function () { function BsModalRef() { /** * Hides the modal */ this.hide = Function; } BsModalRef.decorators = [ { type: core.Injectable } ]; return BsModalRef; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var ModalBackdropOptions = (function () { function ModalBackdropOptions(options) { this.animate = true; Object.assign(this, options); } return ModalBackdropOptions; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var ModalOptions = (function () { function ModalOptions() { } ModalOptions.decorators = [ { type: core.Injectable } ]; return ModalOptions; }()); var /** @type {?} */ modalConfigDefaults = { backdrop: true, keyboard: true, focus: true, show: false, ignoreBackdropClick: false, class: '', animated: true, initialState: {} }; var /** @type {?} */ CLASS_NAME = { SCROLLBAR_MEASURER: 'modal-scrollbar-measure', BACKDROP: 'modal-backdrop', OPEN: 'modal-open', FADE: 'fade', IN: 'in', // bs3 SHOW: 'show' // bs4 }; var /** @type {?} */ TRANSITION_DURATIONS = { MODAL: 300, BACKDROP: 150 }; var /** @type {?} */ DISMISS_REASONS = { BACKRDOP: 'backdrop-click', ESC: 'esc' }; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var ModalContainerComponent = (function () { function ModalContainerComponent(options, _element, _renderer) { this._element = _element; this._renderer = _renderer; this.isShown = false; this.isModalHiding = false; this.config = Object.assign({}, options); } /** * @return {?} */ ModalContainerComponent.prototype.ngOnInit = /** * @return {?} */ function () { var _this = this; if (this.isAnimated) { this._renderer.addClass(this._element.nativeElement, CLASS_NAME.FADE); } this._renderer.setStyle(this._element.nativeElement, 'display', 'block'); setTimeout(function () { _this.isShown = true; _this._renderer.addClass(_this._element.nativeElement, utils.isBs3() ? CLASS_NAME.IN : CLASS_NAME.SHOW); }, this.isAnimated ? TRANSITION_DURATIONS.BACKDROP : 0); if (document && document.body) { if (this.bsModalService.getModalsCount() === 1) { this.bsModalService.checkScrollbar(); this.bsModalService.setScrollbar(); } this._renderer.addClass(document.body, CLASS_NAME.OPEN); } if (this._element.nativeElement) { this._element.nativeElement.focus(); } }; /** * @param {?} event * @return {?} */ ModalContainerComponent.prototype.onClick = /** * @param {?} event * @return {?} */ function (event) { if (this.config.ignoreBackdropClick || this.config.backdrop === 'static' || event.target !== this._element.nativeElement) { return; } this.bsModalService.setDismissReason(DISMISS_REASONS.BACKRDOP); this.hide(); }; /** * @param {?} event * @return {?} */ ModalContainerComponent.prototype.onEsc = /** * @param {?} event * @return {?} */ function (event) { if (!this.isShown) { return; } // tslint:disable-next-line:deprecation if (event.keyCode === 27 || event.key === 'Escape') { event.preventDefault(); } if (this.config.keyboard && this.level === this.bsModalService.getModalsCount()) { this.bsModalService.setDismissReason(DISMISS_REASONS.ESC); this.hide(); } }; /** * @return {?} */ ModalContainerComponent.prototype.ngOnDestroy = /** * @return {?} */ function () { if (this.isShown) { this.hide(); } }; /** * @return {?} */ ModalContainerComponent.prototype.hide = /** * @return {?} */ function () { var _this = this; if (this.isModalHiding || !this.isShown) { return; } this.isModalHiding = true; this._renderer.removeClass(this._element.nativeElement, utils.isBs3() ? CLASS_NAME.IN : CLASS_NAME.SHOW); setTimeout(function () { _this.isShown = false; if (document && document.body && _this.bsModalService.getModalsCount() === 1) { _this._renderer.removeClass(document.body, CLASS_NAME.OPEN); } _this.bsModalService.hide(_this.level); _this.isModalHiding = false; }, this.isAnimated ? TRANSITION_DURATIONS.MODAL : 0); }; ModalContainerComponent.decorators = [ { type: core.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' } }] } ]; /** @nocollapse */ ModalContainerComponent.ctorParameters = function () { return [ { type: ModalOptions, }, { type: core.ElementRef, }, { type: core.Renderer2, }, ]; }; ModalContainerComponent.propDecorators = { "onClick": [{ type: core.HostListener, args: ['click', ['$event'],] },], "onEsc": [{ type: core.HostListener, args: ['window:keydown.esc', ['$event'],] },], }; return ModalContainerComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ /** * This component will be added as background layout for modals if enabled */ var ModalBackdropComponent = (function () { function ModalBackdropComponent(element, renderer) { this._isShown = false; this.element = element; this.renderer = renderer; } Object.defineProperty(ModalBackdropComponent.prototype, "isAnimated", { get: /** * @return {?} */ function () { return this._isAnimated; }, set: /** * @param {?} value * @return {?} */ function (value) { this._isAnimated = value; // this.renderer.setElementClass(this.element.nativeElement, `${ClassName.FADE}`, value); }, enumerable: true, configurable: true }); Object.defineProperty(ModalBackdropComponent.prototype, "isShown", { get: /** * @return {?} */ function () { return this._isShown; }, set: /** * @param {?} value * @return {?} */ function (value) { this._isShown = value; if (value) { this.renderer.addClass(this.element.nativeElement, "" + CLASS_NAME.IN); } else { this.renderer.removeClass(this.element.nativeElement, "" + CLASS_NAME.IN); } if (!utils.isBs3()) { if (value) { this.renderer.addClass(this.element.nativeElement, "" + CLASS_NAME.SHOW); } else { this.renderer.removeClass(this.element.nativeElement, "" + CLASS_NAME.SHOW); } } }, enumerable: true, configurable: true }); /** * @return {?} */ ModalBackdropComponent.prototype.ngOnInit = /** * @return {?} */ function () { if (this.isAnimated) { this.renderer.addClass(this.element.nativeElement, "" + CLASS_NAME.FADE); utils.Utils.reflow(this.element.nativeElement); } this.isShown = true; }; ModalBackdropComponent.decorators = [ { type: core.Component, args: [{ selector: 'bs-modal-backdrop', template: ' ', host: { class: CLASS_NAME.BACKDROP } }] } ]; /** @nocollapse */ ModalBackdropComponent.ctorParameters = function () { return [ { type: core.ElementRef, }, { type: core.Renderer2, }, ]; }; return ModalBackdropComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var /** @type {?} */ TRANSITION_DURATION = 300; var /** @type {?} */ BACKDROP_TRANSITION_DURATION = 150; /** * Mark any code with directive to show it's content in modal */ var ModalDirective = (function () { function ModalDirective(_element, _viewContainerRef, _renderer, clf) { this._element = _element; this._renderer = _renderer; /** * This event fires immediately when the `show` instance method is called. */ this.onShow = new core.EventEmitter(); /** * This event is fired when the modal has been made visible to the user * (will wait for CSS transitions to complete) */ this.onShown = new core.EventEmitter(); /** * This event is fired immediately when * the hide instance method has been called. */ this.onHide = new core.EventEmitter(); /** * This event is fired when the modal has finished being * hidden from the user (will wait for CSS transitions to complete). */ this.onHidden = new core.EventEmitter(); this._isShown = false; this.isBodyOverflowing = false; this.originalBodyPadding = 0; this.scrollbarWidth = 0; this.timerHideModal = 0; this.timerRmBackDrop = 0; this.isNested = false; this._backdrop = clf.createLoader(_element, _viewContainerRef, _renderer); } Object.defineProperty(ModalDirective.prototype, "config", { get: /** * @return {?} */ function () { return this._config; }, set: /** * allows to set modal configuration via element property * @param {?} conf * @return {?} */ function (conf) { this._config = this.getConfig(conf); }, enumerable: true, configurable: true }); Object.defineProperty(ModalDirective.prototype, "isShown", { get: /** * @return {?} */ function () { return this._isShown; }, enumerable: true, configurable: true }); /** * @param {?} event * @return {?} */ ModalDirective.prototype.onClick = /** * @param {?} event * @return {?} */ function (event) { if (this.config.ignoreBackdropClick || this.config.backdrop === 'static' || event.target !== this._element.nativeElement) { return; } this.dismissReason = DISMISS_REASONS.BACKRDOP; this.hide(event); }; /** * @param {?} event * @return {?} */ ModalDirective.prototype.onEsc = /** * @param {?} event * @return {?} */ function (event) { if (!this._isShown) { return; } // tslint:disable-next-line:deprecation if (event.keyCode === 27 || event.key === 'Escape') { event.preventDefault(); } if (this.config.keyboard) { this.dismissReason = DISMISS_REASONS.ESC; this.hide(); } }; /** * @return {?} */ ModalDirective.prototype.ngOnDestroy = /** * @return {?} */ function () { this.config = void 0; if (this._isShown) { this._isShown = false; this.hideModal(); this._backdrop.dispose(); } }; /** * @return {?} */ ModalDirective.prototype.ngOnInit = /** * @return {?} */ function () { var _this = this; this._config = this._config || this.getConfig(); setTimeout(function () { if (_this._config.show) { _this.show(); } }, 0); }; /* Public methods */ /** Allows to manually toggle modal visibility */ /** * Allows to manually toggle modal visibility * @return {?} */ ModalDirective.prototype.toggle = /** * Allows to manually toggle modal visibility * @return {?} */ function () { return this._isShown ? this.hide() : this.show(); }; /** Allows to manually open modal */ /** * Allows to manually open modal * @return {?} */ ModalDirective.prototype.show = /** * Allows to manually open modal * @return {?} */ function () { var _this = this; this.dismissReason = null; this.onShow.emit(this); if (this._isShown) { return; } clearTimeout(this.timerHideModal); clearTimeout(this.timerRmBackDrop); this._isShown = true; this.checkScrollbar(); this.setScrollbar(); if (utils.document && utils.document.body) { if (utils.document.body.classList.contains(CLASS_NAME.OPEN)) { this.isNested = true; } else { this._renderer.addClass(utils.document.body, CLASS_NAME.OPEN); } } this.showBackdrop(function () { _this.showElement(); }); }; /** Allows to manually close modal */ /** * Allows to manually close modal * @param {?=} event * @return {?} */ ModalDirective.prototype.hide = /** * Allows to manually close modal * @param {?=} event * @return {?} */ function (event) { var _this = this; if (event) { event.preventDefault(); } this.onHide.emit(this); // todo: add an option to prevent hiding if (!this._isShown) { return; } utils.window.clearTimeout(this.timerHideModal); utils.window.clearTimeout(this.timerRmBackDrop); this._isShown = false; this._renderer.removeClass(this._element.nativeElement, CLASS_NAME.IN); if (!utils.isBs3()) { this._renderer.removeClass(this._element.nativeElement, CLASS_NAME.SHOW); } // this._addClassIn = false; if (this._config.animated) { this.timerHideModal = utils.window.setTimeout(function () { return _this.hideModal(); }, TRANSITION_DURATION); } else { this.hideModal(); } }; /** Private methods @internal */ /** * Private methods \@internal * @param {?=} config * @return {?} */ ModalDirective.prototype.getConfig = /** * Private methods \@internal * @param {?=} config * @return {?} */ function (config) { return Object.assign({}, modalConfigDefaults, config); }; /** * Show dialog * @internal */ /** * Show dialog * \@internal * @return {?} */ ModalDirective.prototype.showElement = /** * Show dialog * \@internal * @return {?} */ function () { var _this = this; // todo: replace this with component loader usage if (!this._element.nativeElement.parentNode || this._element.nativeElement.parentNode.nodeType !== Node.ELEMENT_NODE) { // don't move modals dom position if (utils.document && utils.document.body) { utils.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); if (this._config.animated) { utils.Utils.reflow(this._element.nativeElement); } // this._addClassIn = true; this._renderer.addClass(this._element.nativeElement, CLASS_NAME.IN); if (!utils.isBs3()) { this._renderer.addClass(this._element.nativeElement, CLASS_NAME.SHOW); } var /** @type {?} */ transitionComplete = function () { if (_this._config.focus) { _this._element.nativeElement.focus(); } _this.onShown.emit(_this); }; if (this._config.animated) { setTimeout(transitionComplete, TRANSITION_DURATION); } else { transitionComplete(); } }; /** @internal */ /** * \@internal * @return {?} */ ModalDirective.prototype.hideModal = /** * \@internal * @return {?} */ function () { var _this = this; this._renderer.setAttribute(this._element.nativeElement, 'aria-hidden', 'true'); this._renderer.setStyle(this._element.nativeElement, 'display', 'none'); this.showBackdrop(function () { if (!_this.isNested) { if (utils.document && utils.document.body) { _this._renderer.removeClass(utils.document.body, CLASS_NAME.OPEN); } _this.resetScrollbar(); } _this.resetAdjustments(); _this.focusOtherModal(); _this.onHidden.emit(_this); }); }; // todo: original show was calling a callback when done, but we can use // promise /** @internal */ /** * \@internal * @param {?=} callback * @return {?} */ ModalDirective.prototype.showBackdrop = /** * \@internal * @param {?=} callback * @return {?} */ function (callback) { var _this = this; if (this._isShown && this.config.backdrop && (!this.backdrop || !this.backdrop.instance.isShown)) { this.removeBackdrop(); this._backdrop .attach(ModalBackdropComponent) .to('body') .show({ isAnimated: this._config.animated }); this.backdrop = this._backdrop._componentRef; if (!callback) { return; } if (!this._config.animated) { callback(); return; } setTimeout(callback, BACKDROP_TRANSITION_DURATION); } else if (!this._isShown && this.backdrop) { this.backdrop.instance.isShown = false; var /** @type {?} */ callbackRemove = function () { _this.removeBackdrop(); if (callback) { callback(); } }; if (this.backdrop.instance.isAnimated) { this.timerRmBackDrop = utils.window.setTimeout(callbackRemove, BACKDROP_TRANSITION_DURATION); } else { callbackRemove(); } } else if (callback) { callback(); } }; /** @internal */ /** * \@internal * @return {?} */ ModalDirective.prototype.removeBackdrop = /** * \@internal * @return {?} */ function () { this._backdrop.hide(); }; /** Events tricks */ // no need for it // protected setEscapeEvent():void { // if (this._isShown && this._config.keyboard) { // $(this._element).on(Event.KEYDOWN_DISMISS, (event) => { // if (event.which === 27) { // this.hide() // } // }) // // } else if (!this._isShown) { // $(this._element).off(Event.KEYDOWN_DISMISS) // } // } // protected setResizeEvent():void { // console.log(this.renderer.listenGlobal('', Event.RESIZE)); // if (this._isShown) { // $(window).on(Event.RESIZE, $.proxy(this._handleUpdate, this)) // } else { // $(window).off(Event.RESIZE) // } // } /** * Events tricks * @return {?} */ ModalDirective.prototype.focusOtherModal = /** * Events tricks * @return {?} */ function () { if (this._element.nativeElement.parentElement == null) { return; } var /** @type {?} */ otherOpenedModals = this._element.nativeElement.parentElement.querySelectorAll('.in[bsModal]'); if (!otherOpenedModals.length) { return; } otherOpenedModals[otherOpenedModals.length - 1].focus(); }; /** @internal */ /** * \@internal * @return {?} */ ModalDirective.prototype.resetAdjustments = /** * \@internal * @return {?} */ function () { this._renderer.setStyle(this._element.nativeElement, 'paddingLeft', ''); this._renderer.setStyle(this._element.nativeElement, 'paddingRight', ''); }; /** Scroll bar tricks */ /** @internal */ /** * \@internal * @return {?} */ ModalDirective.prototype.checkScrollbar = /** * \@internal * @return {?} */ function () { this.isBodyOverflowing = utils.document.body.clientWidth < utils.window.innerWidth; this.scrollbarWidth = this.getScrollbarWidth(); }; /** * @return {?} */ ModalDirective.prototype.setScrollbar = /** * @return {?} */ function () { if (!utils.document) { return; } this.originalBodyPadding = parseInt(utils.window .getComputedStyle(utils.document.body) .getPropertyValue('padding-right') || 0, 10); if (this.isBodyOverflowing) { utils.document.body.style.paddingRight = this.originalBodyPadding + this.scrollbarWidth + "px"; } }; /** * @return {?} */ ModalDirective.prototype.resetScrollbar = /** * @return {?} */ function () { utils.document.body.style.paddingRight = this.originalBodyPadding + "px"; }; // thx d.walsh /** * @return {?} */ ModalDirective.prototype.getScrollbarWidth = /** * @return {?} */ function () { var /** @type {?} */ scrollDiv = this._renderer.createElement('div'); this._renderer.addClass(scrollDiv, CLASS_NAME.SCROLLBAR_MEASURER); this._renderer.appendChild(utils.document.body, scrollDiv); var /** @type {?} */ scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; this._renderer.removeChild(utils.document.body, scrollDiv); return scrollbarWidth; }; ModalDirective.decorators = [ { type: core.Directive, args: [{ selector: '[bsModal]', exportAs: 'bs-modal' },] } ]; /** @nocollapse */ ModalDirective.ctorParameters = function () { return [ { type: core.ElementRef, }, { type: core.ViewContainerRef, }, { type: core.Renderer2, }, { type: componentLoader.ComponentLoaderFactory, }, ]; }; ModalDirective.propDecorators = { "config": [{ type: core.Input },], "onShow": [{ type: core.Output },], "onShown": [{ type: core.Output },], "onHide": [{ type: core.Output },], "onHidden": [{ type: core.Output },], "onClick": [{ type: core.HostListener, args: ['click', ['$event'],] },], "onEsc": [{ type: core.HostListener, args: ['keydown.esc', ['$event'],] },], }; return ModalDirective; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var BsModalService = (function () { function BsModalService(rendererFactory, clf) { this.clf = clf; // constructor props this.config = modalConfigDefaults; // tslint:disable-next-line:no-any this.onShow = new core.EventEmitter(); // tslint:disable-next-line:no-any this.onShown = new core.EventEmitter(); // tslint:disable-next-line:no-any this.onHide = new core.EventEmitter(); // tslint:disable-next-line:no-any this.onHidden = new core.EventEmitter(); this.isBodyOverflowing = false; this.originalBodyPadding = 0; this.scrollbarWidth = 0; this.modalsCount = 0; this.lastDismissReason = ''; this.loaders = []; this._backdropLoader = this.clf.createLoader(null, null, null); this._renderer = rendererFactory.createRenderer(null, null); } /** Shows a modal */ // tslint:disable-next-line:no-any /** * Shows a modal * @param {?} content * @param {?=} config * @return {?} */ BsModalService.prototype.show = /** * Shows a modal * @param {?} content * @param {?=} config * @return {?} */ function (content, config) { this.modalsCount++; this._createLoaders(); this.config = Object.assign({}, modalConfigDefaults, config); this._showBackdrop(); this.lastDismissReason = null; return this._showModal(content); }; /** * @param {?} level * @return {?} */ BsModalService.prototype.hide = /** * @param {?} level * @return {?} */ function (level) { var _this = this; if (this.modalsCount === 1) { this._hideBackdrop(); this.resetScrollbar(); } this.modalsCount = this.modalsCount >= 1 ? this.modalsCount - 1 : 0; setTimeout(function () { _this._hideModal(level); _this.removeLoaders(level); }, this.config.animated ? TRANSITION_DURATIONS.BACKDROP : 0); }; /** * @return {?} */ BsModalService.prototype._showBackdrop = /** * @return {?} */ function () { var /** @type {?} */ isBackdropEnabled = this.config.backdrop || this.config.backdrop === 'static'; var /** @type {?} */ isBackdropInDOM = !this.backdropRef || !this.backdropRef.instance.isShown; if (this.modalsCount === 1) { this.removeBackdrop(); if (isBackdropEnabled && isBackdropInDOM) { this._backdropLoader .attach(ModalBackdropComponent) .to('body') .show({ isAnimated: this.config.animated }); this.backdropRef = this._backdropLoader._componentRef; } } }; /** * @return {?} */ BsModalService.prototype._hideBackdrop = /** * @return {?} */ function () { var _this = this; if (!this.backdropRef) { return; } this.backdropRef.instance.isShown = false; var /** @type {?} */ duration = this.config.animated ? TRANSITION_DURATIONS.BACKDROP : 0; setTimeout(function () { return _this.removeBackdrop(); }, duration); }; // tslint:disable-next-line:no-any /** * @param {?} content * @return {?} */ BsModalService.prototype._showModal = /** * @param {?} content * @return {?} */ function (content) { var /** @type {?} */ modalLoader = this.loaders[this.loaders.length - 1]; var /** @type {?} */ bsModalRef = new BsModalRef(); var /** @type {?} */ modalContainerRef = modalLoader .provide({ provide: ModalOptions, useValue: this.config }) .provide({ provide: BsModalRef, useValue: bsModalRef }) .attach(ModalContainerComponent) .to('body') .show({ content: content, isAnimated: this.config.animated, initialState: this.config.initialState, bsModalService: this }); modalContainerRef.instance.level = this.getModalsCount(); bsModalRef.hide = function () { modalContainerRef.instance.hide(); }; bsModalRef.content = modalLoader.getInnerComponent() || null; return bsModalRef; }; /** * @param {?} level * @return {?} */ BsModalService.prototype._hideModal = /** * @param {?} level * @return {?} */ function (level) { var /** @type {?} */ modalLoader = this.loaders[level - 1]; if (modalLoader) { modalLoader.hide(); } }; /** * @return {?} */ BsModalService.prototype.getModalsCount = /** * @return {?} */ function () { return this.modalsCount; }; /** * @param {?} reason * @return {?} */ BsModalService.prototype.setDismissReason = /** * @param {?} reason * @return {?} */ function (reason) { this.lastDismissReason = reason; }; /** * @return {?} */ BsModalService.prototype.removeBackdrop = /** * @return {?} */ function () { this._backdropLoader.hide(); this.backdropRef = null; }; /** AFTER PR MERGE MODAL.COMPONENT WILL BE USING THIS CODE */ /** Scroll bar tricks */ /** @internal */ /** * \@internal * @return {?} */ BsModalService.prototype.checkScrollbar = /** * \@internal * @return {?} */ function () { this.isBodyOverflowing = document.body.clientWidth < window.innerWidth; this.scrollbarWidth = this.getScrollbarWidth(); }; /** * @return {?} */ BsModalService.prototype.setScrollbar = /** * @return {?} */ function () { if (!document) { return; } this.originalBodyPadding = parseInt(window .getComputedStyle(document.body) .getPropertyValue('padding-right') || '0', 10); if (this.isBodyOverflowing) { document.body.style.paddingRight = this.originalBodyPadding + this.scrollbarWidth + "px"; } }; /** * @return {?} */ BsModalService.prototype.resetScrollbar = /** * @return {?} */ function () { document.body.style.paddingRight = this.originalBodyPadding + "px"; }; /** * @return {?} */ BsModalService.prototype.getScrollbarWidth = /** * @return {?} */ function () { var /** @type {?} */ scrollDiv = this._renderer.createElement('div'); this._renderer.addClass(scrollDiv, CLASS_NAME.SCROLLBAR_MEASURER); this._renderer.appendChild(document.body, scrollDiv); var /** @type {?} */ scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; this._renderer.removeChild(document.body, scrollDiv); return scrollbarWidth; }; /** * @return {?} */ BsModalService.prototype._createLoaders = /** * @return {?} */ function () { var /** @type {?} */ loader = this.clf.createLoader(null, null, null); this.copyEvent(loader.onBeforeShow, this.onShow); this.copyEvent(loader.onShown, this.onShown); this.copyEvent(loader.onBeforeHide, this.onHide); this.copyEvent(loader.onHidden, this.onHidden); this.loaders.push(loader); }; /** * @param {?} level * @return {?} */ BsModalService.prototype.removeLoaders = /** * @param {?} level * @return {?} */ function (level) { this.loaders.splice(level - 1, 1); this.loaders.forEach(function (loader, i) { loader.instance.level = i + 1; }); }; /** * @param {?} from * @param {?} to * @return {?} */ BsModalService.prototype.copyEvent = /** * @param {?} from * @param {?} to * @return {?} */ function (from, to) { var _this = this; from.subscribe(function () { to.emit(_this.lastDismissReason); }); }; BsModalService.decorators = [ { type: core.Injectable } ]; /** @nocollapse */ BsModalService.ctorParameters = function () { return [ { type: core.RendererFactory2, }, { type: componentLoader.ComponentLoaderFactory, }, ]; }; return BsModalService; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var ModalModule = (function () { function ModalModule() { } /** * @return {?} */ ModalModule.forRoot = /** * @return {?} */ function () { return { ngModule: ModalModule, providers: [BsModalService, componentLoader.ComponentLoaderFactory, positioning.PositioningService] }; }; ModalModule.decorators = [ { type: core.NgModule, args: [{ declarations: [ ModalBackdropComponent, ModalDirective, ModalContainerComponent ], exports: [ModalBackdropComponent, ModalDirective], entryComponents: [ModalBackdropComponent, ModalContainerComponent] },] } ]; return ModalModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ exports.BsModalRef = BsModalRef; exports.ModalBackdropOptions = ModalBackdropOptions; exports.ModalContainerComponent = ModalContainerComponent; exports.ModalBackdropComponent = ModalBackdropComponent; exports.ModalOptions = ModalOptions; exports.ModalDirective = ModalDirective; exports.ModalModule = ModalModule; exports.BsModalService = BsModalService; exports.ɵa = CLASS_NAME; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LWJvb3RzdHJhcC1tb2RhbC51bWQuanMubWFwIiwic291cmNlcyI6WyJuZzovL25neC1ib290c3RyYXAvbW9kYWwvYnMtbW9kYWwtcmVmLnNlcnZpY2UudHMiLCJuZzovL25neC1ib290c3RyYXAvbW9kYWwvbW9kYWwtYmFja2Ryb3Aub3B0aW9ucy50cyIsIm5nOi8vbmd4LWJvb3RzdHJhcC9tb2RhbC9tb2RhbC1vcHRpb25zLmNsYXNzLnRzIiwibmc6Ly9uZ3gtYm9vdHN0cmFwL21vZGFsL21vZGFsLWNvbnRhaW5lci5jb21wb25lbnQudHMiLCJuZzovL25neC1ib290c3RyYXAvbW9kYWwvbW9kYWwtYmFja2Ryb3AuY29tcG9uZW50LnRzIiwibmc6Ly9uZ3gtYm9vdHN0cmFwL21vZGFsL21vZGFsLmRpcmVjdGl2ZS50cyIsIm5nOi8vbmd4LWJvb3RzdHJhcC9tb2RhbC9icy1tb2RhbC5zZXJ2aWNlLnRzIiwibmc6Ly9uZ3gtYm9vdHN0cmFwL21vZGFsL21vZGFsLm1vZHVsZS50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBJbmplY3RhYmxlIH0gZnJvbSAnQGFuZ3VsYXIvY29yZSc7XG5cbkBJbmplY3RhY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