@web-atoms/core
Version:
62 lines (61 loc) • 2.37 kB
JavaScript
System.register(["tslib", "../../core/Bind", "../../core/BindableProperty", "../../core/XNode", "../styles/AtomNotificationStyle", "./AtomControl"], function (_export, _context) {
"use strict";
var __decorate, __metadata, Bind, BindableProperty, XNode, AtomNotificationStyle, AtomControl, AtomNotification;
_export("default", void 0);
return {
setters: [function (_tslib) {
__decorate = _tslib.__decorate;
__metadata = _tslib.__metadata;
}, function (_coreBind) {
Bind = _coreBind.default;
}, function (_coreBindableProperty) {
BindableProperty = _coreBindableProperty.BindableProperty;
}, function (_coreXNode) {
XNode = _coreXNode.default;
}, function (_stylesAtomNotificationStyle) {
AtomNotificationStyle = _stylesAtomNotificationStyle.default;
}, function (_AtomControl) {
AtomControl = _AtomControl.AtomControl;
}],
execute: function () {
_export("default", AtomNotification = class AtomNotification extends AtomControl {
constructor() {
super(...arguments);
this.timeout = 5000;
this.timeoutKey = null;
}
onPropertyChanged(name) {
switch (name) {
case "timeout":
this.setupTimeout();
break;
}
}
create() {
this.defaultControlStyle = AtomNotificationStyle;
this.render(XNode.create("div", {
formattedText: Bind.oneWay(() => this.viewModel.message),
timeout: Bind.oneWay(() => this.viewModel.timeout || 5000),
styleClass: Bind.oneWay(() => ({
[this.controlStyle.name]: 1,
error: this.viewModel.type && /error/i.test(this.viewModel.type),
warning: this.viewModel.type && /warn/i.test(this.viewModel.type)
}))
}));
}
setupTimeout() {
if (this.timeoutKey) {
clearTimeout(this.timeoutKey);
}
this.timeoutKey = setTimeout(() => {
if (this.element) {
this.app.broadcast(`atom-window-close:${this.id}`, "");
}
}, this.timeout);
}
});
__decorate([BindableProperty, __metadata("design:type", Number)], AtomNotification.prototype, "timeout", void 0);
}
};
});
//# sourceMappingURL=AtomNotification.js.map