1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6 | };
|
7 | var __metadata = (this && this.__metadata) || function (k, v) {
|
8 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9 | };
|
10 | import { Component, EventEmitter, Input, Output } from '@angular/core';
|
11 | import { AlertConfig } from './alert.config';
|
12 | import { OnChange } from '../utils/decorators';
|
13 | export var AlertComponent = (function () {
|
14 | function AlertComponent(_config) {
|
15 | var _this = this;
|
16 |
|
17 | this.type = 'warning';
|
18 |
|
19 | this.dismissible = false;
|
20 |
|
21 | this.onClose = new EventEmitter();
|
22 |
|
23 | this.onClosed = new EventEmitter();
|
24 | this.isClosed = false;
|
25 | this.classes = '';
|
26 | this.dismissibleChange = new EventEmitter();
|
27 | Object.assign(this, _config);
|
28 | this.dismissibleChange.subscribe(function (dismissible) {
|
29 | _this.classes = _this.dismissible ? 'alert-dismissible' : '';
|
30 | });
|
31 | }
|
32 | AlertComponent.prototype.ngOnInit = function () {
|
33 | var _this = this;
|
34 | if (this.dismissOnTimeout) {
|
35 |
|
36 | setTimeout(function () { return _this.close(); }, parseInt(this.dismissOnTimeout, 10));
|
37 | }
|
38 | };
|
39 |
|
40 |
|
41 | |
42 |
|
43 |
|
44 | AlertComponent.prototype.close = function () {
|
45 | if (this.isClosed) {
|
46 | return;
|
47 | }
|
48 | this.onClose.emit(this);
|
49 | this.isClosed = true;
|
50 | this.onClosed.emit(this);
|
51 | };
|
52 | AlertComponent.decorators = [
|
53 | { type: Component, args: [{
|
54 | selector: 'alert,ngx-alert',
|
55 | template: "\n<template [ngIf]=\"!isClosed\">\n <div [class]=\"'alert alert-' + type\" role=\"alert\" [ngClass]=\"classes\">\n <template [ngIf]=\"dismissible\">\n <button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"close()\">\n <span aria-hidden=\"true\">×</span>\n <span class=\"sr-only\">Close</span>\n </button>\n </template>\n <ng-content></ng-content>\n </div>\n</template>\n "
|
56 | },] },
|
57 | ];
|
58 |
|
59 | AlertComponent.ctorParameters = function () { return [
|
60 | { type: AlertConfig, },
|
61 | ]; };
|
62 | AlertComponent.propDecorators = {
|
63 | 'type': [{ type: Input },],
|
64 | 'dismissible': [{ type: Input },],
|
65 | 'dismissOnTimeout': [{ type: Input },],
|
66 | 'onClose': [{ type: Output },],
|
67 | 'onClosed': [{ type: Output },],
|
68 | };
|
69 | __decorate([
|
70 | OnChange(),
|
71 | __metadata('design:type', Boolean)
|
72 | ], AlertComponent.prototype, "dismissible", void 0);
|
73 | return AlertComponent;
|
74 | }());
|
75 |
|
\ | No newline at end of file |