diff options
author | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-14 15:39:19 +0000 |
---|---|---|
committer | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-14 15:39:19 +0000 |
commit | 1c5685d68f1b73270fb814fe04cbb490eb90ba5f (patch) | |
tree | 3d3ada08a934b96fc31531f1327690d7edc6f766 /includes/js/dojox/dtl/tests/html | |
parent | 104d59099e048688c4dbac37d72137006e396558 (diff) | |
download | semanticscuttle-1c5685d68f1b73270fb814fe04cbb490eb90ba5f.tar.gz semanticscuttle-1c5685d68f1b73270fb814fe04cbb490eb90ba5f.tar.bz2 |
Minor fix: Remove DOJO library (60Mo) replaced by link to Google CDN (online DOJO library)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@159 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojox/dtl/tests/html')
-rw-r--r-- | includes/js/dojox/dtl/tests/html/buffer.js | 35 | ||||
-rw-r--r-- | includes/js/dojox/dtl/tests/html/tag.js | 233 | ||||
-rw-r--r-- | includes/js/dojox/dtl/tests/html/util.js | 160 |
3 files changed, 0 insertions, 428 deletions
diff --git a/includes/js/dojox/dtl/tests/html/buffer.js b/includes/js/dojox/dtl/tests/html/buffer.js deleted file mode 100644 index 3077d8c..0000000 --- a/includes/js/dojox/dtl/tests/html/buffer.js +++ /dev/null @@ -1,35 +0,0 @@ -if(!dojo._hasResource["dojox.dtl.tests.html.buffer"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojox.dtl.tests.html.buffer"] = true; -dojo.provide("dojox.dtl.tests.html.buffer"); - -dojo.require("dojox.dtl.html"); -dojo.require("dojox.dtl.Context"); -dojo.require("dojox.dtl.tests.html.util"); - -doh.register("dojox.dtl.html.buffer", - [ - function test_insertion_order_text(t){ - var dd = dojox.dtl; - - var context = new dd.Context({ - first: false, - last: false - }); - - var template = new dd.HtmlTemplate("<div>{% if first %}first{% endif %}middle{% if last %}last{% endif %}</div>"); - t.is("<div>middle</div>", dd.tests.html.util.render(template, context)); - - context.first = true; - t.is("<div>firstmiddle</div>", dd.tests.html.util.render(template, context)); - - context.first = false; - context.last = true; - t.is("<div>middlelast</div>", dd.tests.html.util.render(template, context)); - - context.first = true; - t.is("<div>firstmiddlelast</div>", dd.tests.html.util.render(template, context)); - } - ] -); - -} diff --git a/includes/js/dojox/dtl/tests/html/tag.js b/includes/js/dojox/dtl/tests/html/tag.js deleted file mode 100644 index c964913..0000000 --- a/includes/js/dojox/dtl/tests/html/tag.js +++ /dev/null @@ -1,233 +0,0 @@ -if(!dojo._hasResource["dojox.dtl.tests.html.tag"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojox.dtl.tests.html.tag"] = true; -dojo.provide("dojox.dtl.tests.html.tag"); - -dojo.require("dojox.dtl.html"); -dojo.require("dojox.dtl.Context"); -dojo.require("dojox.dtl.tests.html.util"); - -doh.register("dojox.dtl.html.tag", - [ - function test_errors(t){ - var dd = dojox.dtl; - var template; - - // No root node after rendering - var found = false; - try { - template = new dd.HtmlTemplate('No div'); - dd.tests.html.util.render(template); - }catch(e){ - t.is("Text should not exist outside of the root node in template", e.message); - found = true; - } - t.t(found); - - var context = new dojox.dtl.Context({test: "Pocket"}); - found = false; - try { - template = new dd.HtmlTemplate('{{ test }}'); - dd.tests.html.util.render(template, context); - }catch(e){ - t.is("Text should not exist outside of the root node in template", e.message); - found = true; - } - t.t(found); - - template = new dd.HtmlTemplate('<div></div>extra content'); - found = false; - try { - dd.tests.html.util.render(template); - }catch(e){ - t.is("Content should not exist outside of the root node in template", e.message); - found = true; - } - t.t(found); - - // More than one top-level node (except for blocks) - template = new dd.HtmlTemplate('<div></div><div></div>'); - found = false; - try { - dd.tests.html.util.render(template); - }catch(e){ - t.is("Content should not exist outside of the root node in template", e.message); - found = true; - } - t.t(found); - - // Logic block rules out any root node - template = new dd.HtmlTemplate('{% if missing %}<div></div>{% endif %}'); - found = false; - try { - dd.tests.html.util.render(template); - }catch(e){ - t.is("Rendered template does not have a root node", e.message); - found = true; - } - t.t(found); - }, - function test_structures(t){ - var dd = dojox.dtl; - - var context = new dd.Context({ - actions: ["ate", "picked"], - items: [ - { - name: "apple" - }, - { - name: "banana", - date: new Date(2007, 2, 16, 14, 30, 10) - }, - { - name: "orange", - date: new Date(2008, 0, 1, 12, 0, 0) - } - ] - }); - - var template = new dd.HtmlTemplate('<div><ul>I {% for action in actions %}{% if not forloop.first %}, {% endif %}{{action}}{% endfor %} the following:<ul>{% for item in items %}<li>{{ item.name }}{% if item.date %} at {{ item.date|date:"P" }}{% endif %}</li>{% endfor %}</ul></ul></div>'); - t.is('<div><ul>I ate, picked the following:<ul><li>apple</li><li>banana at 2:30 pm</li><li>orange at noon</li></ul></ul></div>', dd.tests.html.util.render(template, context)); - }, - function test_tag_extend(t){ - // Problems to look for: - // * Content outside of blocks - }, - function test_tag_for(t){ - var dd = dojox.dtl; - - var context = new dd.Context({ - items: ["apple", "banana", "lemon"] - }); - var template = new dd.HtmlTemplate('<div><ul>{% for item in items %}<li class="{{ item|length }}">{{ item }}</li>{% endfor %}</ul></div>'); - - t.is('<div><ul><li class="5">apple</li><li class="6">banana</li><li class="5">lemon</li></ul></div>', dd.tests.html.util.render(template, context)); - - // The line break is there to make sure our regex works - template = new dd.HtmlTemplate('<div><select>{% for item in items %}<option>{{ item }}</option>\n{% endfor %}</select></div>'); - - t.is('<div><select><option>apple</option><option>banana</option><option>lemon</option></select></div>', dd.tests.html.util.render(template, context)); - }, - function test_tag_if(t){ - var dd = dojox.dtl; - - var context = new dd.Context({key: true}); - var template = new dd.HtmlTemplate('{% if key %}<div>has key</div>{% else %}<div>no key</div>{% endif %}'); - t.is("<div>has key</div>", dd.tests.html.util.render(template, context)); - context.key = false; - t.is("<div>no key</div>", dd.tests.html.util.render(template, context)); - }, - function test_tag_ifchanged(t){ - var dd = dojox.dtl; - - var context = new dd.Context({ - year: 2008, - days: [ - new Date(2008, 0, 12), - new Date(2008, 0, 28), - new Date(2008, 1, 1), - new Date(2008, 1, 1), - new Date(2008, 1, 1) - ] - }); - - var template = new dd.HtmlTemplate("<div><h1>Archive for {{ year }}</h1>"+ -"{% for date in days %}"+ -'{% ifchanged %}<h3>Month: </h3><h3>{{ date|date:"F" }}</h3>{% endifchanged %}'+ -'<a href="{{ date|date:\'M/d\'|lower }}/">{{ date|date:\'j\' }}</a>'+ -"{% endfor %}</div>"); - - t.is('<div><h1>Archive for 2008</h1>'+ -'<h3>Month: </h3><h3>January</h3>'+ -'<a href="jan/12/">12</a>'+ -'<a href="jan/28/">28</a>'+ -'<h3>Month: </h3><h3>February</h3>'+ -'<a href="feb/01/">1</a>'+ -'<a href="feb/01/">1</a>'+ -'<a href="feb/01/">1</a></div>', dd.tests.html.util.render(template, context)); - - template = new dd.HtmlTemplate('<div>{% for date in days %}'+ -'{% ifchanged date.date %} {{ date.date }} {% endifchanged %}'+ -'{% ifchanged date.hour date.date %}'+ -'{{ date.hour }}'+ -'{% endifchanged %}'+ -'{% endfor %}</div>'); - t.is('<div> 2008-01-12 0 2008-01-28 0 2008-02-01 0</div>', dd.tests.html.util.render(template, context)); - }, - function test_tag_ifequal(t){ - var dd = dojox.dtl; - - var context = new dd.Context({ - items: [ - { name: "apple", color: "red" }, - { name: "banana", color: "yellow" }, - { name: "pear", color: "green" }, - { name: "kiwi", color: "brown" } - ], - edit_item: "banana" - }); - - var template = new dd.HtmlTemplate("<div><ul>{% for item in items %}<li>{{ item.name }}</li>{% endfor %}</ul></div>"); - t.is('<div><ul><li>apple</li><li>banana</li><li>pear</li><li>kiwi</li></ul></div>', dd.tests.html.util.render(template, context)); - - template = new dd.HtmlTemplate("<div><ul>{% for item in items %}<li><span>{{ item.name }}</span><br/><p>{{ item.color }}</p></li>{% endfor %}</ul></div>"); - t.is('<div><ul><li><span>apple</span><br/><p>red</p></li><li><span>banana</span><br/><p>yellow</p></li><li><span>pear</span><br/><p>green</p></li><li><span>kiwi</span><br/><p>brown</p></li></ul></div>', dd.tests.html.util.render(template, context)); - - template = new dd.HtmlTemplate("<div><ul>{% for item in items %}<li>{% ifequal item.name edit_item %}<label>Name: <input type='text' name='name' value=\"{{ item.name }}\"/></label><br/><label>Color: <textarea name='color'>{{ item.color }}</textarea></label>{% else %}<span>{{ item.name }}</span><br/><p>{{ item.color }}</p>{% endifequal %}</li>{% endfor %}</ul></div>"); - t.is('<div><ul><li><span>apple</span><br/><p>red</p></li><li><label>Name: <input type="text" name="name" value="banana"/></label><br/><label>Color: <textarea name="color">yellow</textarea></label></li><li><span>pear</span><br/><p>green</p></li><li><span>kiwi</span><br/><p>brown</p></li></ul></div>', dd.tests.html.util.render(template, context)); - - template = new dd.HtmlTemplate("<div><ul>{% for item in items %}<li>{% ifequal item.name edit_item %}<div><label>Name: <input type='text' name='name' value=\"{{ item.name }}\"/></label><br/><label>Color: <textarea name='color'>{{ item.color }}</textarea></label></div>{% else %}<div><span>{{ item.name }}</span><br/><p>{{ item.color }}</p></div>{% endifequal %}</li>{% endfor %}</ul></div>"); - t.is('<div><ul><li><div><span>apple</span><br/><p>red</p></div></li><li><div><label>Name: <input type="text" name="name" value="banana"/></label><br/><label>Color: <textarea name="color">yellow</textarea></label></div></li><li><div><span>pear</span><br/><p>green</p></div></li><li><div><span>kiwi</span><br/><p>brown</p></div></li></ul></div>', dd.tests.html.util.render(template, context)); - - template = new dd.HtmlTemplate("<div><ul>{% for item in items %}{% ifequal item.name edit_item %}<li><label>Name: <input type='text' name='name' value=\"{{ item.name }}\"/></label><br/><label>Color: <textarea name='color'>{{ item.color }}</textarea></label></li>{% else %}<li><span>{{ item.name }}</span><br/><p>{{ item.color }}</p></li>{% endifequal %}{% endfor %}</ul></div>"); - t.is('<div><ul><li><span>apple</span><br/><p>red</p></li><li><label>Name: <input type="text" name="name" value="banana"/></label><br/><label>Color: <textarea name="color">yellow</textarea></label></li><li><span>pear</span><br/><p>green</p></li><li><span>kiwi</span><br/><p>brown</p></li></ul></div>', dd.tests.html.util.render(template, context)); - }, - function test_tag_include(t){ - var dd = dojox.dtl; - - var context = new dd.Context({ - hello: dojo.moduleUrl("dojox.dtl.tests.templates", "hello.html"), - person: "Bob", - people: ["Charles", "Ralph", "Julia"] - }); - - var template = new dd.HtmlTemplate("<div>{% include hello %}</div>"); - t.is("<div>Hello, <span>Bob</span></div>", dd.tests.html.util.render(template, context)); - - template = new dd.HtmlTemplate('<div>{% include "../../dojox/dtl/tests/templates/hello.html" %}</div>'); - t.is("<div>Hello, <span>Bob</span></div>", dd.tests.html.util.render(template, context)); - - template = new dd.HtmlTemplate('<div>{% for person in people %}<div class="include">{% include hello %} </div>{% endfor %}</div>'); - t.is('<div><div class="include">Hello, <span>Charles</span> </div><div class="include">Hello, <span>Ralph</span> </div><div class="include">Hello, <span>Julia</span> </div></div>', dd.tests.html.util.render(template, context)); - }, - function test_tag_spaceless(t){ - var dd = dojox.dtl; - - var template = new dd.HtmlTemplate("{% spaceless %}<ul> \n <li>Hot</li> \n\n<li>Pocket </li>\n </ul>{% endspaceless %}"); - t.is("<ul><li>Hot</li><li>Pocket </li></ul>", dd.tests.html.util.render(template)); - }, - function test_tag_ssi(t){ - var dd = dojox.dtl; - - var context = new dd.Context({ - hello: dojo.moduleUrl("dojox.dtl.tests.templates", "hello.html"), - person: "Bob", - people: ["Charles", "Ralph", "Julia"] - }); - - var template = new dd.HtmlTemplate("<div>{% ssi hello parsed %}</div>"); - t.is("<div>Hello, <span>Bob</span></div>", dd.tests.html.util.render(template, context)); - - template = new dd.HtmlTemplate("<div>{% ssi hello %}</div>"); - t.is("<div>Hello, <span>{{ person }}</span></div>", dd.tests.html.util.render(template, context)); - - template = new dd.HtmlTemplate('<div>{% ssi "../../dojox/dtl/tests/templates/hello.html" parsed %}</div>'); - t.is("<div>Hello, <span>Bob</span></div>", dd.tests.html.util.render(template, context)); - - template = new dd.HtmlTemplate('<div>{% for person in people %}{% ssi hello parsed %} {% endfor %}</div>'); - t.is("<div>Hello, <span>Charles</span> Hello, <span>Ralph</span> Hello, <span>Julia</span> </div>", dd.tests.html.util.render(template, context)); - } - ] -); - -} diff --git a/includes/js/dojox/dtl/tests/html/util.js b/includes/js/dojox/dtl/tests/html/util.js deleted file mode 100644 index b4efe5a..0000000 --- a/includes/js/dojox/dtl/tests/html/util.js +++ /dev/null @@ -1,160 +0,0 @@ -if(!dojo._hasResource["dojox.dtl.tests.html.util"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojox.dtl.tests.html.util"] = true; -dojo.provide("dojox.dtl.tests.html.util"); - -dojo.require("dojox.dtl.html"); -dojo.require("dojox.dtl.render.html"); -dojo.require("dojox.string.Builder"); - -dojox.dtl.HtmlBuffer.prototype.onClone = function(from, to){ - var clones = this._clones = this._clones || []; - - for(var i = 0, group; group = clones[i]; i++){ - for(var j = 0, item; item = group[j]; j++){ - if(item === from){ - group.push(to); - return - }else if(item === to){ - group.push(from); - return; - } - } - } - - clones.push([from, to]); -} -dojox.dtl.HtmlBuffer.prototype.onAddEvent = function(node, type, description){ - var events = this._events = this._events || []; - - var found = false; - for(var i = 0, evt; evt = events[i]; i++){ - if(evt[0] === node){ - found = true; - evt[1] = type; - evt[2] = description; - } - } - - if(!found){ - events.push([node, type, description]); - } -} - -dojox.dtl.tests.html.util.render = function(/*HtmlTemplate*/ template, /*Context*/ context) { - try { - var div = document.createElement("div"); - dojo.style(div, "visibility", "hidden"); - var attach = document.createElement("div"); - div.appendChild(attach); - dojo.body().appendChild(div); - - var buffer = template.getBuffer(); - var canvas = new dojox.dtl.render.html.Render(attach, template); - canvas.render(context, template, buffer); - var clones = buffer._clones; - var events = buffer._events; - - var first = dojox.dtl.tests.html.util.serialize(canvas.domNode, template.tokens, clones, events).toString(); - - buffer = template.getBuffer(); - buffer._clones = clones; - buffer._events = events; - canvas.render(context, template, buffer); - - var second = dojox.dtl.tests.html.util.serialize(canvas.domNode, template.tokens, clones, events).toString(); - - doh.is("Compare re-render: " + first, "Compare re-render: " + second); - return first; - } - catch(e){ - throw e; - }finally{ - div.parentNode.removeChild(div); - } -} - -dojox.dtl.tests.html.util.serialize = function(node, tokens, clones, events, output) { - var types = dojox.dtl.html.types; - clones = clones || []; - events = events || []; - - if (node.nodeType == 3) { - output.append(node.nodeValue); - }else{ - var name = node.nodeName.toLowerCase(); - - if (!output) { - output = new dojox.string.Builder(); - } - output.append("<").append(name); - - var attributes = dojo.filter(tokens, function(token){ - if(token[0] == types.attr){ - for(var i = 0, group; group = clones[i]; i++){ - // group is any set of nodes that were originally the sam - var count = 0; - for(var j = 0, item; item = group[j]; j++){ - if(item === token[1] || item === node){ - if(count++){ - // This is entered when we have 2 hits within a clone group. - // The first would be the original node - // The second would be if our current node is a clone - // of the original - return true; - } - } - } - } - } - }); - - for(var i = 0, attribute; attribute = attributes[i]; i++){ - var value = ""; - if(attribute[2] == "class"){ - value = node.className || value; - }else if(attribute[2] == "for"){ - value = node.htmlFor || value; - }else if(node.getAttribute){ - value = node.getAttribute(attribute[2], 2) || value; - if(dojo.isIE && (attribute[2] == "href" || attribute[2] == "src")){ - if(dojo.isIE){ - var hash = location.href.lastIndexOf(location.hash); - var href = location.href.substring(0, hash).split("/"); - href.pop(); - href = href.join("/") + "/"; - if(value.indexOf(href) == 0){ - value = value.replace(href, ""); - } - value = decodeURIComponent(value); - } - } - } - if(value){ - output.append(" ").append(attribute[2]).append('="').append(value.replace(/"/g, '\\"')).append('"'); - } - } - - // Deal with events - if(events){ - for(var i = 0, evt; evt = events[i]; i++){ - if(evt[0] === node){ - output.append(" ").append(evt[1]).append('="').append(evt[2]).append('"'); - } - } - } - - if(!node.childNodes.length){ - output.append("/>"); - }else{ - output.append(">"); - dojo.forEach(node.childNodes, function(node){ - dojox.dtl.tests.html.util.serialize(node, tokens, clones, events, output); - }); - output.append("</").append(name).append(">"); - } - - return output; - } -} - -} |