[Z3lab-checkins] r2344 - cpsskins/branches/jmo-perspectives/ui/framework/tests/unit
Author: jmorliaguet Date: Sat Feb 11 13:06:14 2006 New Revision: 2344 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Log: - test updates Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Sat Feb 11 13:06:14 2006 @@ -35,30 +35,119 @@ div id=e4span ctal:condition=ctrue ctal:content=string:B.../span/div +div id=e4bspan ctal:content=string:B + ctal:condition=ctrue.../span/div + div id=e5span ctal:condition=cfalse ctal:content=string:C.../span/div +div id=e5bspan ctal:content=string:C +ctal:condition=cfalse.../span/div + !-- ctal:content / ctal:attributes -- div id=e6span ctal:content=string:D ctal:attributes=class string:E.../span/div +div id=e6bspan ctal:attributes=class string:E +ctal:content=string:D.../span/div + !-- ctal:condition / ctal:content / ctal:attributes -- div id=e7span ctal:condition=ctrue ctal:content=string:F ctal:attributes=class string:G.../span/div +div id=e7bspan ctal:content=string:F +ctal:condition=ctrue +ctal:attributes=class string:G.../span/div + +div id=e7cspan ctal:attributes=class string:G +ctal:content=string:F +ctal:condition=ctrue.../span/div + +div id=e7dspan ctal:content=string:F +ctal:attributes=class string:G +ctal:condition=ctrue.../span/div + +div id=e7espan ctal:condition=ctrue +ctal:attributes=class string:G +ctal:content=string:F.../span/div + div id=e8span ctal:condition=cfalse ctal:content=string:H ctal:attributes=class string:I.../span/div +div id=e8bspan ctal:condition=cfalse +ctal:attributes=class string:I +ctal:content=string:H.../span/div + +div id=e8cspan ctal:content=string:H +ctal:condition=cfalse +ctal:attributes=class string:I.../span/div + +div id=e8cspan ctal:content=string:H +ctal:attributes=class string:I +ctal:condition=cfalse.../span/div + +div id=e8dspan ctal:attributes=class string:I +ctal:content=string:H +ctal:condition=cfalse.../span/div + +div id=e8espan ctal:attributes=class string:I +ctal:condition=cfalse +ctal:content=string:H.../span/div + +div id=e8fspan ctal:attributes=class string:I +ctal:condition=cfalse +ctal:content=string:H.../span/div + !-- ctal:omit-tag / ctal:content -- div id=e9span ctal:omit-tag=ctrue ctal:condition=ctrue ctal:content=string:J.../span/div -div id=e10span ctal:omit-tag=ctrue -ctal:condition=cfalse -ctal:content=string:K.../span/div +div id=e9bspan ctal:omit-tag=ctrue + ctal:content=string:J + ctal:condition=ctrue.../span/div + +div id=e9cspan ctal:condition=ctrue +ctal:omit-tag=ctrue +ctal:content=string:J.../span/div + +div id=e9dspan ctal:condition=ctrue +ctal:content=string:J +ctal:omit-tag=ctrue.../span/div + +div id=e9espan ctal:content=string:J +ctal:condition=ctrue +ctal:omit-tag=ctrue.../span/div + +div id=e9fspan ctal:content=string:J +ctal:omit-tag=ctrue +ctal:condition=ctrue.../span/div + +div id=e10span ctal:content=string:K +ctal:omit-tag=ctrue +ctal:condition=cfalse.../span/div + +div id=e10bspan ctal:content=string:K + ctal:condition=cfalse + ctal:omit-tag=ctrue.../span/div + +div id=e10cspan ctal:omit-tag=ctrue + ctal:condition=cfalse + ctal:content=string:K.../span/div + +div id=e10dspan ctal:omit-tag=ctrue + ctal:content=string:K + ctal:condition=cfalse.../span/div + +div id=e10espan ctal:condition=cfalse + ctal:omit-tag=ctrue + ctal:content=string:K.../span/div + +div id=e10fspan ctal:condition=cfalse + ctal:content=string:K + ctal:omit-tag=ctrue.../span/div div id=e11span ctal:omit-tag=cfalse ctal:condition=ctrue @@ -69,44 +158,59 @@ ctal:content=string:M.../span/div !--
[Z3lab-checkins] r2345 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 11 13:10:09 2006 New Revision: 2345 Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Log: - fixed incompatibility with prototype.js Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js == --- cpsskins/branches/jmo-perspectives/ui/framework/ctal.js (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Sat Feb 11 13:10:09 2006 @@ -52,8 +52,8 @@ nodes[0] = value; } } - var node; - for (;node=nodes.shift();) { + for (var i=0; inodes.length; i++) { +var node = nodes[i]; if (marker) { parent.insertBefore(node, marker); } else { @@ -82,8 +82,8 @@ ctal.tal_attributes = function(tmpl, value, data) { var attrs = value.split(;); - var attr; - for (;attr=attrs.shift();) { + for (var i=0; iattrs.length; i++) { +var attr = attrs[i]; var nmx = ctal.get_nameexpr(attr); var aname = nmx[0] var avalue = ctal.eval_expr(data, nmx[1]) -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2347 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 11 13:53:39 2006 New Revision: 2347 Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Log: - reverting. the error comes from the fact that the main data structure gets modified during the parsing phase. Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js == --- cpsskins/branches/jmo-perspectives/ui/framework/ctal.js (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Sat Feb 11 13:53:39 2006 @@ -223,15 +223,8 @@ } ctal.get_nameexpr = function(value) { - var splitnx = value.split(/ /); - var first = ; - // ltrim - while (first == ) { -first = splitnx.shift(); - } - return [first, splitnx.join( )]; - //var splitnx = ctal.trim(value).split(/ /); - //return [ctal.trim(splitnx[0]), ctal.trim(splitnx.slice(1).join(' '))]; + var splitnx = ctal.trim(value).split(/ /); + return [ctal.trim(splitnx[0]), ctal.trim(splitnx.slice(1).join(' '))]; } ctal.trim = function(text) { -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2348 - cpsskins/branches/jmo-perspectives/ui/framework/tests/unit
Author: jmorliaguet Date: Sat Feb 11 13:59:00 2006 New Revision: 2348 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Log: - added test to make sure that the data structure does not get corrupted Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Sat Feb 11 13:59:00 2006 @@ -273,7 +273,6 @@ m: 10 } }, - ctrue: 1, cfalse: 0 } @@ -284,6 +283,18 @@ ctal.process_ctal(document, data); }, +testDataStructure: function() { with(this) { + assertEqual(data['a'], 1); + assertEqual(data['b'], 2); + assertEqual(data['c']['d'], 3); + assertEqual(data['c']['e'], 4); + assertEqual($A(data['f']).inspect(), $A([4, 5, 6]).inspect()); + assertEqual($H(data['g'][0]).inspect(), $H({h: 7, i: 8, j: 9}).inspect()); + assertEqual(data['k']['l']['m'], 10); + assertEqual(data['ctrue'], 1); + assertEqual(data['cfalse'], 0); +}}, + testPrivateAPI: function() { with(this) { assertEqual($A(['style', '']).inspect(), $A(ctal.get_nameexpr('style')).inspect()); -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2349 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 11 14:13:47 2006 New Revision: 2349 Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Log: - a shallow copy should be used Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js == --- cpsskins/branches/jmo-perspectives/ui/framework/ctal.js (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Sat Feb 11 14:13:47 2006 @@ -210,6 +210,7 @@ ctal.eval_pathexpr = function(data, path) { var pathelems = path.split(/); + // XXX use a shallow copy var traverse = data; for (var i=0; i pathelems.length; i++) { if (typeof traverse[pathelems[i]] == undefined) { -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2351 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 11 15:38:13 2006 New Revision: 2351 Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Log: - improved robustness Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js == --- cpsskins/branches/jmo-perspectives/ui/framework/ctal.js (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Sat Feb 11 15:38:13 2006 @@ -83,7 +83,8 @@ ctal.tal_attributes = function(tmpl, value, data) { var attrs = value.split(;); for (var i=0; iattrs.length; i++) { -var attr = attrs[i]; +var attr = ctal.trim(attrs[i]); +if (!attr) continue; var nmx = ctal.get_nameexpr(attr); var aname = nmx[0] var avalue = ctal.eval_expr(data, nmx[1]) @@ -210,15 +211,12 @@ ctal.eval_pathexpr = function(data, path) { var pathelems = path.split(/); - // XXX use a shallow copy var traverse = data; for (var i=0; i pathelems.length; i++) { -if (typeof traverse[pathelems[i]] == undefined) { +traverse = traverse[pathelems[i]]; +if (typeof traverse == undefined) { throw new ctal.TALESError('No data found for ' + path + '') } -else { - traverse = traverse[pathelems[i]]; -} } return traverse; } -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2352 - cpsskins/branches/jmo-perspectives/ui/framework/tests/unit
Author: jmorliaguet Date: Sat Feb 11 15:38:38 2006 New Revision: 2352 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Log: - new tests Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Sat Feb 11 15:38:38 2006 @@ -252,6 +252,28 @@ ctal:repeat=item f ctal:content=item.../div/div +!-- ctal:attributes -- +div id=e30span + ctal:attributes=color string:red.../span/div + +div id=e30bspan + ctal:attributes=color string:red;.../span/div + +div id=e30cspan + ctal:attributes=color string:red ;.../span/div + +div id=e30dspan + ctal:attributes=color string:red; class string: large.../span/div + +div id=e30espan + ctal:attributes=color string:red; class string: large;.../span/div + +div id=e30fspan + ctal:attributes= color string:red; class string: large; .../span/div + +div id=e30gspan + ctal:attributes=color string: red; class string: large; .../span/div + !-- Tests follow -- script type=text/javascript @@ -304,6 +326,8 @@ $A(ctal.get_nameexpr(' style string:1 ')).inspect()); assertEqual($A(['style', 'a/b/c']).inspect(), $A(ctal.get_nameexpr(' style a/b/c')).inspect()); + assertEqual($A(['style', 'a/b/c; color a/b']).inspect(), + $A(ctal.get_nameexpr('style a/b/c; color a/b')).inspect()); }}, testTALContent: function() { with(this) { @@ -427,6 +451,20 @@ assertEqual('div4/divdiv5/divdiv6/div', $(e28).innerHTML); assertEqual('', $(e29).innerHTML); +}}, + +testTALAttributes: function() { with(this) { + assertEqual('span color=red.../span', $(e30).innerHTML); + assertEqual('span color=red.../span', $(e30b).innerHTML); + assertEqual('span color=red.../span', $(e30c).innerHTML); + assertEqual('span class=large color=red.../span', + $(e30d).innerHTML); + assertEqual('span class=large color=red.../span', + $(e30e).innerHTML); + assertEqual('span class=large color=red.../span', + $(e30f).innerHTML); + assertEqual('span class=large color= red.../span', + $(e30g).innerHTML); }} }); -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2353 - cpsskins/branches/jmo-perspectives/ui/framework/tests/unit
Author: jmorliaguet Date: Sat Feb 11 15:47:55 2006 New Revision: 2353 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Log: - added javascript:... tests Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Sat Feb 11 15:47:55 2006 @@ -274,6 +274,15 @@ div id=e30gspan ctal:attributes=color string: red; class string: large; .../span/div +!-- javascript: -- +div id=e31span ctal:content=javascript:1.../span/div + +div id=e31bspan ctal:content=javascript:1+1.../span/div + +div id=e31cspan +ctal:content=javascript:data['k']['l']['m'].../span/div + +!-- ctal:attributes -- !-- Tests follow -- script type=text/javascript @@ -465,6 +474,12 @@ $(e30f).innerHTML); assertEqual('span class=large color= red.../span', $(e30g).innerHTML); +}}, + +testJavascript: function() { with(this) { + assertEqual('span1/span', $(e31).innerHTML); + assertEqual('span2/span', $(e31b).innerHTML); + assertEqual('span10/span', $(e31c).innerHTML); }} }); -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2354 - in cpsskins/branches/jmo-perspectives/ui/framework: . tests/unit
Author: jmorliaguet Date: Sat Feb 11 16:33:05 2006 New Revision: 2354 Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Log: - more robust code (e.g. Opera) - test updates Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js == --- cpsskins/branches/jmo-perspectives/ui/framework/ctal.js (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Sat Feb 11 16:33:05 2006 @@ -170,11 +170,16 @@ if (tmpl.nodeType == 1) { var parsers = ctal.parsers; for (ctal_attr in parsers) { - var attrnode = tmpl.getAttribute(ctal_attr); - if (attrnode) { + var attrs = tmpl.attributes; + for (i=0; iattrs.length; i++) { +var attrnode = attrs[i]; +var attrname = attrnode.nodeName; +if (attrname != ctal_attr) { + continue; +} tmpl.removeAttribute(ctal_attr); var parser = parsers[ctal_attr]; -parser(tmpl, attrnode, data) +parser(tmpl, attrnode.value, data) } } } Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Sat Feb 11 16:33:05 2006 @@ -9,6 +9,7 @@ meta http-equiv=content-type content=text/html; charset=utf-8 / script src=../../prototype.js type=text/javascript/script script src=../../ctal.js type=text/javascript/script + script src=../../cpsskins.js type=text/javascript/script script src=../unittest.js type=text/javascript/script link rel=stylesheet href=../test.css type=text/css / /head @@ -252,37 +253,6 @@ ctal:repeat=item f ctal:content=item.../div/div -!-- ctal:attributes -- -div id=e30span - ctal:attributes=color string:red.../span/div - -div id=e30bspan - ctal:attributes=color string:red;.../span/div - -div id=e30cspan - ctal:attributes=color string:red ;.../span/div - -div id=e30dspan - ctal:attributes=color string:red; class string: large.../span/div - -div id=e30espan - ctal:attributes=color string:red; class string: large;.../span/div - -div id=e30fspan - ctal:attributes= color string:red; class string: large; .../span/div - -div id=e30gspan - ctal:attributes=color string: red; class string: large; .../span/div - -!-- javascript: -- -div id=e31span ctal:content=javascript:1.../span/div - -div id=e31bspan ctal:content=javascript:1+1.../span/div - -div id=e31cspan -ctal:content=javascript:data['k']['l']['m'].../span/div - -!-- ctal:attributes -- !-- Tests follow -- script type=text/javascript @@ -460,26 +430,6 @@ assertEqual('div4/divdiv5/divdiv6/div', $(e28).innerHTML); assertEqual('', $(e29).innerHTML); -}}, - -testTALAttributes: function() { with(this) { - assertEqual('span color=red.../span', $(e30).innerHTML); - assertEqual('span color=red.../span', $(e30b).innerHTML); - assertEqual('span color=red.../span', $(e30c).innerHTML); - assertEqual('span class=large color=red.../span', - $(e30d).innerHTML); - assertEqual('span class=large color=red.../span', - $(e30e).innerHTML); - assertEqual('span class=large color=red.../span', - $(e30f).innerHTML); - assertEqual('span class=large color= red.../span', - $(e30g).innerHTML); -}}, - -testJavascript: function() { with(this) { - assertEqual('span1/span', $(e31).innerHTML); - assertEqual('span2/span', $(e31b).innerHTML); - assertEqual('span10/span', $(e31c).innerHTML); }} }); -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2355 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 11 16:53:25 2006 New Revision: 2355 Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Log: - this fixes the tests on Opera Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js == --- cpsskins/branches/jmo-perspectives/ui/framework/ctal.js (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Sat Feb 11 16:53:25 2006 @@ -174,12 +174,16 @@ for (i=0; iattrs.length; i++) { var attrnode = attrs[i]; var attrname = attrnode.nodeName; -if (attrname != ctal_attr) { +if (attrname != ctal: + ctal_attr) { continue; } +tmpl.removeAttribute(ctal: + ctal_attr); +// For Opera tmpl.removeAttribute(ctal_attr); + var parser = parsers[ctal_attr]; parser(tmpl, attrnode.value, data) +break; } } } @@ -240,11 +244,11 @@ } ctal.parsers = { - ctal:condition: ctal.tal_condition, - ctal:repeat: ctal.tal_repeat, - ctal:content: ctal.tal_content, - ctal:attributes: ctal.tal_attributes, - ctal:omit-tag: ctal.tal_omit_tag, - ctal:replace: ctal.tal_replace + condition: ctal.tal_condition, + repeat: ctal.tal_repeat, + content: ctal.tal_content, + attributes: ctal.tal_attributes, + omit-tag: ctal.tal_omit_tag, + replace: ctal.tal_replace }; -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2356 - cpsskins/branches/jmo-perspectives/ui/framework/tests/unit
Author: jmorliaguet Date: Sat Feb 11 17:37:53 2006 New Revision: 2356 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Log: - the .innerHTML output needs to be normalized Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Sat Feb 11 17:37:53 2006 @@ -9,7 +9,6 @@ meta http-equiv=content-type content=text/html; charset=utf-8 / script src=../../prototype.js type=text/javascript/script script src=../../ctal.js type=text/javascript/script - script src=../../cpsskins.js type=text/javascript/script script src=../unittest.js type=text/javascript/script link rel=stylesheet href=../test.css type=text/css / /head @@ -29,158 +28,158 @@ !-- ctal:content -- div id=e0span ctal:content=a.../span/div div id=e1span ctal:content=c/d.../span/div -div id=e2span ctal:content=string:A.../span/div +div id=e2span ctal:content=string:a.../span/div div id=e3span ctal:content=k/l/m.../span/div !-- ctal:condition / ctal:content -- div id=e4span ctal:condition=ctrue - ctal:content=string:B.../span/div + ctal:content=string:b.../span/div -div id=e4bspan ctal:content=string:B +div id=e4bspan ctal:content=string:b ctal:condition=ctrue.../span/div div id=e5span ctal:condition=cfalse - ctal:content=string:C.../span/div + ctal:content=string:c.../span/div div id=e5bspan ctal:content=string:C ctal:condition=cfalse.../span/div !-- ctal:content / ctal:attributes -- -div id=e6span ctal:content=string:D - ctal:attributes=class string:E.../span/div +div id=e6span ctal:content=string:d + ctal:attributes=class string:e.../span/div -div id=e6bspan ctal:attributes=class string:E -ctal:content=string:D.../span/div +div id=e6bspan ctal:attributes=class string:e +ctal:content=string:d.../span/div !-- ctal:condition / ctal:content / ctal:attributes -- div id=e7span ctal:condition=ctrue - ctal:content=string:F - ctal:attributes=class string:G.../span/div + ctal:content=string:f + ctal:attributes=class string:g.../span/div -div id=e7bspan ctal:content=string:F +div id=e7bspan ctal:content=string:f ctal:condition=ctrue -ctal:attributes=class string:G.../span/div +ctal:attributes=class string:g.../span/div -div id=e7cspan ctal:attributes=class string:G -ctal:content=string:F +div id=e7cspan ctal:attributes=class string:g +ctal:content=string:f ctal:condition=ctrue.../span/div -div id=e7dspan ctal:content=string:F -ctal:attributes=class string:G +div id=e7dspan ctal:content=string:f +ctal:attributes=class string:g ctal:condition=ctrue.../span/div div id=e7espan ctal:condition=ctrue -ctal:attributes=class string:G -ctal:content=string:F.../span/div +ctal:attributes=class string:g +ctal:content=string:f.../span/div div id=e8span ctal:condition=cfalse - ctal:content=string:H - ctal:attributes=class string:I.../span/div + ctal:content=string:h + ctal:attributes=class string:i.../span/div div id=e8bspan ctal:condition=cfalse -ctal:attributes=class string:I -ctal:content=string:H.../span/div +ctal:attributes=class string:i +ctal:content=string:h.../span/div -div id=e8cspan ctal:content=string:H +div id=e8cspan ctal:content=string:h ctal:condition=cfalse -ctal:attributes=class string:I.../span/div +ctal:attributes=class string:i.../span/div -div id=e8cspan ctal:content=string:H -ctal:attributes=class string:I +div id=e8cspan ctal:content=string:h +ctal:attributes=class string:i ctal:condition=cfalse.../span/div -div id=e8dspan ctal:attributes=class string:I -ctal:content=string:H +div id=e8dspan ctal:attributes=class string:i +ctal:content=string:h ctal:condition=cfalse.../span/div -div id=e8espan ctal:attributes=class string:I +div id=e8espan ctal:attributes=class string:i ctal:condition=cfalse -ctal:content=string:H.../span/div +
[Z3lab-checkins] r2359 - cpsskins/branches/jmo-perspectives/ui/framework/tests/functional
Author: jmorliaguet Date: Sat Feb 11 18:19:27 2006 New Revision: 2359 Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/ajax_widget_template.pt (contents, props changed) Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_progressive_enhancement.html Log: - using an external template to draw the widget (-20 lines) Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/ajax_widget_template.pt == --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/ajax_widget_template.pt Sat Feb 11 18:19:27 2006 @@ -0,0 +1,3 @@ +div class=ajax + AJAX widget +/div Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_progressive_enhancement.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_progressive_enhancement.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_progressive_enhancement.html Sat Feb 11 18:19:27 2006 @@ -7,6 +7,7 @@ meta http-equiv=content-type content=text/html; charset=utf-8 / script src=../../prototype.js type=text/javascript/script script src=../../json.js type=text/javascript/script + script src=../../ctal.js type=text/javascript/script script src=../../cpsskins.js type=text/javascript/script link rel=stylesheet href=../../cpsskins.css type=text/css / @@ -25,29 +26,6 @@ } /style - script type=text/javascript -Object.extend(Widgets, { - - ajaxwidget: function(def) { -var widget = Canvas.createNode({ - tag: div, - classes: ajax -}); -return new AjaxWidget(widget, def); - }, -}); - -AjaxWidget = Class.create(); -AjaxWidget.prototype = Object.extend(new CPSSkins.View(), { - - render: function(data) { -this.widget.innerHTML = Ajax widget; - } - -}); - - /script - /head body @@ -77,7 +55,7 @@ ins class=view {widget: { - type: ajaxwidget, + template: ajax_widget_template.pt, replace: htmlwidget }, model: ram-data-provider -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2360 - cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat
Author: jmorliaguet Date: Sat Feb 11 18:55:28 2006 New Revision: 2360 Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/chatbox.pt (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/chatinput.pt (contents, props changed) Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/configure.zcml cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt Log: - replaced the chat box with a template Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/chatbox.pt == --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/chatbox.pt Sat Feb 11 18:55:28 2006 @@ -0,0 +1,7 @@ +div class=chatbox + div class=message ctal:repeat=message messages + [span ctal:content=message/date00:00:00/span] + strong ctal:content=message/userUser/strong: + span ctal:content=message/textText/span + /div +/div Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/chatinput.pt == --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/chatinput.pt Sat Feb 11 18:55:28 2006 @@ -0,0 +1,3 @@ +form method=post + not done yet +/form Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/configure.zcml == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/configure.zcml (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/configure.zcml Sat Feb 11 18:55:28 2006 @@ -9,6 +9,22 @@ template=cpsskins_chat.pt / + browser:page + for=* + layer=cpsskins + name=chatinput.html + permission=zope.Public + template=chatinput.pt + / + + browser:page + for=* + layer=cpsskins + name=chatbox.html + permission=zope.Public + template=chatbox.pt + / + browser:pages layer=cpsskins for=* Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt Sat Feb 11 18:55:28 2006 @@ -9,6 +9,8 @@ type=text/javascript/script script src=/++skin++cpsskins/@@/++resource++json.js type=text/javascript/script + script src=/++skin++cpsskins/@@/++resource++ctal.js + type=text/javascript/script script src=/++skin++cpsskins/@@/++resource++cpsskins.js type=text/javascript/script link rel=stylesheet type=text/css @@ -69,14 +71,6 @@ Object.extend(Widgets, { - chatbox: function(def) { -var widget = Canvas.createNode({ - tag: div, - classes: chatbox -}); -return new ChatBox(widget, def); - }, - inputbox: function(def) { var widget = Canvas.createNode({ tag: form, @@ -88,26 +82,6 @@ }); -ChatBox = Class.create(); -ChatBox.prototype = Object.extend(new CPSSkins.View(), { - - render: function(data) { -var widget = this.widget; -widget.innerHTML = ''; -var messages = data.messages; - -$A(messages).each(function(m, index) { - var message = Canvas.createNode({ -tag: div, -classes: message, -text: '[' + m.date + '] ' + m.user + ': ' + m.text - }); - widget.appendChild(message); -}); - } - -}); - InputBox = Class.create(); InputBox.prototype = Object.extend(new CPSSkins.View(), { @@ -276,7 +250,7 @@ ins class=view {widget: { - type: chatbox + template: chatbox.html }, model: chat } -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2361 - cpsskins/branches/jmo-perspectives/ui/framework/tests/unit
Author: jmorliaguet Date: Sat Feb 11 19:07:25 2006 New Revision: 2361 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Log: - added tests removed by mistake - began adding edge-case tests Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Sat Feb 11 19:07:25 2006 @@ -252,6 +252,40 @@ ctal:repeat=item f ctal:content=item.../div/div +!-- ctal:attributes -- +div id=e30span + ctal:attributes=color string:red.../span/div + +div id=e30bspan + ctal:attributes=color string:red;.../span/div + +div id=e30cspan + ctal:attributes=color string:red ;.../span/div + +div id=e30dspan + ctal:attributes=color string:red; class string: large.../span/div + +div id=e30espan + ctal:attributes=color string:red; class string: large;.../span/div + +div id=e30fspan + ctal:attributes= color string:red; class string: large; .../span/div + +div id=e30gspan + ctal:attributes=color string: red; class string: large; .../span/div + +!-- javascript: -- +div id=e31span ctal:content=javascript:1.../span/div + +div id=e31bspan ctal:content=javascript:1+1.../span/div + +div id=e31cspan +ctal:content=javascript:data['k']['l']['m'].../span/div + +!-- edge cases -- + +div id=e32p ctal:repeat=item javascript:[]span + tal:content=item/id.../span/div !-- Tests follow -- script type=text/javascript @@ -434,6 +468,30 @@ assertEqual('div4/divdiv5/divdiv6/div', htmlOf(e28)); assertEqual('', htmlOf(e29)); +}}, + +testTALAttributes: function() { with(this) { + assertEqual('span color=red.../span', htmlOf(e30)); + assertEqual('span color=red.../span', htmlOf(e30b)); + assertEqual('span color=red.../span', htmlOf(e30c)); + assertEqual('span class=large color=red.../span', + htmlOf(e30d)); + assertEqual('span class=large color=red.../span', + htmlOf(e30e)); + assertEqual('span class=large color=red.../span', + htmlOf(e30f)); + assertEqual('span class=large color= red.../span', + htmlOf(e30g)); +}}, + +testJavascript: function() { with(this) { + assertEqual('span1/span', htmlOf(e31)); + assertEqual('span2/span', htmlOf(e31b)); + assertEqual('span10/span', htmlOf(e31c)); +}}, + +testEdgeCases: function() { with(this) { + assertEqual('', htmlOf(e32)); }} }); -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2362 - cpsskins/branches/jmo-perspectives/ui/framework/tests/unit
Author: jmorliaguet Date: Sat Feb 11 21:49:17 2006 New Revision: 2362 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Log: - found another edge case Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Sat Feb 11 21:49:17 2006 @@ -284,8 +284,14 @@ !-- edge cases -- +!-- item/id should never be accessed -- div id=e32p ctal:repeat=item javascript:[]span - tal:content=item/id.../span/div + ctal:content=item/id.../span/div + +!-- the repeat loop 'a' variable should not override the global variable + 'a' in the data structure -- +div id=e33p ctal:repeat=a javascript:[1, 2]span + ctal:content=a.../span/div !-- Tests follow -- script type=text/javascript @@ -492,6 +498,7 @@ testEdgeCases: function() { with(this) { assertEqual('', htmlOf(e32)); + assertEqual('pspan1/span/ppspan2/span/p', htmlOf(e33)); }} }); -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2363 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 11 22:21:58 2006 New Revision: 2363 Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Log: - only recurse if needed (removes the item/id bug) Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js == --- cpsskins/branches/jmo-perspectives/ui/framework/ctal.js (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Sat Feb 11 22:21:58 2006 @@ -142,8 +142,9 @@ ctal.tal_repeat = function(tmpl, value, data) { var nmx = ctal.get_nameexpr(value); + var datas; try { -var datas = ctal.eval_expr(data, nmx[1]); +datas = ctal.eval_expr(data, nmx[1]); } catch (e) { if (e.name == ctal.TALESError.name) { throw new ctal.TALError(nmx[1]+ is not an Array.) @@ -167,6 +168,7 @@ /* general processor */ ctal.process_ctal = function(tmpl, data) { + var recurse = true; if (tmpl.nodeType == 1) { var parsers = ctal.parsers; for (ctal_attr in parsers) { @@ -182,14 +184,19 @@ tmpl.removeAttribute(ctal_attr); var parser = parsers[ctal_attr]; -parser(tmpl, attrnode.value, data) +if (!parser.recurse) { + recurse = false; +} +parser.parse(tmpl, attrnode.value, data) break; } } } // recursion - for (var i=0; itmpl.childNodes.length; i++) { -ctal.process_ctal(tmpl.childNodes[i], data); + if (recurse) { +for (var i=0; itmpl.childNodes.length; i++) { + ctal.process_ctal(tmpl.childNodes[i], data); +} } } @@ -224,7 +231,7 @@ for (var i=0; i pathelems.length; i++) { traverse = traverse[pathelems[i]]; if (typeof traverse == undefined) { - throw new ctal.TALESError('No data found for ' + path + '') + throw new ctal.TALESError('No data found for ' + path + '') } } return traverse; @@ -243,12 +250,13 @@ return cond (cond != ) } +// the parsing order matters ctal.parsers = { - condition: ctal.tal_condition, - repeat: ctal.tal_repeat, - content: ctal.tal_content, - attributes: ctal.tal_attributes, - omit-tag: ctal.tal_omit_tag, - replace: ctal.tal_replace + condition: {'parse': ctal.tal_condition, 'recurse': true}, + repeat: {'parse': ctal.tal_repeat, 'recurse': false}, + content: {'parse': ctal.tal_content, 'recurse': false}, + replace: {'parse': ctal.tal_replace, 'recurse': false}, + omit-tag: {'parse': ctal.tal_omit_tag, 'recurse': true}, + attributes: {'parse': ctal.tal_attributes, 'recurse': true} }; -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2364 - in cpsskins/branches/jmo-perspectives/ui/framework: . tests/unit
Author: jmorliaguet Date: Sat Feb 11 22:58:41 2006 New Revision: 2364 Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Log: - we do a deep copy of the data structure traversed by the ctal:repeat loop and we restore afterwards otherwise the original data structure gets corrupted. - test updates. Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js == --- cpsskins/branches/jmo-perspectives/ui/framework/ctal.js (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Sat Feb 11 22:58:41 2006 @@ -156,12 +156,26 @@ if (!parent) return; var marker = tmpl.nextSibling; parent.removeChild(tmpl); + + var current_data, saved_data; for (var i=0; idatas.length; i++) { +// do a deep copy of the data structure traversed by the repeat loop +// to avoid corrupting it. +var saved_data = null; +var current_data = data[nmx[0]]; +if (current_data) { + saved_data = ctal.deepcopy(current_data); +} data[nmx[0]] = datas[i]; + var newnode = tmpl.cloneNode(true); ctal.node_insertbefore(parent, newnode, marker); // recurse ctal.process_ctal(newnode, data); +// restore the original data structure +if (saved_data) { + data = ctal.deepcopy(saved_data); +} } } @@ -246,6 +260,18 @@ return text.replace(/^\s+|\s+$/g, ); } +ctal.deepcopy = function(obj) { + var clone = new obj.constructor(); + for (var i in obj) { +if (typeof obj[i] == object) { + clone[i] = ctal.deepcopy(obj[i]); +} else { + clone[i] = obj[i]; +} + } + return clone; +} + ctal.isTrue = function(cond) { return cond (cond != ) } Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Sat Feb 11 22:58:41 2006 @@ -329,15 +329,15 @@ }, testDataStructure: function() { with(this) { - assertEqual(data['a'], 1); - assertEqual(data['b'], 2); - assertEqual(data['c']['d'], 3); - assertEqual(data['c']['e'], 4); - assertEqual($A(data['f']).inspect(), $A([4, 5, 6]).inspect()); - assertEqual($H(data['g'][0]).inspect(), $H({h: 7, i: 8, j: 9}).inspect()); - assertEqual(data['k']['l']['m'], 10); - assertEqual(data['ctrue'], 1); - assertEqual(data['cfalse'], 0); + assertEqual(1, data['a']); + assertEqual(2, data['b']); + assertEqual(3, data['c']['d']); + assertEqual(4, data['c']['e']); + assertEqual($A([4, 5, 6]).inspect(), $A(data['f']).inspect()); + assertEqual($H({h: 7, i: 8, j: 9}).inspect(), $H(data['g'][0]).inspect()); + assertEqual(10, data['k']['l']['m']); + assertEqual(1, data['ctrue']); + assertEqual(0, data['cfalse']); }}, testPrivateAPI: function() { with(this) { -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins