aurelia-materialize-bridge
Version:
Aurelia interface to http://materializecss.com/
43 lines (36 loc) • 910 B
text/typescript
import * as au from "../aurelia";
.customAttribute("md-badge")
.autoinject
export class MdBadge {
constructor(private element: Element) {
this.attributeManager = new au.AttributeManager(this.element);
}
.ato.bindable
isNew: boolean = false;
isNewChanged() {
if (this.isNew) {
this.attributeManager.addClasses("new");
}
else {
this.attributeManager.removeClasses("new");
}
}
.ato.bindable
caption: string = null;
captionChanged() {
if (this.caption !== null) {
this.attributeManager.addAttributes({ "data-badge-caption": this.caption });
}
else {
this.attributeManager.removeAttributes(["data-badge-caption"]);
}
}
attributeManager: au.AttributeManager;
attached() {
this.element.classList.add("badge");
}
detached() {
this.attributeManager.removeClasses(["badge", "new"]);
this.attributeManager.removeAttributes(["data-badge-caption"]);
}
}