ng2-encrm-components
Version:
70 lines • 2.58 kB
JavaScript
var core_1 = require('@angular/core');
var ALERT_TEMPLATE = "\n <div class=\"alert\" role=\"alert\" [ngClass]=\"classes\" *ngIf=\"!closed\">\n <button *ngIf=\"dismissible\" class=\"close\" (click)=\"onClose()\" (touch)=\"onClose()\" aria-label=\"Close\">\n <span aria-hidden=\"true\" class=\"material-icons\">cancel</span>\n </button>\n <ng-content></ng-content>\n </div>\n ";
/**
* BS4 alert component according to eniro style guide
*
* @class
*/
var AlertComponent = (function () {
function AlertComponent() {
/**
* flavor of alert, use one of bootstrap element flavors:
* primary, secondary, info, warning, danger
* @public
* @type {'warning' | 'info' | 'success' | 'danger'}
*/
this.type = 'warning';
/**
* event emitted after dismissing
* @public
* @type {EventEmitter<AlertComponent>}
*/
this.close = new core_1.EventEmitter(false);
this.classes = [];
}
AlertComponent.prototype.ngOnInit = function () {
var _this = this;
this.classes[0] = "alert-" + this.type;
if (this.dismissible) {
this.classes[1] = 'alert-dismissible';
}
else {
this.classes.length = 1;
}
if (this.dismissOnTimeout) {
setTimeout(function () { return _this.onClose(); }, this.dismissOnTimeout);
}
};
// todo: mouse event + touch + pointer
AlertComponent.prototype.onClose = function () {
this.closed = true;
this.close.emit(this);
};
__decorate([
core_1.Input(),
__metadata('design:type', Object)
], AlertComponent.prototype, "type", void 0);
__decorate([
core_1.Input(),
__metadata('design:type', Boolean)
], AlertComponent.prototype, "dismissible", void 0);
__decorate([
core_1.Input(),
__metadata('design:type', Number)
], AlertComponent.prototype, "dismissOnTimeout", void 0);
__decorate([
core_1.Output(),
__metadata('design:type', core_1.EventEmitter)
], AlertComponent.prototype, "close", void 0);
AlertComponent = __decorate([
core_1.Component({
selector: 'en-alert',
template: ALERT_TEMPLATE
}),
__metadata('design:paramtypes', [])
], AlertComponent);
return AlertComponent;
}());
exports.AlertComponent = AlertComponent;
//# sourceMappingURL=alert.component.js.map
;