mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-15 12:15:20 +08:00
23 lines
533 B
JavaScript
23 lines
533 B
JavaScript
import ko from 'ko';
|
|
|
|
export class AbstractCheckbox {
|
|
/**
|
|
* @param {Object} params = {}
|
|
*/
|
|
constructor(params = {}) {
|
|
this.value = ko.isObservable(params.value) ? params.value
|
|
: ko.observable(!!params.value);
|
|
|
|
this.enable = ko.isObservable(params.enable) ? params.enable
|
|
: ko.observable(undefined === params.enable || !!params.enable);
|
|
|
|
this.label = params.label || '';
|
|
this.inline = !!params.inline;
|
|
|
|
this.labeled = undefined !== params.label;
|
|
}
|
|
|
|
click() {
|
|
this.enable() && this.value(!this.value());
|
|
}
|
|
}
|