svghmi/widget_jump.ysl2
changeset 3626 dfcd13683362
parent 3597 f69c68cffec3
child 3685 570a738239f4
equal deleted inserted replaced
3625:bb1eff4091ab 3626:dfcd13683362
    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             }
    96     optional_activable();
   102     optional_activable();
    97 
   103 
    98     const "jump_disability","$has_activity and $has_disability";
   104     const "jump_disability","$has_activity and $has_disability";
    99 
   105 
   100     |     init: function() {
   106     |     init: function() {
   101     |         this.element.onclick = this.make_on_click();
   107     |         this.bound_onmouseup = this.onmouseup.bind(this);
       
   108     |         this.element.addEventListener("pointerdown", this.onmousedown.bind(this));
   102     if "$has_activity" {
   109     if "$has_activity" {
   103     |         this.activable = true;
   110     |         this.activable = true;
   104     }
   111     }
   105 
   112 
   106     >         this.is_relative = 
   113     >         this.is_relative =