UNPKG

ng2-json-editor

Version:

Angular2 component for editing large json documents

84 lines 4.09 kB
/* * This file is part of ng2-json-editor. * Copyright (C) 2016 CERN. * * ng2-json-editor is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * ng2-json-editor is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ng2-json-editor; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * In applying this license, CERN does not * waive the privileges and immunities granted to it by virtue of its status * as an Intergovernmental Organization or submit itself to any jurisdiction. */ var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { Component, ChangeDetectorRef, ChangeDetectionStrategy, ViewChild } from '@angular/core'; import { AbstractSubscriberComponent } from '../abstract-subscriber'; import { ModalService } from '../shared/services'; var ModalViewComponent = (function (_super) { __extends(ModalViewComponent, _super); // TODO: unsubcribe on destroy function ModalViewComponent(modalService, changeDetectorRef) { var _this = _super.call(this) || this; _this.modalService = modalService; _this.changeDetectorRef = changeDetectorRef; return _this; } ModalViewComponent.prototype.ngOnInit = function () { var _this = this; this.modalService .display$ .takeUntil(this.isDestroyed) .subscribe(function (display) { display ? _this.modal.show() : _this.modal.hide(); }); this.modalService .options$ .takeUntil(this.isDestroyed) .subscribe(function (options) { _this.options = options; _this.changeDetectorRef.markForCheck(); }); }; ModalViewComponent.prototype.onShow = function () { if (this.options && this.options.onShow) { this.options.onShow(); } }; return ModalViewComponent; }(AbstractSubscriberComponent)); export { ModalViewComponent }; ModalViewComponent.decorators = [ { type: Component, args: [{ selector: 'modal-view', styles: [""], template: "<div class=\"modal fade\" (onShown)=\"onShow()\" bsModal #modal=\"bs-modal\" tabindex=\"-1\" role=\"dialog\" [config]=\"{ backdrop: false }\"> <div class=\"modal-dialog modal-lg\"> <div *ngIf=\"options\" class=\"modal-content\"> <div class=\"modal-header\"> <button type=\"button\" class=\"close\" (click)=\"modal.hide()\">&times;</button> <h4 class=\"modal-title\">{{options.title}}</h4> </div> <div class=\"modal-body\"> <div [innerHTML]=\"options.bodyHtml\"></div> <div [ngSwitch]=\"options.type\"> <div *ngSwitchCase=\"'confirm'\"> <button class=\"btn btn-success\" (click)=\"options.onConfirm();\"> <i class=\"fa fa-check\"></i> Confirm </button> </div> </div> </div> </div> </div> </div>", changeDetection: ChangeDetectionStrategy.OnPush },] }, ]; /** @nocollapse */ ModalViewComponent.ctorParameters = function () { return [ { type: ModalService, }, { type: ChangeDetectorRef, }, ]; }; ModalViewComponent.propDecorators = { 'modal': [{ type: ViewChild, args: ['modal',] },], }; //# sourceMappingURL=modal-view.component.js.map