mirror of
https://github.com/esiur/iui.git
synced 2025-05-06 06:42:58 +00:00
58 lines
1.2 KiB
JavaScript
58 lines
1.2 KiB
JavaScript
import IUIElement from "../Core/IUIElement.js";
|
|
import { IUI } from "../Core/IUI.js";
|
|
|
|
export default IUI.module(class Check extends IUIElement {
|
|
constructor(properties) {
|
|
super(IUI.extend(properties, { cssClass: 'check' }));
|
|
|
|
this._register("check");
|
|
|
|
this.on("click", () => {
|
|
this.checked = !this.checked;
|
|
});
|
|
}
|
|
|
|
get checked() {
|
|
return this.hasAttribute("checked");
|
|
}
|
|
|
|
set checked(value) {
|
|
this.check(value);
|
|
this._emit("check", { checked: value });
|
|
}
|
|
|
|
check(value) {
|
|
if (value)
|
|
this.setAttribute("checked", "checked");
|
|
else
|
|
this.removeAttribute("checked");
|
|
}
|
|
|
|
create() {
|
|
this.field = this.getAttribute("field");
|
|
}
|
|
|
|
async setData(value) {
|
|
await super.setData(value);
|
|
if (value != null && this.field != null)
|
|
this.value = value[this.field];
|
|
else if (this.field != null)
|
|
this.value = null;
|
|
}
|
|
|
|
|
|
modified(name, value) {
|
|
if (name == this.field) {
|
|
this.value = value;
|
|
}
|
|
}
|
|
|
|
get value() {
|
|
return this.checked;
|
|
}
|
|
|
|
set value(value) {
|
|
this.checked = value;
|
|
}
|
|
|
|
}); |