svghmi/widget_jump.ysl2
branchsvghmi
changeset 3081 9e55061c87fa
parent 2980 2a21d6060d64
child 3107 ee0704cc6dc8
equal deleted inserted replaced
3080:e5fa1f49f0b9 3081:9e55061c87fa
    55     if "$have_disability" {
    55     if "$have_disability" {
    56     |       }
    56     |       }
    57     }
    57     }
    58     |     },
    58     |     },
    59     }
    59     }
    60     |     on_click: function(evt) {
       
    61     |         const index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined;
       
    62     |         const name = this.args[0];
       
    63     |         switch_page(name, index);
       
    64     |     },
       
    65     if "$have_activity" {
    60     if "$have_activity" {
    66     |     notify_page_change: function(page_name, index){
    61     |     notify_page_change: function(page_name, index){
    67     |         const ref_index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined;
    62     |         const ref_index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined;
    68     |         const ref_name = this.args[0];
    63     |         const ref_name = this.args[0];
    69     |         this.active =((ref_name == undefined || ref_name == page_name) && index == ref_index);
    64     |         this.active =((ref_name == undefined || ref_name == page_name) && index == ref_index);
    70     |         this.update();
    65     |         this.update();
    71     |     },
    66     |     },
    72     }
    67     }
       
    68     |     make_on_click(){
       
    69     |         let that = this;
       
    70     |         const name = this.args[0];
       
    71     |         return function(evt){
       
    72     |             const index = that.indexes.length > 0 ? that.indexes[0] + that.offset : undefined;
       
    73     |             switch_page(name, index);
       
    74     |         }
       
    75     |     },
    73     |     init: function() {
    76     |     init: function() {
    74     /* registering event this way does not "click" through svg:use 
    77     /* registering event this way does not "click" through svg:use 
    75     |     this.element.onclick = evt => switch_page(this.args[0]);
    78     |     this.element.onclick = evt => switch_page(this.args[0]);
    76     event must be registered by adding attribute to element instead
    79     event must be registered by adding attribute to element instead
    77     TODO : generalize mouse event handling by global event capture + getElementsAtPoint()
    80     TODO : generalize mouse event handling by global event capture + getElementsAtPoint()
    78     */
    81     */
    79     |         this.element.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click(evt)");
    82     |         this.element.onclick = this.make_on_click();
    80     if "$have_activity" {
    83     if "$have_activity" {
    81     |         this.active_elt_style = this.active_elt.getAttribute("style");
    84     |         this.active_elt_style = this.active_elt.getAttribute("style");
    82     |         this.inactive_elt_style = this.inactive_elt.getAttribute("style");
    85     |         this.inactive_elt_style = this.inactive_elt.getAttribute("style");
    83     }
    86     }
    84     choose {
    87     choose {