aurelia-materialize-bridge
Version:
Aurelia interface to http://materializecss.com/
46 lines (33 loc) • 1.06 kB
text/typescript
import * as au from "../aurelia";
.customElement("md-file")
.autoinject
export class MdFileInput {
constructor(private element: Element) { }
.ato.bindable.stringMd
caption = "File";
.ato.bindable.booleanMd({ defaultBindingMode: au.bindingMode.oneTime })
multiple: boolean = false;
.ato.bindable.stringMd({ defaultBindingMode: au.bindingMode.twoWay })
labelValue: string = "";
.ato.bindable.booleanMd
disabled: boolean = false;
.ato.bindable.booleanMd
readonly: boolean = false;
filePath: HTMLInputElement;
files: FileList;
suspendUpdate = false;
attached() {
this.filePath.addEventListener("change", this.handleChangeFromNativeInput);
}
detached() {
this.filePath.removeEventListener("change", this.handleChangeFromNativeInput);
}
handleChangeFromNativeInput = () => {
if (!this.suspendUpdate) {
this.suspendUpdate = true;
au.fireEvent(this.filePath, "change", { files: this.files });
au.fireMaterializeEvent(this.filePath, "change", { files: this.files });
this.suspendUpdate = false;
}
}
}