author | Edouard Tisserant |
Thu, 26 Mar 2020 14:21:52 +0100 | |
branch | svghmi |
changeset 2902 | 1fcb50af0335 |
parent 2901 | 3f5194bba67d |
child 2903 | 881d0248b3ce |
permissions | -rw-r--r-- |
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 |
|
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
|
6 |
| 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
|
7 |
| const index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined; |
2902 | 8 |
| const name = this.args[0]; |
9 |
| 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
|
10 |
| }, |
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
|
11 |
| 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
|
12 |
/* 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
|
13 |
| 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
|
14 |
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
|
15 |
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
|
16 |
*/ |
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
|
17 |
| 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
|
18 |
| }, |
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
|
19 |
} |
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
|
20 |
|
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
|
21 |
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
|
22 |
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
|
23 |
/* 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
|
24 |
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
|
25 |
/* 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
|
26 |
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
|
27 |
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
|
28 |
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
|
29 |
} |
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
|
30 |
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
|
31 |
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
|
32 |
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
|
33 |
} |
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
|
34 |
|
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
|
35 |
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
|
36 |
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
|
37 |
} |
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
|
38 |
} |