|
@@ -16,7 +16,13 @@ DEALINGS IN THE SOFTWARE.
|
|
function nbInit(a,b){
|
|
function nbInit(a,b){
|
|
var root=document, $s=a;
|
|
var root=document, $s=a;
|
|
|
|
|
|
|
|
+ var dom = null;
|
|
|
|
+
|
|
function searchElement(root, selector){
|
|
function searchElement(root, selector){
|
|
|
|
+ if (selector.indexOf('|dom') === selector.length - 4){
|
|
|
|
+ selector = selector.slice(0,selector.length - 4)
|
|
|
|
+ dom = true;
|
|
|
|
+ }
|
|
if (root === document){
|
|
if (root === document){
|
|
var items = [root.getElementById(selector)];
|
|
var items = [root.getElementById(selector)];
|
|
}
|
|
}
|
|
@@ -56,10 +62,10 @@ function nbInit(a,b){
|
|
var items = searchElement(root, selector);
|
|
var items = searchElement(root, selector);
|
|
for (var i=0,item=items[i];i<items.length;i++,item=items[i]){
|
|
for (var i=0,item=items[i];i<items.length;i++,item=items[i]){
|
|
if (direction == "write" && Array.isArray($s[selector]) && (item.children.length == 0 || (items.length == $s[selector].length && items.length > 1))){
|
|
if (direction == "write" && Array.isArray($s[selector]) && (item.children.length == 0 || (items.length == $s[selector].length && items.length > 1))){
|
|
- callback(item, $s, selector, $s[selector][i], undefined, true);
|
|
|
|
|
|
+ callback(item, $s, selector, $s[selector][i]);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- var res = callback(item, $s, selector, undefined, undefined, true);
|
|
|
|
|
|
+ var res = callback(item, $s, selector);
|
|
if (typeof res !== "undefined"){
|
|
if (typeof res !== "undefined"){
|
|
result.push(res)
|
|
result.push(res)
|
|
}
|
|
}
|
|
@@ -91,12 +97,12 @@ function nbInit(a,b){
|
|
nBind(function (item, $s, selector, value, key, thisByClass){
|
|
nBind(function (item, $s, selector, value, key, thisByClass){
|
|
value = typeof value === 'undefined' ? $s[selector] : value;
|
|
value = typeof value === 'undefined' ? $s[selector] : value;
|
|
var keyExists = typeof key !== 'undefined';
|
|
var keyExists = typeof key !== 'undefined';
|
|
- if ((!item.children.length && !Array.isArray(value) && typeof value === 'object') || thisByClass && value){ //hash array on single leaf node -> set attrs on the tag
|
|
|
|
|
|
+ if ((!item.children.length && !Array.isArray(value) && typeof value === 'object') || thisByClass || dom){ //hash array on single leaf node -> set attrs on the tag
|
|
recursiveObjectSet(item,value);
|
|
recursiveObjectSet(item,value);
|
|
//for (var key in value){
|
|
//for (var key in value){
|
|
//item[key] = value[key];
|
|
//item[key] = value[key];
|
|
//}
|
|
//}
|
|
- if (!thisByClass){
|
|
|
|
|
|
+ if (!thisByClass && !dom){
|
|
item.nbData = value;
|
|
item.nbData = value;
|
|
}
|
|
}
|
|
return;
|
|
return;
|
|
@@ -255,12 +261,14 @@ function nbInit(a,b){
|
|
target[prop] = null;
|
|
target[prop] = null;
|
|
//}
|
|
//}
|
|
syncFromDOM(prop);
|
|
syncFromDOM(prop);
|
|
|
|
+ dom = null;
|
|
return target[prop];
|
|
return target[prop];
|
|
},
|
|
},
|
|
set(target, prop, value){
|
|
set(target, prop, value){
|
|
//syncFromDOM();
|
|
//syncFromDOM();
|
|
target[prop] = value
|
|
target[prop] = value
|
|
syncToDOM(prop);
|
|
syncToDOM(prop);
|
|
|
|
+ dom = null;
|
|
return true;
|
|
return true;
|
|
},
|
|
},
|
|
})
|
|
})
|