50 |
50 |
51 widget_class("Jump") { |
51 widget_class("Jump") { |
52 || |
52 || |
53 activable = false; |
53 activable = false; |
54 frequency = 2; |
54 frequency = 2; |
|
55 target_page_is_current_page = false; |
|
56 button_beeing_pressed = false; |
55 |
57 |
56 make_on_click() { |
58 onmouseup(evt) { |
57 let that = this; |
59 svg_root.removeEventListener("pointerup", this.bound_onmouseup, true); |
58 const name = this.args[0]; |
60 if(this.enable_state) { |
59 return function(evt){ |
61 const index = |
60 /* TODO: in order to allow jumps to page selected through |
62 (this.is_relative && this.indexes.length > 0) ? |
61 for exemple a dropdown, support path pointing to local |
63 this.indexes[0] + this.offset : undefined; |
62 variable whom value would be an HMI_TREE index and then |
64 this.button_beeing_pressed = false; |
63 jump to a relative page not hard-coded in advance |
65 this.activity_state = this.target_page_is_current_page || this.button_beeing_pressed; |
64 */ |
66 fading_page_switch(this.args[0], index); |
65 if(that.enable_state) { |
67 this.notify(); |
66 const index = |
68 } |
67 (that.is_relative && that.indexes.length > 0) ? |
69 } |
68 that.indexes[0] + that.offset : undefined; |
70 |
69 fading_page_switch(name, index); |
71 onmousedown(){ |
70 that.notify(); |
72 if(this.enable_state) { |
71 } |
73 svg_root.addEventListener("pointerup", this.bound_onmouseup, true); |
|
74 this.button_beeing_pressed = true; |
|
75 this.activity_state = true; |
|
76 this.request_animate(); |
72 } |
77 } |
73 } |
78 } |
74 |
79 |
75 notify_page_change(page_name, index) { |
80 notify_page_change(page_name, index) { |
76 // called from animate() |
81 // called from animate() |
77 if(this.activable) { |
82 if(this.activable) { |
78 const ref_index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined; |
83 const ref_index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined; |
79 const ref_name = this.args[0]; |
84 const ref_name = this.args[0]; |
80 this.activity_state = ((ref_name == undefined || ref_name == page_name) && index == ref_index); |
85 this.target_page_is_current_page = ((ref_name == undefined || ref_name == page_name) && index == ref_index); |
|
86 this.activity_state = this.target_page_is_current_page || this.button_beeing_pressed; |
81 // Since called from animate, update activity directly |
87 // Since called from animate, update activity directly |
82 if(this.enable_displayed_state && this.has_activity) { |
88 if(this.enable_displayed_state && this.has_activity) { |
83 this.animate_activity(); |
89 this.animate_activity(); |
84 } |
90 } |
85 } |
91 } |