10 frequency = 2; |
10 frequency = 2; |
11 |
11 |
12 update_activity() { |
12 update_activity() { |
13 if(this.active) { |
13 if(this.active) { |
14 /* show active */ |
14 /* show active */ |
15 this.active_elt.setAttribute("style", this.active_elt_style); |
15 this.active_elt.style.display = ""; |
16 /* hide inactive */ |
16 /* hide inactive */ |
17 this.inactive_elt.setAttribute("style", "display:none"); |
17 this.inactive_elt.style.display = "none"; |
18 } else { |
18 } else { |
19 /* show inactive */ |
19 /* show inactive */ |
20 this.inactive_elt.setAttribute("style", this.inactive_elt_style); |
20 this.inactive_elt.style.display = ""; |
21 /* hide active */ |
21 /* hide active */ |
22 this.active_elt.setAttribute("style", "display:none"); |
22 this.active_elt.style.display = "none"; |
|
23 } |
|
24 } |
|
25 |
|
26 update_disability() { |
|
27 if(this.disabled) { |
|
28 /* show disabled */ |
|
29 this.disabled_elt.style.display = ""; |
|
30 /* hide inactive */ |
|
31 this.inactive_elt.style.display = "none"; |
|
32 /* hide active */ |
|
33 this.active_elt.style.display = "none"; |
|
34 } else { |
|
35 /* hide disabled */ |
|
36 this.disabled_elt.style.display = "none"; |
|
37 this.update_activity(); |
23 } |
38 } |
24 } |
39 } |
25 |
40 |
26 make_on_click() { |
41 make_on_click() { |
27 let that = this; |
42 let that = this; |
28 const name = this.args[0]; |
43 const name = this.args[0]; |
29 return function(evt){ |
44 return function(evt){ |
30 /* TODO: suport path pointing to local variable whom value |
45 /* TODO: in order to allow jumps to page selected through for exemple a dropdown, |
31 would be an HMI_TREE index to jump to a relative page */ |
46 support path pointing to local variable whom value |
32 const index = that.indexes.length > 0 ? that.indexes[0] + that.offset : undefined; |
47 would be an HMI_TREE index and then jump to a relative page not hard-coded in advance */ |
33 switch_page(name, index); |
48 |
|
49 if(!that.disabled) { |
|
50 const index = that.indexes.length > 0 ? that.indexes[0] + that.offset : undefined; |
|
51 switch_page(name, index); |
|
52 } |
34 } |
53 } |
35 } |
54 } |
36 |
55 |
37 notify_page_change(page_name, index) { |
56 notify_page_change(page_name, index) { |
38 if(this.activable) { |
57 if(this.activable) { |
39 const ref_index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined; |
58 const ref_index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined; |
40 const ref_name = this.args[0]; |
59 const ref_name = this.args[0]; |
41 this.active = ((ref_name == undefined || ref_name == page_name) && index == ref_index); |
60 this.active = ((ref_name == undefined || ref_name == page_name) && index == ref_index); |
42 this.update_activity(); |
61 this.update_state(); |
43 } |
62 } |
44 } |
63 } |
45 |
64 |
46 dispatch(value) { |
65 dispatch(value) { |
47 this.disabled = !Number(value); |
66 this.disabled = !Number(value); |
48 if(this.disabled) { |
67 this.update_state(); |
49 /* show disabled */ |
|
50 this.disabled_elt.setAttribute("style", this.disabled_elt_style); |
|
51 /* hide inactive */ |
|
52 this.inactive_elt.setAttribute("style", "display:none"); |
|
53 /* hide active */ |
|
54 this.active_elt.setAttribute("style", "display:none"); |
|
55 } else { |
|
56 /* hide disabled */ |
|
57 this.disabled_elt.setAttribute("style", "display:none"); |
|
58 this.update_activity(); |
|
59 } |
|
60 } |
68 } |
61 } |
69 } |
62 || |
70 || |
63 } |
71 } |
64 |
72 |
73 value "$disability"; |
81 value "$disability"; |
74 |
82 |
75 | init: function() { |
83 | init: function() { |
76 | this.element.onclick = this.make_on_click(); |
84 | this.element.onclick = this.make_on_click(); |
77 if "$have_activity" { |
85 if "$have_activity" { |
78 | this.active_elt_style = this.active_elt.getAttribute("style"); |
|
79 | this.inactive_elt_style = this.inactive_elt.getAttribute("style"); |
|
80 | this.activable = true; |
86 | this.activable = true; |
81 } |
87 } |
|
88 if "not($have_disability)" { |
|
89 | this.unsubscribable = true; |
|
90 } |
|
91 > this.update_state = |
82 choose { |
92 choose { |
83 when "$have_disability" { |
93 when "$have_disability" { |
84 | this.disabled_elt_style = this.disabled_elt.getAttribute("style"); |
94 > this.update_disability |
85 } |
95 } |
86 otherwise { |
96 when "$have_activity" { |
87 | this.unsubscribable = true; |
97 > this.update_activity |
88 } |
98 } |
|
99 otherwise > null |
89 } |
100 } |
|
101 > ;\n |
90 | }, |
102 | }, |
|
103 |
91 } |
104 } |
92 |
105 |
93 template "widget[@type='Jump']", mode="per_page_widget_template"{ |
106 template "widget[@type='Jump']", mode="per_page_widget_template"{ |
94 param "page_desc"; |
107 param "page_desc"; |
95 /* check that given path is compatible with page's reference path */ |
108 /* check that given path is compatible with page's reference path */ |