diff --git a/doc/ui-control.md b/doc/ui-control.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/doc/ui-control.md
diff --git a/ui/wolf.lib.html b/ui/wolf.lib.html
index 5dc2a1b..5e21e9b 100644
--- a/ui/wolf.lib.html
+++ b/ui/wolf.lib.html
@@ -10,6 +10,23 @@
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/ui/wolf.ui.js b/ui/wolf.ui.js
index 2485607..bb87092 100644
--- a/ui/wolf.ui.js
+++ b/ui/wolf.ui.js
@@ -263,8 +263,7 @@
for (var k in template) {
if (k[0] == "$")
continue;
- var attr = template[k];
- values[k] = attr;
+ values[k] = template[k];
}
return values;
}
@@ -371,11 +370,18 @@
}
});
+ if (scriptFactory) {//TODO: use this single instance of script
+ var script = new scriptFactory(null, K, D, UI, TOOLS);
+ if (script.define)
+ controller = script.define(controller);
+ }
+
// Controller logics (new definition rendering) =============
controller.$init = function (template) {
if (template.$ && template.$.length && !allowChildren)
throw new Error("wolf:" + id + " does not allow child nodes");
};
+
controller.$ctor = function (template, ext) {
var parentCustom = ext.customController;
ext = {}.merge(ext); //Copy of ext instance
@@ -384,7 +390,7 @@
var API = {
ui: (name, clone) => {
var result = name ? ui[name] : ui[""];
- return clone ? UI.cloneTemplate(result) : result;
+ return clone !== false ? UI.cloneTemplate(result) : result;
},
value: name => {
var data = values[name];
@@ -401,6 +407,7 @@
childs: name => ext.getChildNodes(name),
global: controlGlobal,
parent: ext.parent,
+ values: values,
}
var script = scriptFactory ? new scriptFactory(API, K, D, UI, TOOLS) : {};
API.controller = script;
@@ -409,9 +416,11 @@
script.render = () => {
for (var k in ui)//return first if any
return ui[k];
- return [];
+ throw new Error("wolf:" + id + " does not have ui defined");
}
+ script.init && script.init();
+
// Event mirror and attribute hook
for (var k in values)
if (k.startsWith("event:")) {
@@ -425,7 +434,7 @@
ext.getChildNodes = function (id) {
//ID for usage on future with multiple chilnodes block definitions
- return template.c;
+ return template.$;
}
ext.customController = script;
ext.parentCustom = parentCustom;
@@ -443,8 +452,10 @@
else
element.nodeValue = data;
}
- for (var k in template.a) {
- var attr = template.a[k];
+ for (var k in template) {
+ if (k[0] == "$")
+ continue;
+ var attr = template[k];
if (attr && attr[0] == "$") {
var data = values[attr.substr(1)];
if (data instanceof D.Binding)
diff --git a/wolf.js b/wolf.js
index 1e19679..2a78edf 100644
--- a/wolf.js
+++ b/wolf.js
@@ -1692,22 +1692,12 @@
result[i] = cloneTemplate(templ[i]);
return result;
}
- var clone = {};
- if (templ.type)
- clone.type = templ.type;
- if (templ.value)
- clone.value = templ.value;
- clone.a = {};
- if (templ.a)
- for (var k in templ.a)
- clone.a[k] = templ.a[k];
- clone.w = {};
- if (templ.w)
- for (var k in templ.w)
- clone.w[k] = templ.w[k];
- clone.c = [];
- if (templ.c)
- clone.c = cloneTemplate(templ.c);
+ var clone = {}.merge(templ);
+
+ // Does not clone events??
+ delete clone.$e;
+ if (templ.$ && Array.isArray(templ.$))
+ clone.$ = cloneTemplate(templ.$);
return clone;
}