diff -r fe819b4c62c0 -r 5f756332ada1 svghmi/widget_jump.ysl2 --- a/svghmi/widget_jump.ysl2 Wed May 12 11:38:00 2021 +0200 +++ b/svghmi/widget_jump.ysl2 Mon May 17 08:52:38 2021 +0200 @@ -12,14 +12,29 @@ update_activity() { if(this.active) { /* show active */ - this.active_elt.setAttribute("style", this.active_elt_style); + this.active_elt.style.display = ""; /* hide inactive */ - this.inactive_elt.setAttribute("style", "display:none"); + this.inactive_elt.style.display = "none"; } else { /* show inactive */ - this.inactive_elt.setAttribute("style", this.inactive_elt_style); + this.inactive_elt.style.display = ""; /* hide active */ - this.active_elt.setAttribute("style", "display:none"); + this.active_elt.style.display = "none"; + } + } + + update_disability() { + if(this.disabled) { + /* show disabled */ + this.disabled_elt.style.display = ""; + /* hide inactive */ + this.inactive_elt.style.display = "none"; + /* hide active */ + this.active_elt.style.display = "none"; + } else { + /* hide disabled */ + this.disabled_elt.style.display = "none"; + this.update_activity(); } } @@ -27,10 +42,14 @@ let that = this; const name = this.args[0]; return function(evt){ - /* TODO: suport path pointing to local variable whom value - would be an HMI_TREE index to jump to a relative page */ - const index = that.indexes.length > 0 ? that.indexes[0] + that.offset : undefined; - switch_page(name, index); + /* TODO: in order to allow jumps to page selected through for exemple a dropdown, + support path pointing to local variable whom value + would be an HMI_TREE index and then jump to a relative page not hard-coded in advance */ + + if(!that.disabled) { + const index = that.indexes.length > 0 ? that.indexes[0] + that.offset : undefined; + switch_page(name, index); + } } } @@ -39,24 +58,13 @@ const ref_index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined; const ref_name = this.args[0]; this.active = ((ref_name == undefined || ref_name == page_name) && index == ref_index); - this.update_activity(); + this.update_state(); } } dispatch(value) { this.disabled = !Number(value); - if(this.disabled) { - /* show disabled */ - this.disabled_elt.setAttribute("style", this.disabled_elt_style); - /* hide inactive */ - this.inactive_elt.setAttribute("style", "display:none"); - /* hide active */ - this.active_elt.setAttribute("style", "display:none"); - } else { - /* hide disabled */ - this.disabled_elt.setAttribute("style", "display:none"); - this.update_activity(); - } + this.update_state(); } } || @@ -75,19 +83,24 @@ | init: function() { | this.element.onclick = this.make_on_click(); if "$have_activity" { - | this.active_elt_style = this.active_elt.getAttribute("style"); - | this.inactive_elt_style = this.inactive_elt.getAttribute("style"); | this.activable = true; } + if "not($have_disability)" { + | this.unsubscribable = true; + } + > this.update_state = choose { when "$have_disability" { - | this.disabled_elt_style = this.disabled_elt.getAttribute("style"); + > this.update_disability } - otherwise { - | this.unsubscribable = true; + when "$have_activity" { + > this.update_activity } + otherwise > null } + > ;\n | }, + } template "widget[@type='Jump']", mode="per_page_widget_template"{