UNPKG

ngx-bootstrap-ci

Version:
1,156 lines (1,142 loc) 104 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; /** * Sets new class to modal window */ this.setClass = 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; bsModalRef.setClass = function (newClass) { modalContainerRef.instance.config.class = newClass; }; 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LWJvb3RzdHJhcC1tb2RhbC51bWQuanMubWFwIiwic291cmNlcyI6WyJuZzovL25neC1ib290c3RyYXAvbW9kYWwvYnMtbW9kYWwtcmVmLnNlcnZpY2UudHMiLCJuZzovL25neC1ib290c3RyYXAvbW9kYWwvbW9kYWwtYmFja2Ryb3Aub3B0aW9ucy50cyIsIm5nOi8vbmd4LWJvb3RzdHJhcC9tb2RhbC9tb2RhbC1vcHRpb25zLmNsYXNzLnRzIiwibmc6Ly9uZ3gtYm9vdHN0cmFwL21vZGFsL21vZGFsLWNvbnRhaW5lci5jb21wb25lbnQudHMiLCJuZzovL25neC1ib290c3RyYXAvbW9kYWwvbW9kYWwtYmFja2Ryb3AuY29tcG9uZW50LnRzIiwibmc6Ly9uZ3gtYm9vdHN0cmFwL21vZGFsL21vZGFsLmRpcmVjdGl2ZS50cyIsIm5nOi8vbmd4LWJvb3RzdHJhcC9tb2RhbC9icy1tb2RhbC5zZXJ2aWNlLnRzIiwibmc6Ly9uZ3gtYm9vdHN0cmFwL21vZGFsL21vZGFsLm1vZHVsZS50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcn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