svghmi/widget_jump.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Sun, 19 Apr 2020 22:44:41 +0200
branchsvghmi
changeset 2942 b07ad97e6019
parent 2912 d320367eb2ad
child 2943 304e88bae115
permissions -rw-r--r--
SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
2883
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
     1
// widget_jump.ysl2
2779
75c6a31caca6 SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents: 2763
diff changeset
     2
2903
881d0248b3ce SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents: 2902
diff changeset
     3
function "jump_widget_activity" {
881d0248b3ce SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents: 2902
diff changeset
     4
    param "hmi_element";
881d0248b3ce SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents: 2902
diff changeset
     5
        optional_labels("active inactive");
881d0248b3ce SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents: 2902
diff changeset
     6
}
881d0248b3ce SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents: 2902
diff changeset
     7
2906
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
     8
function "jump_widget_disability" {
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
     9
    param "hmi_element";
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    10
        optional_labels("disabled");
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    11
}
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    12
2883
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
    13
template "widget[@type='Jump']", mode="widget_defs" {
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
    14
    param "hmi_element";
2906
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    15
    const "activity" call "jump_widget_activity" with "hmi_element", "$hmi_element";
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    16
    const "have_activity","string-length($activity)>0";
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    17
    value "$activity";
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    18
    const "disability" call "jump_widget_disability" with "hmi_element", "$hmi_element";
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    19
    const "have_disability","$have_activity and string-length($disability)>0";
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    20
    value "$disability";
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    21
    if "$have_activity" {
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    22
    |     active: false,
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    23
    if "$have_disability" {
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    24
    |     disabled: false,
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    25
    |     frequency: 2,
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    26
    |     dispatch: function(value) {
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    27
    |         this.disabled = !Number(value);
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    28
    |         this.update();
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    29
    |     },
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    30
    }
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    31
    |     update: function(){
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    32
    if "$have_disability" {
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    33
    |       if(this.disabled) {
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    34
    |         /* show disabled */ 
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    35
    |         this.disabled_elt.setAttribute("style", this.active_elt_style);
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    36
    |         /* hide inactive */ 
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    37
    |         this.inactive_elt.setAttribute("style", "display:none");
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    38
    |         /* hide active */ 
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    39
    |         this.active_elt.setAttribute("style", "display:none");
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    40
    |       } else {
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    41
    |         /* hide disabled */ 
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    42
    |         this.disabled_elt.setAttribute("style", "display:none");
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    43
    }
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    44
    |         if(this.active) {
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    45
    |              /* show active */ 
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    46
    |              this.active_elt.setAttribute("style", this.active_elt_style);
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    47
    |              /* hide inactive */ 
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    48
    |              this.inactive_elt.setAttribute("style", "display:none");
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    49
    |         } else {
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    50
    |              /* show inactive */ 
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    51
    |              this.inactive_elt.setAttribute("style", this.inactive_elt_style);
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    52
    |              /* hide active */ 
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    53
    |              this.active_elt.setAttribute("style", "display:none");
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    54
    |         }
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    55
    if "$have_disability" {
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    56
    |       }
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    57
    }
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    58
    |     },
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    59
    }
2883
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
    60
    |     on_click: function(evt) {
2898
a2910281fcb5 SVGHMI: Alow relative relative Jump. (i.e, relative jump from a foreach widget)
Edouard Tisserant
parents: 2883
diff changeset
    61
    |         const index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined;
2902
1fcb50af0335 SVGHMI: added Back widget.
Edouard Tisserant
parents: 2901
diff changeset
    62
    |         const name = this.args[0];
1fcb50af0335 SVGHMI: added Back widget.
Edouard Tisserant
parents: 2901
diff changeset
    63
    |         switch_page(name, index);
2883
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
    64
    |     },
2906
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    65
    if "$have_activity" {
2903
881d0248b3ce SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents: 2902
diff changeset
    66
    |     notify_page_change: function(page_name, index){
881d0248b3ce SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents: 2902
diff changeset
    67
    |         const ref_index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined;
881d0248b3ce SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents: 2902
diff changeset
    68
    |         const ref_name = this.args[0];
2906
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    69
    |         this.active =((ref_name == undefined || ref_name == page_name) && index == ref_index);
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    70
    |         this.update();
2903
881d0248b3ce SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents: 2902
diff changeset
    71
    |     },
881d0248b3ce SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents: 2902
diff changeset
    72
    }
2883
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
    73
    |     init: function() {
2901
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
    74
    /* registering event this way does not "click" through svg:use 
2883
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
    75
    |     this.element.onclick = evt => switch_page(this.args[0]);
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
    76
    event must be registered by adding attribute to element instead
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
    77
    TODO : generalize mouse event handling by global event capture + getElementsAtPoint()
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
    78
    */
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
    79
    |         this.element.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click(evt)");
2906
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    80
    if "$have_activity" {
2903
881d0248b3ce SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents: 2902
diff changeset
    81
    |         this.active_elt_style = this.active_elt.getAttribute("style");
881d0248b3ce SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents: 2902
diff changeset
    82
    |         this.inactive_elt_style = this.inactive_elt.getAttribute("style");
881d0248b3ce SVGHMI: Jump widget can now display as active or inactive, if corresponfing "active" and "inactive labeled elements are provided.
Edouard Tisserant
parents: 2902
diff changeset
    83
    }
2906
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    84
    if "$have_disability" {
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    85
    |         this.disabled_elt_style = this.disabled_elt.getAttribute("style");
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    86
    }
2883
8e3d130399b0 SVGHMI: created widget_*.ysl2. Renamed widget_common in widgets_common, so that it doesn't match globing.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2882
diff changeset
    87
    |     },
2753
9a7e12e96399 SVGHMI: Added XSLT transformation, Makefile to get XSLT from ysl2 (copy of plcopen/Makefile) and a minimal stylesheet to start with.
Edouard Tisserant
parents:
diff changeset
    88
}
2901
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
    89
