svghmi/widget_jump.ysl2
author Edouard Tisserant
Thu, 26 Mar 2020 11:17:34 +0100
branchsvghmi
changeset 2900 3ef217f525ff
parent 2898 a2910281fcb5
child 2901 3f5194bba67d
permissions -rw-r--r--
SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
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
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
     3
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
     4
    param "hmi_element";
2900
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2898
diff changeset
     5
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2898
diff changeset
     6
    /* check that given path is compatible with page's reference path */
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2898
diff changeset
     7
    if "count(arg) > 0 and count(path) > 0" {
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2898
diff changeset
     8
        const "target_page_name", "arg[1]/@value";
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2898
diff changeset
     9
        const "target_page_desc", "$hmi_pages_descs[arg[1]/@value = $target_page_name]";
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2898
diff changeset
    10
        const "target_page_path", "$target_page_desc/path[1]/@value";
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2898
diff changeset
    11
        if "not(func:same_class_paths($target_page_path, path[1]/@value))"
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2898
diff changeset
    12
            warning > Jump id="«@id»" to page "«$target_page_name»" with incompatible path "«path[1]/@value»"
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2898
diff changeset
    13
    }
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2898
diff changeset
    14
    /* TODO check that path is also matching in case of implicit local jump (no page name given) */
3ef217f525ff SVGHMI: Check that explicit relative page jump path is consistant with destination page reference path.
Edouard Tisserant
parents: 2898
diff changeset
    15
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
    16
    |     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
    17
    |         const index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined;
a2910281fcb5 SVGHMI: Alow relative relative Jump. (i.e, relative jump from a foreach widget)
Edouard Tisserant
parents: 2883
diff changeset
    18
    |         switch_page(this.args[0], 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
    19
    |     },
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
    20
    |     init: function() {
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
    21
    /* registering event this way doies not "click" through svg:use 
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
    22
    |     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
    23
    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
    24
    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
    25
    */
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
    26
    |         this.element.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click(evt)");
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
    27
    |     },
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
    28
}