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 encForm = new Form({id: "encryption", tag: document.getElementById("encryption")});
|
||||||
|
|
||||||
let encAdv = encForm.createCheckBox({label: "Advanced settings"});
|
|
||||||
let encMsg = encForm.createTextArea({label: "Message"});
|
let encMsg = encForm.createTextArea({label: "Message"});
|
||||||
let encPass = encForm.createPasswordInput({label: "Password"});
|
let encPass = encForm.createPasswordInput({label: "Password"});
|
||||||
let encButton = encForm.createButton({label: "Encrypt"});
|
let encButton = encForm.createButton({label: "Encrypt"});
|
||||||
|
@ -13,8 +13,8 @@ class InterfaceElement {
|
|||||||
this.#hidden = x;
|
this.#hidden = x;
|
||||||
|
|
||||||
this.handle.hidden = this.hidden;
|
this.handle.hidden = this.hidden;
|
||||||
if (this.label !== undefined) {
|
if (this.labelTag !== undefined) {
|
||||||
this.label.hidden = this.hidden;
|
this.labelTag.hidden = this.hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hidden === true) this.clearAlerts();
|
if (this.hidden === true) this.clearAlerts();
|
||||||
@ -42,6 +42,11 @@ class Form extends InterfaceElement {
|
|||||||
this.elements = [];
|
this.elements = [];
|
||||||
|
|
||||||
this.clearAlerts = this.clearAlerts.bind(this);
|
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;
|
#advanced = false;
|
||||||
@ -69,6 +74,10 @@ class Form extends InterfaceElement {
|
|||||||
|
|
||||||
appendElement(elem) {
|
appendElement(elem) {
|
||||||
this.handle.append(elem.fragment);
|
this.handle.append(elem.fragment);
|
||||||
|
this.elements.push(elem);
|
||||||
|
if (elem.advanced) {
|
||||||
|
elem.hidden = !this.advanced;
|
||||||
|
}
|
||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +160,7 @@ class FormElement extends InterfaceElement {
|
|||||||
this.handle.disabled = !this.#enabled;
|
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});
|
super({tag});
|
||||||
|
|
||||||
this.clearAlerts = this.clearAlerts.bind(this);
|
this.clearAlerts = this.clearAlerts.bind(this);
|
||||||
@ -176,8 +185,6 @@ class FormElement extends InterfaceElement {
|
|||||||
} else {
|
} else {
|
||||||
this.fragment = fragment;
|
this.fragment = fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.advanced === true) this.hidden = !form.advanced;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get value() {
|
get value() {
|
||||||
|
Loading…
Reference in New Issue
Block a user