aurelia-materialize-bridge
Version:
Aurelia interface to http://materializecss.com/
55 lines (43 loc) • 1.07 kB
text/typescript
import * as au from "../aurelia";
.customElement("md-radio")
.autoinject
export class MdRadio {
constructor(private element: Element) {
this.controlId = `md-radio-${MdRadio.id++}`;
}
static id = 0;
controlId: string;
attributeManager: au.AttributeManager;
radio: HTMLInputElement;
.bindable({ defaultBindingMode: au.bindingMode.twoWay })
checked: boolean | string;
.ato.bindable.booleanMd
disabled: boolean = false;
disabledChanged(newValue: boolean) {
if (this.radio) {
this.radio.disabled = newValue;
}
}
.ato.bindable.booleanMd
readonly: boolean = false;
.ato.bindable.booleanMd
gap: boolean = false;
.bindable
model: any;
.ato.bindable.stringMd
name: string = "";
.ato.bindable.stringMd
value: string = "";
attached() {
this.attributeManager = new au.AttributeManager(this.radio);
if (this.gap) {
this.attributeManager.addClasses("with-gap");
}
if (this.disabled) {
this.radio.disabled = true;
}
}
detached() {
this.attributeManager.removeClasses(["with-gap", "disabled"]);
}
}