author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Thu, 24 Dec 2020 16:56:19 +0100 | |
branch | svghmi |
changeset 3097 | a098b2dd9dff |
parent 3081 | 9e55061c87fa |
child 3107 | ee0704cc6dc8 |
permissions | -rw-r--r-- |
2883
8e3d130399b0
SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2882
diff
changeset
|
1 |
// widget_jump.ysl2 |
2779
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2763
diff
changeset
|
2 |
|
2903
881d0248b3ce
SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents:
2902
diff
changeset
|
3 |
function "jump_widget_activity" { |
881d0248b3ce
SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents:
2902
diff
changeset
|
4 |
param "hmi_element"; |
881d0248b3ce
SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents:
2902
diff
changeset
|
5 |
optional_labels("active inactive"); |
881d0248b3ce
SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents:
2902
diff
changeset
|
6 |
} |
881d0248b3ce
SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents:
2902
diff
changeset
|
7 |
|
2906
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
8 |
function "jump_widget_disability" { |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
9 |
param "hmi_element"; |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
10 |
optional_labels("disabled"); |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
11 |
} |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
12 |
|
2883
8e3d130399b0
SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2882
diff
changeset
|
13 |
template "widget[@type='Jump']", mode="widget_defs" { |
8e3d130399b0
SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2882
diff
changeset
|
14 |
param "hmi_element"; |
2906
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
15 |
const "activity" call "jump_widget_activity" with "hmi_element", "$hmi_element"; |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
16 |
const "have_activity","string-length($activity)>0"; |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
17 |
value "$activity"; |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
18 |
const "disability" call "jump_widget_disability" with "hmi_element", "$hmi_element"; |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
19 |
const "have_disability","$have_activity and string-length($disability)>0"; |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
20 |
value "$disability"; |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
21 |
if "$have_activity" { |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
22 |
| active: false, |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
23 |
if "$have_disability" { |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
24 |
| disabled: false, |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
25 |
| frequency: 2, |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
26 |
| dispatch: function(value) { |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
27 |
| this.disabled = !Number(value); |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
28 |
| this.update(); |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
29 |
| }, |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
30 |
} |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
31 |
| update: function(){ |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
32 |
if "$have_disability" { |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
33 |
| if(this.disabled) { |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
34 |
| /* show disabled */ |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
35 |
| this.disabled_elt.setAttribute("style", this.active_elt_style); |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
36 |
| /* hide inactive */ |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
37 |
| this.inactive_elt.setAttribute("style", "display:none"); |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
38 |
| /* hide active */ |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
39 |
| this.active_elt.setAttribute("style", "display:none"); |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
40 |
| } else { |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
41 |
| /* hide disabled */ |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
42 |
| this.disabled_elt.setAttribute("style", "display:none"); |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
43 |
} |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
44 |
| if(this.active) { |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
45 |
| /* show active */ |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
46 |
| this.active_elt.setAttribute("style", this.active_elt_style); |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
47 |
| /* hide inactive */ |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
48 |
| this.inactive_elt.setAttribute("style", "display:none"); |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
49 |
| } else { |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
50 |
| /* show inactive */ |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
51 |
| this.inactive_elt.setAttribute("style", this.inactive_elt_style); |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
52 |
| /* hide active */ |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
53 |
| this.active_elt.setAttribute("style", "display:none"); |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
54 |
| } |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
55 |
if "$have_disability" { |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
56 |
| } |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
57 |
} |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
58 |
| }, |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
59 |
} |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
60 |
if "$have_activity" { |
2903
881d0248b3ce
SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents:
2902
diff
changeset
|
61 |
| notify_page_change: function(page_name, index){ |
881d0248b3ce
SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents:
2902
diff
changeset
|
62 |
| const ref_index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined; |
881d0248b3ce
SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents:
2902
diff
changeset
|
63 |
| const ref_name = this.args[0]; |
2906
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
64 |
| this.active =((ref_name == undefined || ref_name == page_name) && index == ref_index); |
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
65 |
| this.update(); |
2903
881d0248b3ce
SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents:
2902
diff
changeset
|
66 |
| }, |
881d0248b3ce
SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents:
2902
diff
changeset
|
67 |
} |
3081
9e55061c87fa
SVGHMI: more attempts to prevent losing memory in JS closure
Edouard Tisserant
parents:
2980
diff
changeset
|
68 |
| make_on_click(){ |
9e55061c87fa
SVGHMI: more attempts to prevent losing memory in JS closure
Edouard Tisserant
parents:
2980
diff
changeset
|
69 |
| let that = this; |
9e55061c87fa
SVGHMI: more attempts to prevent losing memory in JS closure
Edouard Tisserant
parents:
2980
diff
changeset
|
70 |
| const name = this.args[0]; |
9e55061c87fa
SVGHMI: more attempts to prevent losing memory in JS closure
Edouard Tisserant
parents:
2980
diff
changeset
|
71 |
| return function(evt){ |
9e55061c87fa
SVGHMI: more attempts to prevent losing memory in JS closure
Edouard Tisserant
parents:
2980
diff
changeset
|
72 |
| const index = that.indexes.length > 0 ? that.indexes[0] + that.offset : undefined; |
9e55061c87fa
SVGHMI: more attempts to prevent losing memory in JS closure
Edouard Tisserant
parents:
2980
diff
changeset
|
73 |
| switch_page(name, index); |
9e55061c87fa
SVGHMI: more attempts to prevent losing memory in JS closure
Edouard Tisserant
parents:
2980
diff
changeset
|
74 |
| } |
9e55061c87fa
SVGHMI: more attempts to prevent losing memory in JS closure
Edouard Tisserant
parents:
2980
diff
changeset
|
75 |
| }, |
2883
8e3d130399b0
SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2882
diff
changeset
|
76 |
| init: function() { |
2901
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
77 |
/* registering event this way does not "click" through svg:use |
2883
8e3d130399b0
SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2882
diff
changeset
|
78 |
| this.element.onclick = evt => switch_page(this.args[0]); |
8e3d130399b0
SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2882
diff
changeset
|
79 |
event must be registered by adding attribute to element instead |
8e3d130399b0
SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2882
diff
changeset
|
80 |
TODO : generalize mouse event handling by global event capture + getElementsAtPoint() |
8e3d130399b0
SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2882
diff
changeset
|
81 |
*/ |
3081
9e55061c87fa
SVGHMI: more attempts to prevent losing memory in JS closure
Edouard Tisserant
parents:
2980
diff
changeset
|
82 |
| this.element.onclick = this.make_on_click(); |
2906
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
83 |
if "$have_activity" { |
2903
881d0248b3ce
SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents:
2902
diff
changeset
|
84 |
| this.active_elt_style = this.active_elt.getAttribute("style"); |
881d0248b3ce
SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents:
2902
diff
changeset
|
85 |
| this.inactive_elt_style = this.inactive_elt.getAttribute("style"); |
881d0248b3ce
SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents:
2902
diff
changeset
|
86 |
} |
2953
15bebe9a2806
SVGHMI: apply per class overloading of sub/unsub to Jump widget
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2943
diff
changeset
|
87 |
choose { |
15bebe9a2806
SVGHMI: apply per class overloading of sub/unsub to Jump widget
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2943
diff
changeset
|
88 |
when "$have_disability" { |
2906
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
89 |
| this.disabled_elt_style = this.disabled_elt.getAttribute("style"); |
2953
15bebe9a2806
SVGHMI: apply per class overloading of sub/unsub to Jump widget
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2943
diff
changeset
|
90 |
} |
15bebe9a2806
SVGHMI: apply per class overloading of sub/unsub to Jump widget
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2943
diff
changeset
|
91 |
otherwise { |
2980
2a21d6060d64
SVGHMI: add "unsubscribable" property to widgets in order to generalize what already happens for jump buttons.
Edouard Tisserant
parents:
2953
diff
changeset
|
92 |
| this.unsubscribable = true; |
2953
15bebe9a2806
SVGHMI: apply per class overloading of sub/unsub to Jump widget
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2943
diff
changeset
|
93 |
} |
2906
3b4a1319da09
SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents:
2903
diff
changeset
|
94 |
} |
2883
8e3d130399b0
SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2882
diff
changeset
|
95 |
| }, |
2753
9a7e12e96399
SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff
changeset
|
96 |
} |
2901
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
97 |
|
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
98 |
template "widget[@type='Jump']", mode="per_page_widget_template"{ |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
99 |
param "page_desc"; |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
100 |
/* check that given path is compatible with page's reference path */ |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
101 |
if "path" { |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
102 |
/* when no page name provided, check for same page */ |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
103 |
const "target_page_name" choose { |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
104 |
when "arg" value "arg[1]/@value"; |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
105 |
otherwise value "$page_desc/arg[1]/@value"; |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
106 |
} |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
107 |
const "target_page_path" choose { |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
108 |
when "arg" value "$hmi_pages_descs[arg[1]/@value = $target_page_name]/path[1]/@value"; |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
109 |
otherwise value "$page_desc/path[1]/@value"; |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
110 |
} |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
111 |
|
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
112 |
if "not(func:same_class_paths($target_page_path, path[1]/@value))" |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
113 |
error > Jump id="«@id»" to page "«$target_page_name»" with incompatible path "«path[1]/@value» (must be same class as "«$target_page_path»") |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
114 |
} |
3f5194bba67d
SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents:
2900
diff
changeset
|
115 |
} |
2942
b07ad97e6019
SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2912
diff
changeset
|
116 |
|
2943
304e88bae115
SVGHMI: added more meaningful namespaces to emit javascript code from.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2942
diff
changeset
|
117 |
emit "declarations:jump" |
2942
b07ad97e6019
SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2912
diff
changeset
|
118 |
|| |
b07ad97e6019
SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2912
diff
changeset
|
119 |
var jumps_need_update = false; |
b07ad97e6019
SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2912
diff
changeset
|
120 |
var jump_history = [[default_page, undefined]]; |
b07ad97e6019
SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2912
diff
changeset
|
121 |
|
b07ad97e6019
SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2912
diff
changeset
|
122 |
function update_jumps() { |
b07ad97e6019
SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2912
diff
changeset
|
123 |
page_desc[current_visible_page].jumps.map(w=>w.notify_page_change(current_visible_page,current_page_index)); |
b07ad97e6019
SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2912
diff
changeset
|
124 |
jumps_need_update = false; |
b07ad97e6019
SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2912
diff
changeset
|
125 |
}; |
b07ad97e6019
SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2912
diff
changeset
|
126 |
|
b07ad97e6019
SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2912
diff
changeset
|
127 |
|| |
b07ad97e6019
SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2912
diff
changeset
|
128 |