edouard@2883: // widget_jump.ysl2 Edouard@2779: edouard@2883: template "widget[@type='Jump']", mode="widget_defs" { edouard@2883: param "hmi_element"; 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@2901: /* registering event this way does 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: } Edouard@2901: Edouard@2901: template "widget[@type='Jump']", mode="per_page_widget_template"{ Edouard@2901: param "page_desc"; Edouard@2901: /* check that given path is compatible with page's reference path */ Edouard@2901: if "path" { Edouard@2901: /* when no page name provided, check for same page */ Edouard@2901: const "target_page_name" choose { Edouard@2901: when "arg" value "arg[1]/@value"; Edouard@2901: otherwise value "$page_desc/arg[1]/@value"; Edouard@2901: } Edouard@2901: const "target_page_path" choose { Edouard@2901: when "arg" value "$hmi_pages_descs[arg[1]/@value = $target_page_name]/path[1]/@value"; Edouard@2901: otherwise value "$page_desc/path[1]/@value"; Edouard@2901: } Edouard@2901: Edouard@2901: if "not(func:same_class_paths($target_page_path, path[1]/@value))" Edouard@2901: error > Jump id="«@id»" to page "«$target_page_name»" with incompatible path "«path[1]/@value» (must be same class as "«$target_page_path»") Edouard@2901: } Edouard@2901: }