SVGHMI: apply per class overloading of sub/unsub to Jump widget svghmi
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Sun, 10 May 2020 16:36:41 +0200
branchsvghmi
changeset 2953 15bebe9a2806
parent 2952 2adfce8908b4
child 2954 b5dccd0d99ac
SVGHMI: apply per class overloading of sub/unsub to Jump widget
svghmi/widget_jump.ysl2
--- a/svghmi/widget_jump.ysl2	Sun May 10 16:36:09 2020 +0200
+++ b/svghmi/widget_jump.ysl2	Sun May 10 16:36:41 2020 +0200
@@ -81,33 +81,19 @@
     |         this.active_elt_style = this.active_elt.getAttribute("style");
     |         this.inactive_elt_style = this.inactive_elt.getAttribute("style");
     }
-    if "$have_disability" {
+    choose {
+        when "$have_disability" {
     |         this.disabled_elt_style = this.disabled_elt.getAttribute("style");
+        }
+        otherwise {
+    |         this.sub = function(){};
+    |         this.unsub = function(){};
+    |         this.apply_cache = function(){};
+        }
     }
     |     },
 }
 
-// default : normal subscribing
-template "widget[@type='Jump']", mode="widget_subscribe" {
-    param "hmi_element";
-    const "activity" call "jump_widget_activity" with "hmi_element", "$hmi_element";
-    const "have_activity","string-length($activity)>0";
-    const "disability" call "jump_widget_disability" with "hmi_element", "$hmi_element";
-    const "have_disability","$have_activity and string-length($disability)>0";
-    choose {
-        when "$have_disability" {
-    |     sub: subscribe,
-    |     unsub: unsubscribe,
-    |     apply_cache: widget_apply_cache,
-        }
-        otherwise {
-    |     sub: function(){},
-    |     unsub: function(){},
-    |     apply_cache: function(){},
-        }
-    }
-}
-
 template "widget[@type='Jump']", mode="per_page_widget_template"{
     param "page_desc";
     /* check that given path is compatible with page's reference path */