23 | ["«substring-after(@inkscape:label, concat(arg[1]/@value, ':'))»", id("«@id»")]`if "position()!=last()" > ,` |
23 | ["«substring-after(@inkscape:label, concat(arg[1]/@value, ':'))»", id("«@id»")]`if "position()!=last()" > ,` |
24 } |
24 } |
25 | ], |
25 | ], |
26 | init: function() { |
26 | init: function() { |
27 | /* TODO elt.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click(evt)");*/ |
27 | /* TODO elt.setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click(evt)");*/ |
28 | }, |
|
29 |
28 |
30 | items: [ |
29 | this.items = [ |
31 const "items_regex","concat('^',$prefix,'[0-9]+')"; |
30 const "items_regex","concat('^',$prefix,'[0-9]+')"; |
32 const "unordered_items","$hmi_element//*[regexp:test(@inkscape:label, $items_regex)]"; |
31 const "unordered_items","$hmi_element//*[regexp:test(@inkscape:label, $items_regex)]"; |
33 foreach "$unordered_items" { |
32 foreach "$unordered_items" { |
34 const "elt_label","concat($prefix, string(position()))"; |
33 const "elt_label","concat($prefix, string(position()))"; |
35 const "elt","$unordered_items[@inkscape:label = $elt_label]"; |
34 const "elt","$unordered_items[@inkscape:label = $elt_label]"; |
36 const "pos","position()"; |
35 const "pos","position()"; |
37 const "item_path", "$items_paths[$pos]"; |
36 const "item_path", "$items_paths[$pos]"; |
38 | [ /* item="«$elt_label»" path="«$item_path»" */ |
37 | [ /* item="«$elt_label»" path="«$item_path»" */ |
39 if "count($elt)=0" error > Missing item labeled «$elt_label» in ForEach widget «$hmi_element/@id» |
38 if "count($elt)=0" error > Missing item labeled «$elt_label» in ForEach widget «$hmi_element/@id» |
40 foreach "func:refered_elements($elt)[@id = $hmi_elements/@id][not(@id = $elt/@id)]" { |
39 foreach "func:refered_elements($elt)[@id = $hmi_elements/@id][not(@id = $elt/@id)]" { |
41 if "not(func:is_descendant_path(func:widget(@id)/path/@value, $item_path))" |
40 if "not(func:is_descendant_path(func:widget(@id)/path/@value, $item_path))" |
42 error > Widget id="«@id»" label="«@inkscape:label»" is having wrong path. Accroding to ForEach widget ancestor id="«$hmi_element/@id»", path should be descendant of «$item_path». |
41 error > Widget id="«@id»" label="«@inkscape:label»" is having wrong path. Accroding to ForEach widget ancestor id="«$hmi_element/@id»", path should be descendant of «$item_path». |
43 | hmi_widgets["«@id»"]`if "position()!=last()" > ,` |
42 | hmi_widgets["«@id»"]`if "position()!=last()" > ,` |
44 } |
43 } |
45 | ]`if "position()!=last()" > ,` |
44 | ]`if "position()!=last()" > ,` |
46 } |
45 } |
47 | ], |
46 | ] |
|
47 | }, |
|
48 | item_offset: 0, |
48 } |
49 } |
49 |
50 |
50 template "widget[@type='ForEach']", mode="widget_subscribe"{ |
51 template "widget[@type='ForEach']", mode="widget_subscribe"{ |
51 // param "hmi_element"; |
52 // param "hmi_element"; |
52 | sub: function(off){ |
53 | sub: function(off){ |
53 | /*subscribe.call(this,off);*/ |
54 | subscribe_foreach.call(this,off); |
54 /* TODO */ |
|
55 | }, |
55 | }, |
56 |
56 |
57 | unsub: function(){ |
57 | unsub: function(){ |
58 | /*unsubscribe.call(this);*/ |
58 | unsubscribe_foreach.call(this); |
59 /* TODO */ |
|
60 | }, |
59 | }, |
61 } |
60 } |