snappymail/dev/Component/Checkbox.js

18 lines
413 B
JavaScript
Raw Normal View History

export class CheckboxComponent {
constructor(params = {}) {
this.name = params.name;
this.value = ko.isObservable(params.value) ? params.value
: ko.observable(!!params.value);
2015-11-15 08:23:16 +08:00
this.enable = ko.isObservable(params.enable) ? params.enable
: ko.observable(undefined === params.enable || !!params.enable);
this.label = params.label;
}
click() {
this.enable() && this.value(!this.value());
}
}