Comparing version 0.10.5 to 0.10.6
@@ -32,9 +32,2 @@ /** | ||
}, | ||
RQL:function(msg, report, fileName, lineNum){ | ||
if(typeof msg === 'object') | ||
report = msg; | ||
if(!msg) | ||
msg = "RQLError"; | ||
return this.Error(500, msg, report, fileName, lineNum); | ||
}, | ||
MethodNotAllowed:function(msg, report, fileName, lineNum){ | ||
@@ -41,0 +34,0 @@ if(typeof msg === 'object') |
@@ -15,3 +15,4 @@ /** | ||
*/ | ||
deep.flatten = function utilsFlatten(node) { | ||
// todo manage list of arguments : compile them when flattened | ||
deep.flatten = function flatten(node) { | ||
//console.log("deep.flatten : ", node.value); | ||
@@ -18,0 +19,0 @@ if(node._deep_flattener_) |
@@ -21,2 +21,10 @@ /** | ||
deep.errors.RQL = function(msg, report, fileName, lineNum){ | ||
if(typeof msg === 'object') | ||
report = msg; | ||
if(!msg) | ||
msg = "RQLError"; | ||
return deep.errors.Error(500, msg, report, fileName, lineNum); | ||
}; | ||
deep.rql = function(array, query) | ||
@@ -28,6 +36,6 @@ { | ||
return queryCache[query].call(array); | ||
return deep.rqlToFunc(query).call(array); | ||
return deep.rql.compile(query).call(array); | ||
}; | ||
deep.rqlToFunc = function(query){ | ||
deep.rql.compile = function(query){ | ||
var parsed = deep.utils.parseRQL(query); | ||
@@ -34,0 +42,0 @@ var func = rqlNodeToFunc(parsed); |
@@ -61,9 +61,23 @@ /** | ||
{ | ||
var terms = []; | ||
var cur = string[count]; | ||
var toAnalyse = ""; | ||
while(count < ln && string[count] != '}' && string[count] != '|') | ||
while(count < ln && cur != '}' && cur != '|') | ||
{ | ||
if(string[count] != ' ') | ||
toAnalyse += string[count]; | ||
count++; | ||
if(cur == "+") | ||
{ | ||
terms.push(toAnalyse); | ||
toAnalyse = ""; | ||
} | ||
else if(cur == "'") | ||
{ | ||
var end = string.indexOf("'", count+1); | ||
toAnalyse = string.substring(count, end); | ||
count = end; | ||
} | ||
else if(cur != ' ') | ||
toAnalyse += cur; | ||
cur = string[++count]; | ||
} | ||
terms.push(toAnalyse); | ||
var isOr = (string[count] == '|'); | ||
@@ -73,6 +87,24 @@ if(string[count] == '}' || isOr) | ||
var val = null; | ||
if(toAnalyse[0] == "'") | ||
val = toAnalyse.substring(1,toAnalyse.length-1); | ||
else | ||
val = utils.retrieveValueByPath(context, toAnalyse, "."); | ||
for(var i = 0; i < terms.length; ++i) | ||
{ | ||
toAnalyse = terms[i]; | ||
if(toAnalyse[0] == "'") | ||
{ | ||
if(i === 0) | ||
val = toAnalyse.substring(1); | ||
else | ||
val += toAnalyse.substring(1); | ||
} | ||
else | ||
{ | ||
if(i === 0) | ||
val = utils.retrieveValueByPath(context, toAnalyse, "."); | ||
else | ||
val += utils.retrieveValueByPath(context, toAnalyse, "."); | ||
if(val && val.forEach) | ||
val = val.join(","); | ||
} | ||
if(!val) | ||
break; | ||
} | ||
if(val) | ||
@@ -79,0 +111,0 @@ { |
@@ -34,20 +34,3 @@ /** | ||
// should seek after particular deep.ui html attributs and tag to interpret as 'partials' or 'data-bind')... | ||
var self = this; | ||
if (success.placed) { | ||
for(var i in deep.ui.View.htmlEnhancers) | ||
{ | ||
var enhancer = deep.ui.View.htmlEnhancers[i]; | ||
enhancer.call(this,success); | ||
} | ||
success.placed | ||
.find("div[partials]") // <div partials="swig::...." > | ||
.each(function() { | ||
var node = $(this); | ||
deep.get(node.attr("partials")).done(function(partials) { | ||
if (typeof partials === 'function') | ||
node.html(partials()); | ||
node.html(partials); | ||
}); | ||
}); | ||
} | ||
}, | ||
@@ -67,2 +50,3 @@ fail: function(e) { | ||
.done(function(res) { | ||
//console.log("view deep load done : ", res); | ||
return { | ||
@@ -75,3 +59,10 @@ context: self, | ||
}, | ||
refresh: function(params, loaded) { | ||
refresh: function(query, params, loaded) { | ||
if(typeof query === 'object' && query !== null) | ||
{ | ||
loaded = params; | ||
params = query; | ||
query = null; | ||
} | ||
//console.log("view refresh : params : ", params, " - loaded : ", loaded); | ||
var self = this; | ||
@@ -82,9 +73,10 @@ params = params || this.params; | ||
var render = function(loaded) { | ||
if (!loaded) | ||
//console.log("view render : ", loaded) | ||
if (!loaded || !loaded.res) | ||
return; | ||
var what = self, how=null, where=null,rendered = null,placed = null; | ||
if(self.what) | ||
what=loaded.res.shift(); | ||
what = loaded.res.shift(); | ||
if(self.how) | ||
how=loaded.res.shift(); | ||
how = loaded.res.shift(); | ||
if(self.where) | ||
@@ -119,2 +111,3 @@ where=loaded.res.shift(); | ||
} | ||
if (placed) | ||
@@ -124,2 +117,17 @@ self.placed = function() { | ||
}; | ||
var promises = []; | ||
if (placed) | ||
for(var i in deep.ui.View.htmlEnhancers) | ||
{ | ||
var enhancer = deep.ui.View.htmlEnhancers[i]; | ||
promises.push(enhancer.call(this,o)); | ||
} | ||
if(promises.length > 0) | ||
return deep.all(promises) | ||
.done(function(){ | ||
if (typeof self.done === "function") | ||
return self.done(o) || o; | ||
return o; | ||
}); | ||
if (typeof self.done === "function") | ||
@@ -135,3 +143,3 @@ return self.done(o) || o; | ||
toString: function(pretty) { | ||
return JSON.stringify(this); | ||
return "default view render."; | ||
} | ||
@@ -165,6 +173,23 @@ }); | ||
func._isDone_ = true; | ||
deep.chain.addInChain.apply(self,[func]); | ||
deep.chain.addInChain.call(self,func); | ||
return this; | ||
}); | ||
deep.ui.View.htmlEnhancers = {}; | ||
deep.ui.View.htmlEnhancers = { | ||
partials:function(success){ | ||
var promises = []; | ||
success.placed | ||
.find("div[partials]") // <div partials="swig::...." > | ||
.each(function() { | ||
var node = $(this); | ||
promises.push(deep.get(node.attr("partials")) | ||
.done(function(partials) { | ||
if (typeof partials === 'function') | ||
node.html(partials()); | ||
node.html(partials); | ||
})); | ||
}); | ||
return deep.all(promises); | ||
} | ||
}; | ||
return deep.View; | ||
@@ -171,0 +196,0 @@ }); |
{ | ||
"name" : "deepjs", | ||
"version" : "0.10.5", | ||
"version" : "0.10.6", | ||
"author" : "Gilles Coomans <gilles.coomans@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description" : "Powerful atomic tools for managing objects, functions and promises", |
78
TODO.txt
## Beautify | ||
@@ -25,2 +24,5 @@ | ||
- client micro caching | ||
- test context and modes | ||
@@ -124,5 +126,77 @@ | ||
deepjs DSLs : | ||
queries (stepper) | ||
rql | ||
selectors | ||
protocols | ||
sheets | ||
interpret | ||
route | ||
deepjs will show you other kinds of programmation, that use 'spatial' and 'time' consideration | ||
deepjs algorithms | ||
up/bottom | ||
flatten | ||
deepLoad | ||
ocm compilation | ||
setHierarchy | ||
store constraints | ||
fullSchemaByPath | ||
mapper | ||
doRoute | ||
deepjs patterns | ||
layered | ||
backgrounds | ||
selectors | ||
promise | ||
chain | ||
collider | ||
compositions | ||
sheets | ||
store | ||
range | ||
relations | ||
protocols | ||
roles | ||
ocm | ||
context | ||
view | ||
routes | ||
deepjs objects | ||
_deep_query_node_ | ||
_deep_chain_ | ||
_deep_promise_ | ||
_deep_deferred_ | ||
_deep_composition_ | ||
_deep_flattener_ | ||
_deep_merger_ | ||
_deep_ocm_ | ||
_deep_collider_ | ||
_deep_sheet_ | ||
_deep_store_ | ||
_deep_shared_ | ||
_deep_range_ | ||
_deep_view_ | ||
_deep_mapper_ | ||
_deep_router_ | ||
@@ -30,5 +30,5 @@ if (typeof define !== 'function') { | ||
c:function(){ | ||
return deep("mystring { id | '0' } after") | ||
return deep("mystring { id | 'hello' } after") | ||
.interpret({id:undefined}) | ||
.equal("mystring 0 after"); | ||
.equal("mystring hello after"); | ||
}, | ||
@@ -39,2 +39,22 @@ d:function(){ | ||
.equal("mystring 12 after"); | ||
}, | ||
e:function(){ | ||
return deep("mystring { 'hello world' } after") | ||
.interpret({id:12}) | ||
.equal("mystring hello world after"); | ||
}, | ||
addition:function(){ | ||
return deep("mystring { 'hello world : '+'interpreted' + id } after") | ||
.interpret({id:12}) | ||
.equal("mystring hello world : interpreted12 after"); | ||
}, | ||
addition_breaked:function(){ | ||
return deep("mystring { id+'interpreted' | 'other' } after") | ||
.interpret({id:undefined}) | ||
.equal("mystring other after"); | ||
}, | ||
array:function(){ | ||
return deep("mystring { arr } after") | ||
.interpret({arr:[1,3,4]}) | ||
.equal("mystring 1,3,4 after"); | ||
} | ||
@@ -41,0 +61,0 @@ } |
696292
15297