diff -r cc0ecc5e918f -r ec365ef396b1 svghmi/gen_index_xhtml.xslt
--- a/svghmi/gen_index_xhtml.xslt Thu Apr 01 15:57:06 2021 +0200
+++ b/svghmi/gen_index_xhtml.xslt Thu Apr 01 16:00:58 2021 +0200
@@ -6715,7 +6715,10 @@
choices: [
-
+
+
+
+
{
@@ -6770,15 +6773,7 @@
//toggle state and apply
- if (this.state) {
-
- this.state = 0;
-
- } else {
-
- this.state = 1;
-
- }
+ this.state = this.state ? false : true;
this.apply_hmi_value(0, this.state);
@@ -6792,23 +6787,27 @@
+ activate(val) {
+
+ let [active, inactive] = val ? ["none",""] : ["", "none"];
+
+ if (this.active_elt)
+
+ this.active_elt.style.display = active;
+
+ if (this.inactive_elt)
+
+ this.inactive_elt.style.display = inactive;
+
+ }
+
+
+
animate(){
- // redraw toggle button on screen refresh
-
- if (this.state) {
-
- this.active_elt.setAttribute("style", this.active_style);
-
- this.inactive_elt.setAttribute("style", "display:none");
-
- } else {
-
- this.inactive_elt.setAttribute("style", this.inactive_style);
-
- this.active_elt.setAttribute("style", "display:none");
-
- }
+ // redraw toggle button on screen refresh
+
+ this.activate(this.state);
}
@@ -6816,23 +6815,9 @@
init() {
- this.active_style = this.active_elt ? this.active_elt.style.cssText : undefined;
-
- this.inactive_style = this.inactive_elt ? this.inactive_elt.style.cssText : undefined;
-
-
-
- if (this.active_style && this.inactive_style) {
-
- this.active_elt.setAttribute("style", "display:none");
-
- this.inactive_elt.setAttribute("style", this.inactive_style);
-
- }
-
-
-
- this.element.setAttribute("onclick", "hmi_widgets['"+this.element_id+"'].on_click(evt)");
+ this.activate(false);
+
+ this.element.onclick = (evt) => this.on_click(evt);
}
@@ -6848,8 +6833,6 @@
-
-