author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Wed, 05 Aug 2020 18:49:29 +0200 | |
branch | svghmi |
changeset 3005 | ff9ae4f4e3be |
parent 3004 | 705e34c6fe93 |
child 3011 | 601c6dbc1da7 |
permissions | -rw-r--r-- |
2977 | 1 |
// widget_tooglebutton.ysl2 |
2 |
||
3 |
template "widget[@type='ToggleButton']", mode="widget_defs" { |
|
4 |
param "hmi_element"; |
|
5 |
labels("active inactive"); |
|
6 |
| frequency: 5, |
|
7 |
| state: 0, |
|
8 |
| dispatch: function(value) { |
|
9 |
| this.state = value; |
|
10 |
| if (this.state) { |
|
11 |
| this.active_elt.setAttribute("style", this.active_style); |
|
12 |
| this.inactive_elt.setAttribute("style", "display:none"); |
|
13 |
| this.state = 0; |
|
14 |
| } else { |
|
15 |
| this.inactive_elt.setAttribute("style", this.inactive_style); |
|
16 |
| this.active_elt.setAttribute("style", "display:none"); |
|
17 |
| this.state = 1; |
|
18 |
| } |
|
19 |
| }, |
|
20 |
| on_click: function(evt) { |
|
3004
705e34c6fe93
SVGHMI: More JS code refactoring : change_hmi_value and apply_hmi_value now methods of widget class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2977
diff
changeset
|
21 |
| this.apply_hmi_value(0, this.state); |
2977 | 22 |
| }, |
23 |
| active_style: undefined, |
|
24 |
| inactive_style: undefined, |
|
25 |
| init: function() { |
|
26 |
| this.active_style = this.active_elt.style.cssText; |
|
27 |
| this.inactive_style = this.inactive_elt.style.cssText; |
|
28 |
| this.element.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click(evt)"); |
|
29 |
| }, |
|
3004
705e34c6fe93
SVGHMI: More JS code refactoring : change_hmi_value and apply_hmi_value now methods of widget class.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2977
diff
changeset
|
30 |
} |