ng2-alert-center
Version:
Alert center provides an alert service and an alert component, you can include in your Angular 2 project.
56 lines • 2.66 kB
JavaScript
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Alert } from '../model/alert';
import { AlertType } from '../model/alert-type';
var AlertComponent = (function () {
function AlertComponent() {
this.alert = new Alert(AlertType.INFO, '', '');
this.htmlTextEnabled = false;
this.dismissed = new EventEmitter();
}
AlertComponent.prototype.ngOnInit = function () {
this.initTimerIfNeeded();
};
AlertComponent.prototype.isSuccess = function () {
return this.alert.alertType === AlertType.SUCCESS;
};
AlertComponent.prototype.isInfo = function () {
return this.alert.alertType === AlertType.INFO;
};
AlertComponent.prototype.isWarning = function () {
return this.alert.alertType === AlertType.WARNING;
};
AlertComponent.prototype.isDanger = function () {
return this.alert.alertType === AlertType.DANGER;
};
AlertComponent.prototype.dismiss = function () {
this.dismissed.emit();
};
AlertComponent.prototype.isDismissEnabled = function () {
return this.alert.isDismissable();
};
AlertComponent.prototype.isTextStrongDefined = function () {
return this.alert.textStrong && this.alert.textStrong.length > 0;
};
AlertComponent.prototype.initTimerIfNeeded = function () {
var _this = this;
if (this.alert.isAutoDismissing()) {
setTimeout(function () { return _this.dismiss(); }, this.alert.autoDismissTime);
}
};
return AlertComponent;
}());
export { AlertComponent };
AlertComponent.decorators = [
{ type: Component, args: [{
selector: 'nac-alert',
template: "\n <div class=\"alert\"\n [class.alert-success]=\"isSuccess()\"\n [class.alert-info]=\"isInfo()\"\n [class.alert-warning]=\"isWarning()\"\n [class.alert-danger]=\"isDanger()\">\n <button *ngIf=\"isDismissEnabled()\" type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\" (click)=\"dismiss()\">\n <span aria-hidden=\"true\">×</span>\n </button>\n <strong *ngIf=\"isTextStrongDefined()\">{{alert.textStrong}}</strong><span *ngIf=\"!htmlTextEnabled\">{{alert.text}}</span>\n <span *ngIf=\"htmlTextEnabled\" [innerHtml]=\"alert.text\"></span>\n </div>\n "
},] },
];
/** @nocollapse */
AlertComponent.ctorParameters = function () { return []; };
AlertComponent.propDecorators = {
'alert': [{ type: Input },],
'htmlTextEnabled': [{ type: Input },],
'dismissed': [{ type: Output },],
};
//# sourceMappingURL=alert.component.js.map