interface.js: provide advanced options check boxes
This commit is contained in:
parent
71d4e3f58d
commit
bbc4fdb5c5
@ -1,6 +1,5 @@
|
||||
let encForm = new Form({id: "encryption", tag: document.getElementById("encryption")});
|
||||
|
||||
let encAdv = encForm.createCheckBox({label: "Advanced settings"});
|
||||
let encMsg = encForm.createTextArea({label: "Message"});
|
||||
let encPass = encForm.createPasswordInput({label: "Password"});
|
||||
let encButton = encForm.createButton({label: "Encrypt"});
|
||||
|
@ -13,8 +13,8 @@ class InterfaceElement {
|
||||
this.#hidden = x;
|
||||
|
||||
this.handle.hidden = this.hidden;
|
||||
if (this.label !== undefined) {
|
||||
this.label.hidden = this.hidden;
|
||||
if (this.labelTag !== undefined) {
|
||||
this.labelTag.hidden = this.hidden;
|
||||
}
|
||||
|
||||
if (this.hidden === true) this.clearAlerts();
|
||||
@ -42,6 +42,11 @@ class Form extends InterfaceElement {
|
||||
this.elements = [];
|
||||
|
||||
this.clearAlerts = this.clearAlerts.bind(this);
|
||||
|
||||
let advancedToggle = this.createCheckBox({label: "Advanced settings"});
|
||||
advancedToggle.handle.addEventListener('change', function() {
|
||||
this.advanced = advancedToggle.value;
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
#advanced = false;
|
||||
@ -69,6 +74,10 @@ class Form extends InterfaceElement {
|
||||
|
||||
appendElement(elem) {
|
||||
this.handle.append(elem.fragment);
|
||||
this.elements.push(elem);
|
||||
if (elem.advanced) {
|
||||
elem.hidden = !this.advanced;
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
|
||||
@ -151,7 +160,7 @@ class FormElement extends InterfaceElement {
|
||||
this.handle.disabled = !this.#enabled;
|
||||
}
|
||||
|
||||
constructor({form, tag, labelTag, label="", fragment, dataType, advanced=false, enabled=true}) {
|
||||
constructor({tag, labelTag, label="", fragment, dataType, advanced=false, enabled=true}) {
|
||||
super({tag});
|
||||
|
||||
this.clearAlerts = this.clearAlerts.bind(this);
|
||||
@ -176,8 +185,6 @@ class FormElement extends InterfaceElement {
|
||||
} else {
|
||||
this.fragment = fragment;
|
||||
}
|
||||
|
||||
if (this.advanced === true) this.hidden = !form.advanced;
|
||||
}
|
||||
|
||||
get value() {
|
||||
|
Loading…
Reference in New Issue
Block a user