8 state = 0; |
8 state = 0; |
9 active_style = undefined; |
9 active_style = undefined; |
10 inactive_style = undefined; |
10 inactive_style = undefined; |
11 |
11 |
12 dispatch(value) { |
12 dispatch(value) { |
13 this.state = value; |
13 if(this.state != value){ |
14 if (this.state) { |
14 this.state = value; |
15 this.active_elt.setAttribute("style", this.active_style); |
15 if (this.state) { |
16 this.inactive_elt.setAttribute("style", "display:none"); |
16 this.active_elt.setAttribute("style", this.active_style); |
17 this.state = 0; |
17 this.inactive_elt.setAttribute("style", "display:none"); |
18 } else { |
18 } else { |
19 this.inactive_elt.setAttribute("style", this.inactive_style); |
19 this.inactive_elt.setAttribute("style", this.inactive_style); |
20 this.active_elt.setAttribute("style", "display:none"); |
20 this.active_elt.setAttribute("style", "display:none"); |
21 this.state = 1; |
21 } |
22 } |
22 } |
23 } |
23 } |
24 |
24 |
25 on_click(evt) { |
25 on_click(evt) { |
|
26 if (this.state) { |
|
27 this.inactive_elt.setAttribute("style", this.inactive_style); |
|
28 this.active_elt.setAttribute("style", "display:none"); |
|
29 this.state = 0; |
|
30 } else { |
|
31 this.active_elt.setAttribute("style", this.active_style); |
|
32 this.inactive_elt.setAttribute("style", "display:none"); |
|
33 this.state = 1; |
|
34 } |
26 this.apply_hmi_value(0, this.state); |
35 this.apply_hmi_value(0, this.state); |
27 } |
36 } |
28 |
37 |
29 init() { |
38 init() { |
30 this.active_style = this.active_elt.style.cssText; |
39 this.active_style = this.active_elt.style.cssText; |
31 this.inactive_style = this.inactive_elt.style.cssText; |
40 this.inactive_style = this.inactive_elt.style.cssText; |
32 this.element.setAttribute("onclick", "hmi_widgets['"+this.element_id+"'].on_click(evt)"); |
41 this.element.setAttribute("onclick", "hmi_widgets['"+this.element_id+"'].on_click(evt)"); |
|
42 this.inactive_elt.setAttribute("style", this.inactive_style); |
|
43 this.active_elt.setAttribute("style", "display:none"); |
33 } |
44 } |
34 } |
45 } |
35 || |
46 || |
36 } |
47 } |
37 |
48 |