edouard@2883: // widget_jump.ysl2 Edouard@2779: edouard@2883: template "widget[@type='Jump']", mode="widget_defs" { edouard@2883: param "hmi_element"; Edouard@2900: Edouard@2900: /* check that given path is compatible with page's reference path */ Edouard@2900: if "count(arg) > 0 and count(path) > 0" { Edouard@2900: const "target_page_name", "arg[1]/@value"; Edouard@2900: const "target_page_desc", "$hmi_pages_descs[arg[1]/@value = $target_page_name]"; Edouard@2900: const "target_page_path", "$target_page_desc/path[1]/@value"; Edouard@2900: if "not(func:same_class_paths($target_page_path, path[1]/@value))" Edouard@2900: warning > Jump id="«@id»" to page "«$target_page_name»" with incompatible path "«path[1]/@value»" Edouard@2900: } Edouard@2900: /* TODO check that path is also matching in case of implicit local jump (no page name given) */ Edouard@2900: edouard@2883: | on_click: function(evt) { Edouard@2898: | const index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined; Edouard@2898: | switch_page(this.args[0], index); edouard@2883: | }, edouard@2883: | init: function() { edouard@2883: /* registering event this way doies not "click" through svg:use edouard@2883: | this.element.onclick = evt => switch_page(this.args[0]); edouard@2883: event must be registered by adding attribute to element instead edouard@2883: TODO : generalize mouse event handling by global event capture + getElementsAtPoint() edouard@2883: */ edouard@2883: | this.element.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click(evt)"); edouard@2883: | }, Edouard@2753: }