2906
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    90
// default : normal subscribing
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    91
template "widget[@type='Jump']", mode="widget_subscribe" {
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    92
    param "hmi_element";
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    93
    const "activity" call "jump_widget_activity" with "hmi_element", "$hmi_element";
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    94
    const "have_activity","string-length($activity)>0";
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    95
    const "disability" call "jump_widget_disability" with "hmi_element", "$hmi_element";
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    96
    const "have_disability","$have_activity and string-length($disability)>0";
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    97
    choose {
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    98
        when "$have_disability" {
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
    99
    |     sub: subscribe,
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
   100
    |     unsub: unsubscribe,
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
   101
    |     apply_cache: widget_apply_cache,
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
   102
        }
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
   103
        otherwise {
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
   104
    |     sub: function(){},
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
   105
    |     unsub: function(){},
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
   106
    |     apply_cache: function(){},
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
   107
        }
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
   108
    }
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
   109
}
3b4a1319da09 SVGHMI: Jump widget, if it has a 'disabled' labeled element, reflects value of the pointed HMITree variable by showing this element when value is False, and behaving normaly otherwise.
Edouard Tisserant
parents: 2903
diff changeset
   110
2901
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   111
template "widget[@type='Jump']", mode="per_page_widget_template"{
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   112
    param "page_desc";
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   113
    /* check that given path is compatible with page's reference path */
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   114
    if "path" {
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   115
        /* when no page name provided, check for same page */
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   116
        const "target_page_name" choose {
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   117
            when "arg" value "arg[1]/@value";
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   118
            otherwise value "$page_desc/arg[1]/@value";
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   119
        }
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   120
        const "target_page_path" choose {
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   121
            when "arg" value "$hmi_pages_descs[arg[1]/@value = $target_page_name]/path[1]/@value";
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   122
            otherwise value "$page_desc/path[1]/@value";
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   123
        }
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   124
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   125
        if "not(func:same_class_paths($target_page_path, path[1]/@value))"
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   126
            error > Jump id="«@id»" to page "«$target_page_name»" with incompatible path "«path[1]/@value» (must be same class as "«$target_page_path»")
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   127
    }
3f5194bba67d SVGHMI: Jump widget now make errors if path given for relative jump doesn't match target page reference path class.
Edouard Tisserant
parents: 2900
diff changeset
   128
}
2942
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
   129
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
   130
emit "epilogue:jump"
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
   131
||
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
   132
var jumps_need_update = false;
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
   133
var jump_history = [[default_page, undefined]];
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
   134
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
   135
function update_jumps() {
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
   136
    page_desc[current_visible_page].jumps.map(w=>w.notify_page_change(current_visible_page,current_page_index));
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
   137
    jumps_need_update = false;
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
   138
};
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
   139
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
   140
||
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
   141