From e44a7e37b6c7b5961adaffc62b9042b8d442938e Mon Sep 17 00:00:00 2001 From: mensonge Date: Thu, 13 Nov 2008 09:49:11 +0000 Subject: New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f --- includes/js/dojox/dtl/Context.js | 87 + includes/js/dojox/dtl/README | 207 + includes/js/dojox/dtl/_HtmlTemplated.js | 72 + includes/js/dojox/dtl/_Templated.js | 93 + includes/js/dojox/dtl/_base.js | 570 +++ includes/js/dojox/dtl/contrib/data.js | 89 + includes/js/dojox/dtl/contrib/dijit.js | 220 ++ includes/js/dojox/dtl/contrib/html.js | 107 + includes/js/dojox/dtl/contrib/objects.js | 15 + includes/js/dojox/dtl/demos/demo_Animation.html | 45 + includes/js/dojox/dtl/demos/demo_Blog.html | 96 + includes/js/dojox/dtl/demos/demo_Data.html | 58 + includes/js/dojox/dtl/demos/demo_Dijitless.html | 50 + includes/js/dojox/dtl/demos/demo_Events.html | 46 + .../js/dojox/dtl/demos/demo_HtmlTemplated.html | 40 + includes/js/dojox/dtl/demos/demo_Inline.html | 48 + includes/js/dojox/dtl/demos/demo_NodeList.html | 37 + includes/js/dojox/dtl/demos/demo_Table.html | 4072 ++++++++++++++++++++ includes/js/dojox/dtl/demos/demo_Templated.html | 36 + includes/js/dojox/dtl/demos/demo_Tree.html | 33 + .../js/dojox/dtl/demos/json/blog/get_blog_1.json | 1 + .../js/dojox/dtl/demos/json/blog/get_blog_3.json | 1 + .../dojox/dtl/demos/json/blog/get_blog_list.json | 1 + .../dojox/dtl/demos/json/blog/get_page_about.json | 1 + includes/js/dojox/dtl/demos/json/fruit.json | 1 + includes/js/dojox/dtl/demos/json/morefruit.json | 1 + .../js/dojox/dtl/demos/templates/animation.html | 5 + .../js/dojox/dtl/demos/templates/blog_base.html | 8 + .../js/dojox/dtl/demos/templates/blog_detail.html | 10 + .../js/dojox/dtl/demos/templates/blog_list.html | 9 + .../js/dojox/dtl/demos/templates/blog_page.html | 7 + .../dojox/dtl/demos/templates/countrychildren.html | 1 + includes/js/dojox/dtl/demos/templates/gallery.html | 16 + .../js/dojox/dtl/demos/templates/nodelist.html | 5 + includes/js/dojox/dtl/ext-dojo/NodeList.js | 33 + includes/js/dojox/dtl/filter/dates.js | 54 + includes/js/dojox/dtl/filter/htmlstrings.js | 59 + includes/js/dojox/dtl/filter/integers.js | 32 + includes/js/dojox/dtl/filter/lists.js | 137 + includes/js/dojox/dtl/filter/logic.js | 34 + includes/js/dojox/dtl/filter/misc.js | 59 + includes/js/dojox/dtl/filter/strings.js | 327 ++ includes/js/dojox/dtl/html.js | 818 ++++ includes/js/dojox/dtl/render/html.js | 76 + includes/js/dojox/dtl/tag/date.js | 29 + includes/js/dojox/dtl/tag/loader.js | 277 ++ includes/js/dojox/dtl/tag/logic.js | 272 ++ includes/js/dojox/dtl/tag/loop.js | 196 + includes/js/dojox/dtl/tag/misc.js | 291 ++ includes/js/dojox/dtl/tests/context.js | 79 + .../js/dojox/dtl/tests/demo_Templated_Jaxer.html | 87 + includes/js/dojox/dtl/tests/html/buffer.js | 35 + includes/js/dojox/dtl/tests/html/tag.js | 233 ++ includes/js/dojox/dtl/tests/html/util.js | 160 + includes/js/dojox/dtl/tests/module.js | 15 + includes/js/dojox/dtl/tests/runTests.html | 9 + includes/js/dojox/dtl/tests/templates/hello.html | 1 + includes/js/dojox/dtl/tests/templates/pocket.html | 1 + includes/js/dojox/dtl/tests/templates/pocket2.html | 1 + includes/js/dojox/dtl/tests/text/filter.js | 740 ++++ includes/js/dojox/dtl/tests/text/load.js | 6 + includes/js/dojox/dtl/tests/text/tag.js | 480 +++ includes/js/dojox/dtl/utils/date.js | 72 + 63 files changed, 10701 insertions(+) create mode 100644 includes/js/dojox/dtl/Context.js create mode 100644 includes/js/dojox/dtl/README create mode 100644 includes/js/dojox/dtl/_HtmlTemplated.js create mode 100644 includes/js/dojox/dtl/_Templated.js create mode 100644 includes/js/dojox/dtl/_base.js create mode 100644 includes/js/dojox/dtl/contrib/data.js create mode 100644 includes/js/dojox/dtl/contrib/dijit.js create mode 100644 includes/js/dojox/dtl/contrib/html.js create mode 100644 includes/js/dojox/dtl/contrib/objects.js create mode 100644 includes/js/dojox/dtl/demos/demo_Animation.html create mode 100644 includes/js/dojox/dtl/demos/demo_Blog.html create mode 100644 includes/js/dojox/dtl/demos/demo_Data.html create mode 100644 includes/js/dojox/dtl/demos/demo_Dijitless.html create mode 100644 includes/js/dojox/dtl/demos/demo_Events.html create mode 100644 includes/js/dojox/dtl/demos/demo_HtmlTemplated.html create mode 100644 includes/js/dojox/dtl/demos/demo_Inline.html create mode 100644 includes/js/dojox/dtl/demos/demo_NodeList.html create mode 100644 includes/js/dojox/dtl/demos/demo_Table.html create mode 100644 includes/js/dojox/dtl/demos/demo_Templated.html create mode 100644 includes/js/dojox/dtl/demos/demo_Tree.html create mode 100644 includes/js/dojox/dtl/demos/json/blog/get_blog_1.json create mode 100644 includes/js/dojox/dtl/demos/json/blog/get_blog_3.json create mode 100644 includes/js/dojox/dtl/demos/json/blog/get_blog_list.json create mode 100644 includes/js/dojox/dtl/demos/json/blog/get_page_about.json create mode 100644 includes/js/dojox/dtl/demos/json/fruit.json create mode 100644 includes/js/dojox/dtl/demos/json/morefruit.json create mode 100644 includes/js/dojox/dtl/demos/templates/animation.html create mode 100644 includes/js/dojox/dtl/demos/templates/blog_base.html create mode 100644 includes/js/dojox/dtl/demos/templates/blog_detail.html create mode 100644 includes/js/dojox/dtl/demos/templates/blog_list.html create mode 100644 includes/js/dojox/dtl/demos/templates/blog_page.html create mode 100644 includes/js/dojox/dtl/demos/templates/countrychildren.html create mode 100644 includes/js/dojox/dtl/demos/templates/gallery.html create mode 100644 includes/js/dojox/dtl/demos/templates/nodelist.html create mode 100644 includes/js/dojox/dtl/ext-dojo/NodeList.js create mode 100644 includes/js/dojox/dtl/filter/dates.js create mode 100644 includes/js/dojox/dtl/filter/htmlstrings.js create mode 100644 includes/js/dojox/dtl/filter/integers.js create mode 100644 includes/js/dojox/dtl/filter/lists.js create mode 100644 includes/js/dojox/dtl/filter/logic.js create mode 100644 includes/js/dojox/dtl/filter/misc.js create mode 100644 includes/js/dojox/dtl/filter/strings.js create mode 100644 includes/js/dojox/dtl/html.js create mode 100644 includes/js/dojox/dtl/render/html.js create mode 100644 includes/js/dojox/dtl/tag/date.js create mode 100644 includes/js/dojox/dtl/tag/loader.js create mode 100644 includes/js/dojox/dtl/tag/logic.js create mode 100644 includes/js/dojox/dtl/tag/loop.js create mode 100644 includes/js/dojox/dtl/tag/misc.js create mode 100644 includes/js/dojox/dtl/tests/context.js create mode 100644 includes/js/dojox/dtl/tests/demo_Templated_Jaxer.html create mode 100644 includes/js/dojox/dtl/tests/html/buffer.js create mode 100644 includes/js/dojox/dtl/tests/html/tag.js create mode 100644 includes/js/dojox/dtl/tests/html/util.js create mode 100644 includes/js/dojox/dtl/tests/module.js create mode 100644 includes/js/dojox/dtl/tests/runTests.html create mode 100644 includes/js/dojox/dtl/tests/templates/hello.html create mode 100644 includes/js/dojox/dtl/tests/templates/pocket.html create mode 100644 includes/js/dojox/dtl/tests/templates/pocket2.html create mode 100644 includes/js/dojox/dtl/tests/text/filter.js create mode 100644 includes/js/dojox/dtl/tests/text/load.js create mode 100644 includes/js/dojox/dtl/tests/text/tag.js create mode 100644 includes/js/dojox/dtl/utils/date.js (limited to 'includes/js/dojox/dtl') diff --git a/includes/js/dojox/dtl/Context.js b/includes/js/dojox/dtl/Context.js new file mode 100644 index 0000000..f608506 --- /dev/null +++ b/includes/js/dojox/dtl/Context.js @@ -0,0 +1,87 @@ +if(!dojo._hasResource["dojox.dtl.Context"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.dtl.Context"] = true; +dojo.provide("dojox.dtl.Context"); +dojo.require("dojox.dtl._base"); + +dojox.dtl.Context = dojo.extend(function(dict){ + this._this = {}; + dojox.dtl._Context.call(this, dict); +}, dojox.dtl._Context.prototype, +{ + extend: function(/*dojox.dtl.Context|Object*/ obj){ + // summary: Returns a clone of this context object, with the items from the + // passed objecct mixed in. + var context = new dojox.dtl.Context(); + var keys = this.getKeys(); + var i, key; + for(i = 0; key = keys[i]; i++){ + if(typeof obj[key] != "undefined"){ + context[key] = obj[key]; + }else{ + context[key] = this[key]; + } + } + + if(obj instanceof dojox.dtl.Context){ + keys = obj.getKeys(); + }else if(typeof obj == "object"){ + keys = []; + for(key in obj){ + keys.push(key); + } + } + + for(i = 0; key = keys[i]; i++){ + context[key] = obj[key]; + } + + return context; + }, + filter: function(/*dojox.dtl.Context|Object|String...*/ filter){ + // summary: Returns a clone of this context, only containing the items + // defined in the filter. + var context = new dojox.dtl.Context(); + var keys = []; + var i, arg; + if(filter instanceof dojox.dtl.Context){ + keys = filter.getKeys(); + }else if(typeof filter == "object"){ + for(var key in filter){ + keys.push(key); + } + }else{ + for(i = 0; arg = arguments[i]; i++){ + if(typeof arg == "string"){ + keys.push(arg); + } + } + } + + for(i = 0, key; key = keys[i]; i++){ + context[key] = this[key]; + } + + return context; + }, + setThis: function(/*Object*/ _this){ + this._this = _this; + }, + getThis: function(){ + return this._this; + }, + hasKey: function(key){ + if(typeof this[key] != "undefined"){ + return true; + } + + for(var i = 0, dict; dict = this._dicts[i]; i++){ + if(typeof dict[key] != "undefined"){ + return true; + } + } + + return false; + } +}); + +} diff --git a/includes/js/dojox/dtl/README b/includes/js/dojox/dtl/README new file mode 100644 index 0000000..a6cc8c3 --- /dev/null +++ b/includes/js/dojox/dtl/README @@ -0,0 +1,207 @@ +------------------------------------------------------------------------------- +DojoX Django Template Language +------------------------------------------------------------------------------- +Version 0.0 +Release date: 09/20/2007 +------------------------------------------------------------------------------- +Project state: experimental/feature incomplete +------------------------------------------------------------------------------- +Project authors + Neil Roberts (pottedmeat@dojotoolkit.org) +------------------------------------------------------------------------------- +Project description + +The Django Template language uses a system of templates that can be compiled +once and rendered indefinitely afterwards. It uses a simple system of tags +and filters. + +This is a 1:1 match with the Django Template Language as outlined in +http://www.djangoproject.com/documentation/templates/. All applicable tags and +filters have been implemented (see below), along with new filters and tags as +necessary (see below). + +The Django Template Language is intended within Django to only handle text. +Our implementation is able to handle HTML in addition to text. Actually, the +text and HTML portions of dojox.dtl are two separate layers, the HTML layer +sits on top of the text layer (base). It's also been implemented in such a way +that you have little to fear when moving your code from Django to dojox.dtl. +Your existing templates should work, and will benefit from the massive +performance gain of being able to manipulate nodes, rather than having to do +clunky innerHTML swaps you would have to do with a text-only system. It also +allows for new HTML-centric abilities, outlined below. + +Despite having two levels of complexity, if you write your tags correctly, they +will work in both environments. +------------------------------------------------------------------------------- +Dependencies + +Base: +dojox.string.Builder + +Date filters and tags: +dojox.date.php + +Widget: +dijit._Widget +dijit._Container +------------------------------------------------------------------------------- +Installation instructions + +Grab the following from the Dojo SVN Repository: +http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/dtl.js +http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/dtl/* + +Install into the following directory structure: +/dojox/dtl/ + +...which should be at the same level as your Dojo checkout. +------------------------------------------------------------------------------- +What's Been Done + +Note: HTML Unit Tests should only be around for the oddities of HTML, tag/filter +code is the same for each environment with minor exceptions. Cloning of all tags +should be tested inside a for loop. + +| Implemented | Tag | Text Unit Test | HTML Unit Test | +| X | block | X | | +| X | comment | X | | +| X | cycle | X | | +| X | debug | X | | +| X | extends | X | | +| X | filter | X | | +| X | firstof | X | | +| X | for | X | | +| X | if | X | | +| X | ifchanged | X | X | +| X | ifequal | X | | +| X | ifnotequal | X | | +| X | include | X | X | +| X | load | X | | +| X | now | X | | +| X | regroup | X | | +| X | spaceless | X | X | +| X | ssi | X | X | +| X | templatetag | X | | +| N/A | url | | | +| X | widthratio | X | | +| X | with | X | | + +| Implemented | Filter | Text Unit Test | HTML Unit Test | +| X | add | X | | +| X | addslashes | X | | +| X | capfirst | X | | +| X | center | X | | +| X | cut | X | | +| X | date | X | | +| X | default | X | | +| X | default_if_none | X | | +| X | dictsort | X | | +| X | dictsort_reversed | X | | +| X | divisibleby | X | | +| X | escape | X | | +| X | filesizeformat | X | | +| X | first | X | | +| X | fix_ampersands | X | | +| X | floatformat | X | | +| X | get_digit | X | | +| X | iriencode | X | | +| X | join | X | | +| X | length | X | | +| X | length_is | X | | +| X | linebreaks | X | | +| X | linebreaksbr | X | | +| X | linenumbers | X | | +| X | ljust | X | | +| X | lower | X | | +| X | make_list | X | | +| X | phone2numeric | X | | +| X | pluralize | X | | +| X | pprint | X | | +| X | random | X | | +| X | removetags | X | | +| X | rjust | X | | +| X | slice | X | | +| X | slugify | X | | +| X | stringformat | X | | +| X | striptags | X | | +| X | time | X | | +| X | timesince | X | | +| X | timeuntil | X | | +| X | title | X | | +| X | truncatewords | X | | +| X | truncatewords_html | X | | +| X | unordered_list | X | | +| X | upper | X | | +| X | urlencode | X | | +| X | urlize | X | | +| X | urlizetrunc | X | | +| X | wordcount | X | | +| X | wordwrap | X | | +| X | yesno | X | | +------------------------------------------------------------------------------- +HTML-Specific Additions +------------------------------------------------------------------------------- +{%extends "shared:templates/template.html" %} + +When using the {% extends %} tag, we don't always want to replace the parent +node in DOM. For example, if we have a list view and a detail view, but both +share the same base template, we want it to share the parent template. This +basically means that the same nodes will be used in the parent for both views. + +To use this, simply add "shared:" to the beginning of the specified template. +------------------------------------------------------------------------------- + + +Some browsers treat comment nodes as full fledged nodes. If performance is +important to you, you can wrap your markup in comments. The comments will be +automatically stripped for browsers that cannot support this. +------------------------------------------------------------------------------- +Attribute Tags + +If a tag name begins with "attr:" then it will be able to inject an object +into the parsed template. (See dojox.dtl.tag.event.EventNode) + +onclick/onmouseover/etc attributes work by attaching to the rendering object. + +tstyle attribute allows for styles to be changed dynamically. Use them just +like a "style" attribute. + +attach attribute attaches the node to the rendering object. +------------------------------------------------------------------------------- +New Context Functions + +setThis() and getThis() returns the object "in charge" of the current rendering. +This is used so that we can attach events. + +mixin() and filter() clone the current context, and either add to or reduce +the keys in the context. +------------------------------------------------------------------------------- +Buffers + +Both the base and HTML versions of dojox.dtl use buffers. The base version uses +dojox.string.Builder and the HTML version uses dojox.dtl.HtmlBuffer. + +The HTML buffer has several calls important to rendering: + +setParent/getParent/concat/remove: + +setParent and concat are used in order to render our HTML. As we move through +the parsed template, different nodes change the parent or add on to the +current parent. getParent is useful in things like the attribute tags, since +they can use getParent to find the node that they're an attribute on. remove is +used during unrendering. + +setAttribute: + +Sets an attribute on the current parent +------------------------------------------------------------------------------- +Tags Need clone/unrender Functions. + +One of the biggest challenges of getting dojox.dtl to work in an HTML +environment was logic blocks. Nodes and objects inside a for loop need to be +cloned, they can't simply be re-rendered, especially if they involve a Node. +Also, in the case of an if/else block, we need to be able to not just render +one of the blocks, but also unrender the second. + +This is really simple code, a good example is the dojox.dtl.HtmlNode +object. Each function in this object is only one line long. \ No newline at end of file diff --git a/includes/js/dojox/dtl/_HtmlTemplated.js b/includes/js/dojox/dtl/_HtmlTemplated.js new file mode 100644 index 0000000..8947a8d --- /dev/null +++ b/includes/js/dojox/dtl/_HtmlTemplated.js @@ -0,0 +1,72 @@ +if(!dojo._hasResource["dojox.dtl._HtmlTemplated"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.dtl._HtmlTemplated"] = true; +dojo.provide("dojox.dtl._HtmlTemplated"); +dojo.require("dijit._Templated"); +dojo.require("dojox.dtl.html"); +dojo.require("dojox.dtl.render.html"); +dojo.require("dojox.dtl.contrib.dijit"); + +dojox.dtl._HtmlTemplated = { + prototype: { + _dijitTemplateCompat: false, + buildRendering: function(){ + this.domNode = this.srcNodeRef; + + if(!this._render){ + var ddcd = dojox.dtl.contrib.dijit; + var old = ddcd.widgetsInTemplate; + ddcd.widgetsInTemplate = this.widgetsInTemplate; + this._template = this._getCachedTemplate(this.templatePath, this.templateString); + this._render = new dojox.dtl.render.html.Render(this.domNode, this._template); + ddcd.widgetsInTemplate = old; + } + + var self = this; + this._rendering = setTimeout(function(){ self.render(); }, 10); + }, + setTemplate: function(/*String|dojo._Url*/ template, /*dojox.dtl.Context?*/ context){ + // summary: + // Quickly switch between templated by location + if(dojox.dtl.text._isTemplate(template)){ + this._template = this._getCachedTemplate(null, template); + }else{ + this._template = this._getCachedTemplate(template); + } + this.render(context); + }, + render: function(/*dojox.dtl.Context?*/ context){ + if(this._rendering){ + clearTimeout(this._rendering); + delete this._rendering; + } + this._render.render(this._getContext(context)); + }, + _getContext: function(context){ + if (!(context instanceof dojox.dtl.Context)) { + context = false; + } + context = context || new dojox.dtl.Context(this); + context.setThis(this); + return context; + }, + _getCachedTemplate: function(templatePath, templateString){ + if(!this._templates){ + this._templates = {}; + } + var key = templateString || templatePath.toString(); + var tmplts = this._templates; + if(tmplts[key]){ + return tmplts[key]; + } + return (tmplts[key] = new dojox.dtl.HtmlTemplate( + dijit._Templated.getCachedTemplate( + templatePath, + templateString, + true + ) + )); + } + } +}; + +} diff --git a/includes/js/dojox/dtl/_Templated.js b/includes/js/dojox/dtl/_Templated.js new file mode 100644 index 0000000..1472fe9 --- /dev/null +++ b/includes/js/dojox/dtl/_Templated.js @@ -0,0 +1,93 @@ +if(!dojo._hasResource["dojox.dtl._Templated"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.dtl._Templated"] = true; +dojo.provide("dojox.dtl._Templated"); +dojo.require("dijit._Templated"); +dojo.require("dojox.dtl._base"); + +dojo.declare("dojox.dtl._Templated", dijit._Templated, { + _dijitTemplateCompat: false, + buildRendering: function(){ + var node; + + if(this.domNode && !this._template){ + return; + } + + if(!this._template){ + var t = this.getCachedTemplate( + this.templatePath, + this.templateString, + this._skipNodeCache + ); + if(t instanceof dojox.dtl.Template) { + this._template = t; + }else{ + node = t; + } + } + if(!node){ + var nodes = dijit._Templated._createNodesFromText( + this._template.render(new dojox.dtl._Context(this)) + ); + for(var i = 0; i < nodes.length; i++){ + if(nodes[i].nodeType == 1){ + node = nodes[i]; + break; + } + } + } + + this._attachTemplateNodes(node); + + var source = this.srcNodeRef; + if(source && source.parentNode){ + source.parentNode.replaceChild(node, source); + } + + if(this.widgetsInTemplate){ + var childWidgets = dojo.parser.parse(node); + this._attachTemplateNodes(childWidgets, function(n,p){ + return n[p]; + }); + } + + if(this.domNode){ + dojo.place(node, this.domNode, "before"); + this.destroyDescendants(); + dojo._destroyElement(this.domNode); + } + this.domNode = node; + + this._fillContent(source); + }, + _templateCache: {}, + getCachedTemplate: function(templatePath, templateString, alwaysUseString){ + // summary: + // Layer for dijit._Templated.getCachedTemplate + var tmplts = this._templateCache; + var key = templateString || templatePath; + if(tmplts[key]){ + return tmplts[key]; + } + + templateString = dojo.string.trim(templateString || dijit._Templated._sanitizeTemplateString(dojo._getText(templatePath))); + + if( this._dijitTemplateCompat && + (alwaysUseString || templateString.match(/\$\{([^\}]+)\}/g)) + ){ + templateString = this._stringRepl(templateString); + } + + // If we always use a string, or find no variables, just store it as a node + if(alwaysUseString || !templateString.match(/\{[{%]([^\}]+)[%}]\}/g)){ + return (tmplts[key] = dijit._Templated._createNodesFromText(templateString)[0]); + }else{ + return (tmplts[key] = new dojox.dtl.Template(templateString)); + } + }, + render: function(){ + this.buildRendering(); + } +}); + +} diff --git a/includes/js/dojox/dtl/_base.js b/includes/js/dojox/dtl/_base.js new file mode 100644 index 0000000..f42f245 --- /dev/null +++ b/includes/js/dojox/dtl/_base.js @@ -0,0 +1,570 @@ +if(!dojo._hasResource["dojox.dtl._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.dtl._base"] = true; +dojo.provide("dojox.dtl._base"); + +dojo.require("dojox.string.Builder"); +dojo.require("dojox.string.tokenize"); + +(function(){ + var dd = dojox.dtl; + + dd._Context = dojo.extend(function(dict){ + // summary: Pass one of these when rendering a template to tell the template what values to use. + dojo.mixin(this, dict || {}); + this._dicts = []; + }, + { + push: function(){ + var dict = {}; + var keys = this.getKeys(); + for(var i = 0, key; key = keys[i]; i++){ + dict[key] = this[key]; + delete this[key]; + } + this._dicts.unshift(dict); + }, + pop: function(){ + if(!this._dicts.length){ + throw new Error("pop() called on empty Context"); + } + var dict = this._dicts.shift(); + dojo.mixin(this, dict); + }, + getKeys: function(){ + var keys = []; + for(var key in this){ + if(this.hasOwnProperty(key) && key != "_dicts" && key != "_this"){ + keys.push(key); + } + } + return keys; + }, + get: function(key, otherwise){ + if(typeof this[key] != "undefined"){ + return this._normalize(this[key]); + } + + for(var i = 0, dict; dict = this._dicts[i]; i++){ + if(typeof dict[key] != "undefined"){ + return this._normalize(dict[key]); + } + } + + return otherwise; + }, + _normalize: function(value){ + if(value instanceof Date){ + value.year = value.getFullYear(); + value.month = value.getMonth() + 1; + value.day = value.getDate(); + value.date = value.year + "-" + ("0" + value.month).slice(-2) + "-" + ("0" + value.day).slice(-2); + value.hour = value.getHours(); + value.minute = value.getMinutes(); + value.second = value.getSeconds(); + value.microsecond = value.getMilliseconds(); + } + return value; + }, + update: function(dict){ + this.push(); + if(dict){ + dojo.mixin(this, dict); + } + } + }); + + var ddt = dd.text = { + types: {tag: -1, varr: -2, text: 3}, + pySplit: function(str){ + // summary: Split a string according to Python's split function + str = dojo.trim(str); + return (!str.length) ? [] : str.split(/\s+/g); + }, + _get: function(module, name, errorless){ + // summary: Used to find both tags and filters + var params = dd.register.get(module, name.toLowerCase(), errorless); + if(!params){ + if(!errorless){ + throw new Error("No tag found for " + name); + } + return null; + } + + var fn = params[1]; + var require = params[2]; + + var parts; + if(fn.indexOf(":") != -1){ + parts = fn.split(":"); + fn = parts.pop(); + } + + dojo["require"](require); + + var parent = dojo.getObject(require); + + return parent[fn || name] || parent[name + "_"]; + }, + getTag: function(name, errorless){ + return ddt._get("tag", name, errorless); + }, + getFilter: function(name, errorless){ + return ddt._get("filter", name, errorless); + }, + getTemplate: function(file){ + return new dd.Template(dd.getTemplateString(file)); + }, + getTemplateString: function(file){ + return dojo._getText(file.toString()) || ""; + }, + _resolveLazy: function(location, sync, json){ + if(sync){ + if(json){ + return dojo.fromJson(dojo._getText(location)) || {}; + }else{ + return dd.text.getTemplateString(location); + } + }else{ + return dojo.xhrGet({ + handleAs: (json) ? "json" : "text", + url: location + }); + } + }, + _resolveTemplateArg: function(arg, sync){ + if(ddt._isTemplate(arg)){ + if(!sync){ + var d = new dojo.Deferred(); + d.callback(arg); + return d; + } + return arg; + } + return ddt._resolveLazy(arg, sync); + }, + _isTemplate: function(arg){ + return (typeof arg == "undefined") || (dojo.isString(arg) && (arg.match(/^\s*[<{]/) || arg.indexOf(" ") != -1)); + }, + _resolveContextArg: function(arg, sync){ + if(arg.constructor == Object){ + if(!sync){ + var d = new dojo.Deferred; + d.callback(arg); + return d; + } + return arg; + } + return ddt._resolveLazy(arg, sync, true); + }, + _re: /(?:\{\{\s*(.+?)\s*\}\}|\{%\s*(load\s*)?(.+?)\s*%\})/g, + tokenize: function(str){ + return dojox.string.tokenize(str, ddt._re, ddt._parseDelims); + }, + _parseDelims: function(varr, load, tag){ + var types = ddt.types; + if(varr){ + return [types.varr, varr]; + }else if(load){ + var parts = dd.text.pySplit(tag); + for(var i = 0, part; part = parts[i]; i++){ + dojo["require"](part); + } + }else{ + return [types.tag, tag]; + } + } + } + + dd.Template = dojo.extend(function(/*String|dojo._Url*/ template){ + // template: + // The string or location of the string to + // use as a template + var str = ddt._resolveTemplateArg(template, true) || ""; + var tokens = ddt.tokenize(str); + var parser = new dd._Parser(tokens); + this.nodelist = parser.parse(); + }, + { + update: function(node, context){ + // node: DOMNode|String|dojo.NodeList + // A node reference or set of nodes + // context: dojo._Url|String|Object + // The context object or location + return ddt._resolveContextArg(context).addCallback(this, function(contextObject){ + var content = this.render(new dd._Context(contextObject)); + if(node.forEach){ + node.forEach(function(item){ + item.innerHTML = content; + }); + }else{ + dojo.byId(node).innerHTML = content; + } + return this; + }); + }, + render: function(context, /*concatenatable?*/ buffer){ + buffer = buffer || this.getBuffer(); + context = context || new dd._Context({}); + return this.nodelist.render(context, buffer) + ""; + }, + getBuffer: function(){ + dojo.require("dojox.string.Builder"); + return new dojox.string.Builder(); + } + }); + + dd._Filter = dojo.extend(function(token){ + // summary: Uses a string to find (and manipulate) a variable + if(!token) throw new Error("Filter must be called with variable name"); + this.contents = token; + + var cache = this._cache[token]; + if(cache){ + this.key = cache[0]; + this.filters = cache[1]; + }else{ + this.filters = []; + dojox.string.tokenize(token, this._re, this._tokenize, this); + this._cache[token] = [this.key, this.filters]; + } + }, + { + _cache: {}, + _re: /(?:^_\("([^\\"]*(?:\\.[^\\"])*)"\)|^"([^\\"]*(?:\\.[^\\"]*)*)"|^([a-zA-Z0-9_.]+)|\|(\w+)(?::(?:_\("([^\\"]*(?:\\.[^\\"])*)"\)|"([^\\"]*(?:\\.[^\\"]*)*)"|([a-zA-Z0-9_.]+)|'([^\\']*(?:\\.[^\\']*)*)'))?|^'([^\\']*(?:\\.[^\\']*)*)')/g, + _values: { + 0: '"', // _("text") + 1: '"', // "text" + 2: "", // variable + 8: '"' // 'text' + }, + _args: { + 4: '"', // :_("text") + 5: '"', // :"text" + 6: "", // :variable + 7: "'"// :'text' + }, + _tokenize: function(){ + var pos, arg; + + for(var i = 0, has = []; i < arguments.length; i++){ + has[i] = (typeof arguments[i] != "undefined" && dojo.isString(arguments[i]) && arguments[i]); + } + + if(!this.key){ + for(pos in this._values){ + if(has[pos]){ + this.key = this._values[pos] + arguments[pos] + this._values[pos]; + break; + } + } + }else{ + for(pos in this._args){ + if(has[pos]){ + var value = arguments[pos]; + if(this._args[pos] == "'"){ + value = value.replace(/\\'/g, "'"); + }else if(this._args[pos] == '"'){ + value = value.replace(/\\"/g, '"'); + } + arg = [!this._args[pos], value]; + break; + } + } + // Get a named filter + var fn = ddt.getFilter(arguments[3]); + if(!dojo.isFunction(fn)) throw new Error(arguments[3] + " is not registered as a filter"); + this.filters.push([fn, arg]); + } + }, + getExpression: function(){ + return this.contents; + }, + resolve: function(context){ + var str = this.resolvePath(this.key, context); + for(var i = 0, filter; filter = this.filters[i]; i++){ + // Each filter has the function in [0], a boolean in [1][0] of whether it's a variable or a string + // and [1][1] is either the variable name of the string content. + if(filter[1]){ + if(filter[1][0]){ + str = filter[0](str, this.resolvePath(filter[1][1], context)); + }else{ + str = filter[0](str, filter[1][1]); + } + }else{ + str = filter[0](str); + } + } + return str; + }, + resolvePath: function(path, context){ + var current, parts; + var first = path.charAt(0); + var last = path.slice(-1); + if(!isNaN(parseInt(first))){ + current = (path.indexOf(".") == -1) ? parseInt(path) : parseFloat(path); + }else if(first == '"' && first == last){ + current = path.slice(1, -1); + }else{ + if(path == "true"){ return true; } + if(path == "false"){ return false; } + if(path == "null" || path == "None"){ return null; } + parts = path.split("."); + current = context.get(parts[0]); + for(var i = 1; i < parts.length; i++){ + var part = parts[i]; + if(current){ + if(dojo.isObject(current) && part == "items" && typeof current[part] == "undefined"){ + var items = []; + for(var key in current){ + items.push([key, current[key]]); + } + current = items; + continue; + } + + if(current.get && dojo.isFunction(current.get)){ + current = current.get(part); + }else if(typeof current[part] == "undefined"){ + current = current[part]; + break; + }else{ + current = current[part]; + } + + if(dojo.isFunction(current)){ + if(current.alters_data){ + current = ""; + }else{ + current = current(); + } + } + }else{ + return ""; + } + } + } + return current; + } + }); + + dd._TextNode = dd._Node = dojo.extend(function(/*Object*/ obj){ + // summary: Basic catch-all node + this.contents = obj; + }, + { + set: function(data){ + this.contents = data; + }, + render: function(context, buffer){ + // summary: Adds content onto the buffer + return buffer.concat(this.contents); + } + }); + + dd._NodeList = dojo.extend(function(/*Node[]*/ nodes){ + // summary: Allows us to render a group of nodes + this.contents = nodes || []; + this.last = ""; + }, + { + push: function(node){ + // summary: Add a new node to the list + this.contents.push(node); + }, + render: function(context, buffer){ + // summary: Adds all content onto the buffer + for(var i = 0; i < this.contents.length; i++){ + buffer = this.contents[i].render(context, buffer); + if(!buffer) throw new Error("Template must return buffer"); + } + return buffer; + }, + dummyRender: function(context){ + return this.render(context, dd.Template.prototype.getBuffer()).toString(); + }, + unrender: function(){ return arguments[1]; }, + clone: function(){ return this; } + }); + + dd._VarNode = dojo.extend(function(str){ + // summary: A node to be processed as a variable + this.contents = new dd._Filter(str); + }, + { + render: function(context, buffer){ + var str = this.contents.resolve(context); + return buffer.concat(str); + } + }); + + dd._noOpNode = new function(){ + // summary: Adds a no-op node. Useful in custom tags + this.render = this.unrender = function(){ return arguments[1]; } + this.clone = function(){ return this; } + } + + dd._Parser = dojo.extend(function(tokens){ + // summary: Parser used during initialization and for tag groups. + this.contents = tokens; + }, + { + i: 0, + parse: function(/*Array?*/ stop_at){ + // summary: Turns tokens into nodes + // description: Steps into tags are they're found. Blocks use the parse object + // to find their closing tag (the stop_at array). stop_at is inclusive, it + // returns the node that matched. + var types = ddt.types; + var terminators = {}; + stop_at = stop_at || []; + for(var i = 0; i < stop_at.length; i++){ + terminators[stop_at[i]] = true; + } + + var nodelist = new dd._NodeList(); + while(this.i < this.contents.length){ + token = this.contents[this.i++]; + if(dojo.isString(token)){ + nodelist.push(new dd._TextNode(token)); + }else{ + var type = token[0]; + var text = token[1]; + if(type == types.varr){ + nodelist.push(new dd._VarNode(text)); + }else if(type == types.tag){ + if(terminators[text]){ + --this.i; + return nodelist; + } + var cmd = text.split(/\s+/g); + if(cmd.length){ + cmd = cmd[0]; + var fn = ddt.getTag(cmd); + if(fn){ + nodelist.push(fn(this, text)); + } + } + } + } + } + + if(stop_at.length){ + throw new Error("Could not find closing tag(s): " + stop_at.toString()); + } + + this.contents.length = 0; + return nodelist; + }, + next: function(){ + // summary: Returns the next token in the list. + var token = this.contents[this.i++]; + return {type: token[0], text: token[1]}; + }, + skipPast: function(endtag){ + var types = ddt.types; + while(this.i < this.contents.length){ + var token = this.contents[this.i++]; + if(token[0] == types.tag && token[1] == endtag){ + return; + } + } + throw new Error("Unclosed tag found when looking for " + endtag); + }, + getVarNodeConstructor: function(){ + return dd._VarNode; + }, + getTextNodeConstructor: function(){ + return dd._TextNode; + }, + getTemplate: function(file){ + return new dd.Template(file); + } + }); + + dd.register = { + _registry: { + attributes: [], + tags: [], + filters: [] + }, + get: function(/*String*/ module, /*String*/ name){ + var registry = dd.register._registry[module + "s"]; + for(var i = 0, entry; entry = registry[i]; i++){ + if(dojo.isString(entry[0])){ + if(entry[0] == name){ + return entry; + } + }else if(name.match(entry[0])){ + return entry; + } + } + }, + getAttributeTags: function(){ + var tags = []; + var registry = dd.register._registry.attributes; + for(var i = 0, entry; entry = registry[i]; i++){ + if(entry.length == 3){ + tags.push(entry); + }else{ + var fn = dojo.getObject(entry[1]); + if(fn && dojo.isFunction(fn)){ + entry.push(fn); + tags.push(entry); + } + } + } + return tags; + }, + _any: function(type, base, locations){ + for(var path in locations){ + for(var i = 0, fn; fn = locations[path][i]; i++){ + var key = fn; + if(dojo.isArray(fn)){ + key = fn[0]; + fn = fn[1]; + } + if(dojo.isString(key)){ + if(key.substr(0, 5) == "attr:"){ + var attr = fn; + if(attr.substr(0, 5) == "attr:"){ + attr = attr.slice(5); + } + dd.register._registry.attributes.push([attr, base + "." + path + "." + attr]); + } + key = key.toLowerCase(); + } + dd.register._registry[type].push([ + key, + fn, + base + "." + path + ]); + } + } + }, + tags: function(/*String*/ base, /*Object*/ locations){ + dd.register._any("tags", base, locations); + }, + filters: function(/*String*/ base, /*Object*/ locations){ + dd.register._any("filters", base, locations); + } + } + + dd.register.tags("dojox.dtl.tag", { + "date": ["now"], + "logic": ["if", "for", "ifequal", "ifnotequal"], + "loader": ["extends", "block", "include", "load", "ssi"], + "misc": ["comment", "debug", "filter", "firstof", "spaceless", "templatetag", "widthratio", "with"], + "loop": ["cycle", "ifchanged", "regroup"] + }); + dd.register.filters("dojox.dtl.filter", { + "dates": ["date", "time", "timesince", "timeuntil"], + "htmlstrings": ["escape", "linebreaks", "linebreaksbr", "removetags", "striptags"], + "integers": ["add", "get_digit"], + "lists": ["dictsort", "dictsortreversed", "first", "join", "length", "length_is", "random", "slice", "unordered_list"], + "logic": ["default", "default_if_none", "divisibleby", "yesno"], + "misc": ["filesizeformat", "pluralize", "phone2numeric", "pprint"], + "strings": ["addslashes", "capfirst", "center", "cut", "fix_ampersands", "floatformat", "iriencode", "linenumbers", "ljust", "lower", "make_list", "rjust", "slugify", "stringformat", "title", "truncatewords", "truncatewords_html", "upper", "urlencode", "urlize", "urlizetrunc", "wordcount", "wordwrap"] + }); +})(); + +} diff --git a/includes/js/dojox/dtl/contrib/data.js b/includes/js/dojox/dtl/contrib/data.js new file mode 100644 index 0000000..5ca3aa7 --- /dev/null +++ b/includes/js/dojox/dtl/contrib/data.js @@ -0,0 +1,89 @@ +if(!dojo._hasResource["dojox.dtl.contrib.data"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.dtl.contrib.data"] = true; +dojo.provide("dojox.dtl.contrib.data"); +dojo.require("dojox.dtl._base"); + +(function(){ + var dd = dojox.dtl; + var ddcd = dd.contrib.data; + + ddcd._BoundItem = dojo.extend(function(item, store){ + this.item = item; + this.store = store; + }, + { + get: function(key){ + var store = this.store; + var item = this.item; + + if(key == "getLabel"){ + return store.getLabel(item); + }else if(key == "getAttributes"){ + return store.getAttributes(item); + }else if(key == "getIdentity"){ + if(store.getIdentity){ + return store.getIdentity(item); + } + return "Store has no identity API"; + }else{ + if(store.hasAttribute(item, key)){ + var value = store.getValue(item, key); + return (dojo.isObject(value) && store.isItem(value)) ? new ddcd._BoundItem(value, store) : value; + }else if(key.slice(-1) == "s" && store.hasAttribute(item, key.slice(0, -1))){ + return dojo.map(store.getValues(item, key.slice(0, -1)), function(value){ + return (dojo.isObject(value) && store.isItem(value)) ? new ddcd._BoundItem(value, store) : value; + }); + } + } + } + }); + + ddcd.BindDataNode = dojo.extend(function(items, store, alias){ + this.items = new dd._Filter(items); + this.store = new dd._Filter(store); + this.alias = alias; + }, + { + render: function(context, buffer){ + var items = this.items.resolve(context); + var store = this.store.resolve(context); + if(!store){ + throw new Error("data_bind didn't receive a store"); + } + + var list = []; + if(items){ + for(var i = 0, item; item = items[i]; i++){ + list.push(new ddcd._BoundItem(item, store)); + } + } + + context[this.alias] = list; + return buffer; + }, + unrender: function(context, buffer){ + return buffer; + }, + clone: function(){ + return this; + } + }); + + dojo.mixin(ddcd, { + bind_data: function(parser, text){ + var parts = dd.text.pySplit(text); + + if(parts[2] != 'to' || parts[4] != 'as' || !parts[5]){ + throw new Error("data_bind expects the format: 'data_bind items to store as varName'"); + } + + return new ddcd.BindDataNode(parts[1], parts[3], parts[5]); + } + }); + + dd.register.tags("dojox.dtl.contrib", { + "data": ["bind_data"] + }); +})(); + +} diff --git a/includes/js/dojox/dtl/contrib/dijit.js b/includes/js/dojox/dtl/contrib/dijit.js new file mode 100644 index 0000000..41caf33 --- /dev/null +++ b/includes/js/dojox/dtl/contrib/dijit.js @@ -0,0 +1,220 @@ +if(!dojo._hasResource["dojox.dtl.contrib.dijit"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.dtl.contrib.dijit"] = true; +dojo.provide("dojox.dtl.contrib.dijit"); + +dojo.require("dojox.dtl.html"); +dojo.require("dojo.parser"); + +(function(){ + var dd = dojox.dtl; + var ddcd = dd.contrib.dijit; + + ddcd.AttachNode = dojo.extend(function(keys, object){ + this._keys = keys; + this._object = object; + }, + { + render: function(context, buffer){ + if(!this._rendered){ + this._rendered = true; + for(var i=0, key; key = this._keys[i]; i++){ + context.getThis()[key] = this._object || buffer.getParent(); + } + } + return buffer; + }, + unrender: function(context, buffer){ + if(this._rendered){ + this._rendered = false; + for(var i=0, key; key = this._keys[i]; i++){ + if(context.getThis()[key] === (this._object || buffer.getParent())){ + delete context.getThis()[key]; + } + } + } + return buffer; + }, + clone: function(buffer){ + return new this.constructor(this._keys, this._object); + } + }); + + ddcd.EventNode = dojo.extend(function(command, obj){ + this._command = command; + + var type, events = command.split(/\s*,\s*/); + var trim = dojo.trim; + var types = []; + var fns = []; + while(type = events.pop()){ + if(type){ + var fn = null; + if(type.indexOf(":") != -1){ + // oh, if only JS had tuple assignment + var funcNameArr = type.split(":"); + type = trim(funcNameArr[0]); + fn = trim(funcNameArr[1]); + }else{ + type = trim(type); + } + if(!fn){ + fn = type; + } + types.push(type); + fns.push(fn); + } + } + + this._types = types; + this._fns = fns; + this._object = obj; + this._rendered = []; + }, + { + // _clear: Boolean + // Make sure we kill the actual tags (onclick problems, etc) + _clear: false, + render: function(context, buffer){ + for(var i = 0, type; type = this._types[i]; i++){ + if(!this._clear && !this._object){ + buffer.getParent()[type] = null; + } + var fn = this._fns[i]; + var args; + if(fn.indexOf(" ") != -1){ + if(this._rendered[i]){ + dojo.disconnect(this._rendered[i]); + this._rendered[i] = false; + } + args = dojo.map(fn.split(" ").slice(1), function(item){ + return new dd._Filter(item).resolve(context); + }); + fn = fn[0]; + } + if(!this._rendered[i]){ + if(!this._object){ + this._rendered[i] = buffer.addEvent(context, type, fn, args); + }else{ + this._rendered[i] = dojo.connect(this._object, type, context.getThis(), fn); + } + } + } + this._clear = true; + + return buffer; + }, + unrender: function(context, buffer){ + while(this._rendered.length){ + dojo.disconnect(this._rendered.pop()); + } + return buffer; + }, + clone: function(){ + return new this.constructor(this._command, this._object); + } + }); + + function cloneNode(n1){ + var n2 = n1.cloneNode(true); + if(dojo.isIE){ + dojo.query("script", n2).forEach("item.text = this[index].text;", dojo.query("script", n1)); + } + return n2; + } + + ddcd.DojoTypeNode = dojo.extend(function(node, parsed){ + this._node = node; + this._parsed = parsed; + + var events = node.getAttribute("dojoAttachEvent"); + if(events){ + this._events = new ddcd.EventNode(dojo.trim(events)); + } + var attach = node.getAttribute("dojoAttachPoint"); + if(attach){ + this._attach = new ddcd.AttachNode(dojo.trim(attach).split(/\s*,\s*/)); + } + + if (!parsed){ + this._dijit = dojo.parser.instantiate([cloneNode(node)])[0]; + }else{ + node = cloneNode(node); + var old = ddcd.widgetsInTemplate; + ddcd.widgetsInTemplate = false; + this._template = new dd.HtmlTemplate(node); + ddcd.widgetsInTemplate = old; + } + }, + { + render: function(context, buffer){ + if(this._parsed){ + var _buffer = new dd.HtmlBuffer(); + this._template.render(context, _buffer); + var root = cloneNode(_buffer.getRootNode()); + var div = document.createElement("div"); + div.appendChild(root); + var rendered = div.innerHTML; + div.removeChild(root); + if(rendered != this._rendered){ + this._rendered = rendered; + if(this._dijit){ + this._dijit.destroyRecursive(); + } + this._dijit = dojo.parser.instantiate([root])[0]; + } + } + + var node = this._dijit.domNode; + + if(this._events){ + this._events._object = this._dijit; + this._events.render(context, buffer); + } + if(this._attach){ + this._attach._object = this._dijit; + this._attach.render(context, buffer); + } + + return buffer.concat(node); + }, + unrender: function(context, buffer){ + return buffer.remove(this._dijit.domNode); + }, + clone: function(){ + return new this.constructor(this._node, this._parsed); + } + }); + + dojo.mixin(ddcd, { + widgetsInTemplate: true, + dojoAttachPoint: function(parser, text){ + return new ddcd.AttachNode(dojo.trim(text).slice(16).split(/\s*,\s*/)); + }, + dojoAttachEvent: function(parser, text){ + return new ddcd.EventNode(text.slice(16)); + }, + dojoType: function(parser, text){ + if(ddcd.widgetsInTemplate){ + var node = parser.swallowNode(); + var parsed = false; + if(text.slice(-7) == " parsed"){ + parsed = true; + node.setAttribute("dojoType", dojo.trim(text).slice(0, -7)); + } + return new ddcd.DojoTypeNode(node, parsed); + } + return dd._noOpNode; + }, + on: function(parser, text){ + // summary: Associates an event type to a function (on the current widget) by name + var parts = text.split(" "); + return new ddcd.EventNode(parts[0] + ":" + parts.slice(1).join(" ")); + } + }); + + dd.register.tags("dojox.dtl.contrib", { + "dijit": ["attr:dojoType", "attr:dojoAttachPoint", ["attr:attach", "dojoAttachPoint"], "attr:dojoAttachEvent", [/(attr:)?on(click|key(up))/i, "on"]] + }); +})(); + +} diff --git a/includes/js/dojox/dtl/contrib/html.js b/includes/js/dojox/dtl/contrib/html.js new file mode 100644 index 0000000..260bbe2 --- /dev/null +++ b/includes/js/dojox/dtl/contrib/html.js @@ -0,0 +1,107 @@ +if(!dojo._hasResource["dojox.dtl.contrib.html"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.dtl.contrib.html"] = true; +dojo.provide("dojox.dtl.contrib.html"); + +dojo.require("dojox.dtl.html"); + +(function(){ + var dd = dojox.dtl; + var ddch = dd.contrib.html; + + ddch.HtmlNode = dojo.extend(function(name){ + this.contents = new dd._Filter(name); + this._div = document.createElement("div"); + this._lasts = []; + }, + { + render: function(context, buffer){ + var text = this.contents.resolve(context); + if(text){ + text = text.replace(/<(\/?script)/ig, '<$1').replace(/\bon[a-z]+\s*=/ig, ''); + if(this._rendered && this._last != text){ + buffer = this.unrender(context, buffer); + } + this._last = text; + + // This can get reset in the above tag + if(!this._rendered){ + this._rendered = true; + var div = this._div; + div.innerHTML = text; + var children = div.childNodes; + while(children.length){ + var removed = div.removeChild(children[0]); + this._lasts.push(removed); + buffer = buffer.concat(removed); + } + } + } + + return buffer; + }, + unrender: function(context, buffer){ + if(this._rendered){ + this._rendered = false; + this._last = ""; + for(var i = 0, node; node = this._lasts[i++];){ + buffer = buffer.remove(node); + dojo._destroyElement(node); + } + this._lasts = []; + } + return buffer; + }, + clone: function(buffer){ + return new this.constructor(this.contents.getExpression()); + } + }); + + ddch.StyleNode = dojo.extend(function(styles){ + this.contents = {}; + this._styles = styles; + for(var key in styles){ + this.contents[key] = new dd.Template(styles[key]); + } + }, + { + render: function(context, buffer){ + for(var key in this.contents){ + dojo.style(buffer.getParent(), key, this.contents[key].render(context)); + } + return buffer; + }, + unrender: function(context, buffer){ + return buffer; + }, + clone: function(buffer){ + return new this.constructor(this._styles); + } + }); + + dojo.mixin(ddch, { + html: function(parser, text){ + var parts = text.split(" ", 2); + return new ddch.HtmlNode(parts[1]); + }, + tstyle: function(parser, text){ + var styles = {}; + text = text.replace(/^tstyle\s+/, ""); + var rules = text.split(/\s*;\s*/g); + for(var i = 0, rule; rule = rules[i]; i++){ + var parts = rule.split(/\s*:\s*/g); + var key = parts[0]; + var value = parts[1]; + if(value.indexOf("{{") == 0){ + styles[key] = value; + } + } + return new ddch.StyleNode(styles); + } + }); + + dd.register.tags("dojox.dtl.contrib", { + "html": ["html", "attr:tstyle"] + }); +})(); + +} diff --git a/includes/js/dojox/dtl/contrib/objects.js b/includes/js/dojox/dtl/contrib/objects.js new file mode 100644 index 0000000..d29c0df --- /dev/null +++ b/includes/js/dojox/dtl/contrib/objects.js @@ -0,0 +1,15 @@ +if(!dojo._hasResource["dojox.dtl.contrib.objects"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.dtl.contrib.objects"] = true; +dojo.provide("dojox.dtl.contrib.objects"); + +dojo.mixin(dojox.dtl.contrib.objects, { + key: function(value, arg){ + return value[arg]; + } +}); + +dojox.dtl.register.filters("dojox.dtl.contrib", { + "objects": ["key"] +}); + +} diff --git a/includes/js/dojox/dtl/demos/demo_Animation.html b/includes/js/dojox/dtl/demos/demo_Animation.html new file mode 100644 index 0000000..1a5e278 --- /dev/null +++ b/includes/js/dojox/dtl/demos/demo_Animation.html @@ -0,0 +1,45 @@ + + + Testing dojox.dtl using animation to change attributes + + + + +
+ + \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/demo_Blog.html b/includes/js/dojox/dtl/demos/demo_Blog.html new file mode 100644 index 0000000..c9bd990 --- /dev/null +++ b/includes/js/dojox/dtl/demos/demo_Blog.html @@ -0,0 +1,96 @@ + + + Testing dojox.dtl using a blog example + + + + +
+ + diff --git a/includes/js/dojox/dtl/demos/demo_Data.html b/includes/js/dojox/dtl/demos/demo_Data.html new file mode 100644 index 0000000..93bb76f --- /dev/null +++ b/includes/js/dojox/dtl/demos/demo_Data.html @@ -0,0 +1,58 @@ + + + Demo using the dojo.data bind_data tag + + + + +
+ + + \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/demo_Dijitless.html b/includes/js/dojox/dtl/demos/demo_Dijitless.html new file mode 100644 index 0000000..2aaceaa --- /dev/null +++ b/includes/js/dojox/dtl/demos/demo_Dijitless.html @@ -0,0 +1,50 @@ + + + Demo using dojox.dtl._HtmlTemplated without Dijit + + + + +
+ + diff --git a/includes/js/dojox/dtl/demos/demo_Events.html b/includes/js/dojox/dtl/demos/demo_Events.html new file mode 100644 index 0000000..aa3da46 --- /dev/null +++ b/includes/js/dojox/dtl/demos/demo_Events.html @@ -0,0 +1,46 @@ + + + Demo using dojox.dtl._Templated + + + + + +
+ + + \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/demo_HtmlTemplated.html b/includes/js/dojox/dtl/demos/demo_HtmlTemplated.html new file mode 100644 index 0000000..71dabe4 --- /dev/null +++ b/includes/js/dojox/dtl/demos/demo_HtmlTemplated.html @@ -0,0 +1,40 @@ + + + Demo using dojox.dtl._HtmlTemplated + + + + + +
+ + + \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/demo_Inline.html b/includes/js/dojox/dtl/demos/demo_Inline.html new file mode 100644 index 0000000..6e17d8e --- /dev/null +++ b/includes/js/dojox/dtl/demos/demo_Inline.html @@ -0,0 +1,48 @@ + + + Demo using dojox.dtl._HtmlTemplated inline in DOM + + + + + + + + + diff --git a/includes/js/dojox/dtl/demos/demo_NodeList.html b/includes/js/dojox/dtl/demos/demo_NodeList.html new file mode 100644 index 0000000..d1ab0a8 --- /dev/null +++ b/includes/js/dojox/dtl/demos/demo_NodeList.html @@ -0,0 +1,37 @@ + + + Demo using dojox.dtl._Templated + + + + +
+
+
+
+ + diff --git a/includes/js/dojox/dtl/demos/demo_Table.html b/includes/js/dojox/dtl/demos/demo_Table.html new file mode 100644 index 0000000..56dc8ac --- /dev/null +++ b/includes/js/dojox/dtl/demos/demo_Table.html @@ -0,0 +1,4072 @@ + + + Demo to show a massive nested for loop to render a table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IndexNumericTextCurrencyDate
0158.9Bill$22.442008-12-28
1690.4Joe$3.032009-07-03
2843Bob$11.142010-09-30
357.8Matt$70.642009-12-16
4494.6Mark$9.132010-05-11
5766.3Tom$55.342008-03-10
6699.3Jake$26.242008-11-26
7487.8Greg$72.942010-06-23
8786.2Adam$34.642008-09-19
9188.6Steve$6.332009-01-01
10898.4George$22.242009-09-18
11222.2John$91.242009-10-23
12707.9Phil$75.542010-02-28
13585.5Jack$81.342009-03-24
14213.8Paul$30.742009-07-08
15968.5Rob$7.332008-02-06
1639.3Walt$77.342008-12-05
17335.7Nathan$26.142008-01-27
18127.6Dan$4.732009-03-03
19365.3Jeff$23.542009-05-15
20692.9Bill$13.342010-01-26
21244.9Joe$35.642009-10-16
22827Bob$6.332009-01-06
23519.6Matt$64.942008-06-03
24917.8Mark$86.342009-05-24
25407.1Tom$83.142009-08-17
26449.3Jake$87.042008-11-27
27753.5Greg$20.642009-09-25
28787Adam$33.442009-11-18
29166.9Steve$69.942010-08-17
30609.6George$39.242011-01-18
31274John$63.642009-01-02
32850.3Phil$46.342009-03-17
33181.4Jack$98.342008-02-04
34325.3Paul$90.142010-10-30
35776.3Rob$30.842010-04-17
36300.8Walt$75.742009-11-18
37598Nathan$51.042010-07-15
38155.6Dan$29.742008-06-04
39759.8Jeff$46.442010-08-21
40599.2Bill$7.432008-09-16
41571.9Joe$34.842010-09-23
42900.3Bob$19.842009-01-09
43292.2Matt$37.942008-12-21
44333Mark$70.542008-08-28
45236.4Tom$48.142009-08-19
46970.9Jake$78.242008-11-10
47575.8Greg$37.942010-06-24
48386.7Adam$53.542008-04-02
49531.1Steve$29.542009-09-21
50374.3George$89.442009-12-15
51609.1John$46.642011-01-22
52480.3Phil$36.642008-07-07
53814.8Jack$65.842009-09-19
54132.2Paul$99.142008-10-12
55350.1Rob$22.842010-04-22
56875.7Walt$19.842009-08-12
57158.1Nathan$77.442010-10-25
58950.9Dan$16.142009-05-05
5941.1Jeff$69.242010-04-11
60595.4Bill$6.632009-12-09
61223.4Joe$67.542008-03-30
62199.2Bob$15.642009-05-28
63372.8Matt$97.042008-04-28
64925.7Mark$10.242008-04-17
65183.1Tom$45.342009-01-05
66921.2Jake$32.842009-08-23
67440.8Greg$48.642008-12-04
68339.8Adam$43.742009-06-08
69773.7Steve$47.842008-06-17
70502.3George$7.332008-09-01
71124.8John$29.742010-10-22
72213Phil$49.642008-02-18
73667.3Jack$86.942008-01-14
74779.8Paul$79.442008-05-12
75883.3Rob$97.742009-10-17
76214.4Walt$89.942010-11-01
77743.7Nathan$33.942009-03-16
7847Dan$67.942010-08-04
79511Jeff$45.342008-12-08
80666.7Bill$95.542009-03-03
81888.5Joe$8.032010-02-09
82785.4Bob$29.342008-07-06
83837.7Matt$96.042008-02-05
84860.2Mark$74.042010-08-12
85985Tom$62.342010-07-17
86562.3Jake$83.742010-03-21
87467.6Greg$58.142008-02-16
88859Adam$62.842010-04-12
89687.5Steve$13.942008-07-17
90993.9George$80.542008-05-26
91373.8John$69.442008-08-26
9250.4Phil$47.942009-07-30
93222.8Jack$31.742009-06-14
94263.9Paul$17.742008-08-16
9599.2Rob$16.242010-08-07
96911.8Walt$72.442010-01-31
97623Nathan$19.242008-10-03
98673.4Dan$5.032010-09-29
99402.8Jeff$73.842008-01-06
100584.8Bill$73.242010-07-26
101721.7Joe$10.642009-08-06
102938.1Bob$15.642011-02-11
103447.1Matt$37.942008-12-12
104915.9Mark$64.342009-07-05
105124.2Tom$74.242010-01-08
106955.3Jake$65.342009-02-23
107623.6Greg$27.642009-10-02
108872.6Adam$95.042009-11-30
109749.4Steve$35.342009-01-30
110764.7George$93.742008-03-26
111585.4John$65.942008-07-26
11299.8Phil$59.742009-01-23
11393.2Jack$4.432010-04-06
114403.3Paul$96.042009-02-16
115890.2Rob$8.432008-04-23
116538.9Walt$3.932010-05-19
117911.6Nathan$66.342008-02-02
118475.9Dan$53.542011-02-05
11990.7Jeff$28.542009-01-16
120443.3Bill$5.032008-11-05
121527.7Joe$63.542010-12-07
122717.7Bob$73.542009-08-28
12363.5Matt$82.842009-10-18
124788Mark$23.142009-09-02
125155Tom$12.142009-12-08
126263.6Jake$66.042010-01-22
12725.6Greg$57.242008-12-28
12863.9Adam$4.732010-09-09
12952Steve$13.842008-06-03
130392.5George$58.142008-07-31
131670.3John$10.942010-08-04
132607Phil$82.742009-10-01
133140.7Jack$89.042009-03-16
134718.3Paul$67.842009-12-08
135255.9Rob$83.342010-04-27
136877.6Walt$9.732009-03-29
137538.6Nathan$12.242011-01-20
138862.5Dan$18.642008-01-13
139721.9Jeff$23.842008-06-21
140866.2Bill$63.042010-04-25
14159.9Joe$30.142010-08-29
142888.4Bob$90.842010-02-09
143451.5Matt$4.832009-10-05
144842.2Mark$76.742008-09-27
145463.9Tom$2.232008-03-18
146206.6Jake$90.042008-07-08
147609.3Greg$43.842008-11-26
148583.6Adam$30.142009-06-29
149605.2Steve$2.332010-03-31
150764.8George$88.942009-01-27
151505.6John$94.942010-01-10
152355.4Phil$83.742009-09-25
15331.9Jack$28.842009-11-20
154598.4Paul$13.142009-02-23
155842.9Rob$59.442009-03-20
156920.5Walt$80.142008-11-24
15794.5Nathan$41.042010-04-16
158390.6Dan$99.442008-01-28
159872.6Jeff$59.942008-02-23
160592.3Bill$36.442010-12-18
161942.4Joe$86.942010-10-19
162593Bob$22.442010-04-13
163151.1Matt$25.642008-01-11
164757.4Mark$85.542008-06-10
165130Tom$69.842010-04-29
166525Jake$61.842009-09-10
167819.8Greg$71.342010-12-29
168552.9Adam$10.342010-12-22
169586.8Steve$97.542009-09-13
170643.5George$56.842010-11-08
171588.9John$51.042010-06-10
172482.9Phil$10.342007-12-25
173213.9Jack$25.442008-10-17
174233.2Paul$1.132008-05-01
175383Rob$14.242010-07-18
176127.1Walt$66.742009-05-01
177672.2Nathan$48.642008-06-03
178627.4Dan$3.932008-09-30
179576.3Jeff$62.642008-09-01
180124.1Bill$26.942010-06-20
18135.3Joe$85.842008-11-30
182815.7Bob$34.142009-03-30
183820.6Matt$55.542010-01-18
18481.8Mark$78.842010-01-31
185197.5Tom$17.142010-07-14
18610.8Jake$29.842009-06-23
187442Greg$97.042011-01-06
188585.7Adam$59.742007-12-21
189832.2Steve$17.442009-12-14
19054.3George$29.842010-10-22
191844John$33.342010-05-10
192143.9Phil$14.942008-04-07
193546.8Jack$96.942010-01-09
194203.8Paul$5.132009-05-09
195872.3Rob$24.842009-11-22
196682.3Walt$25.942010-11-02
197158.7Nathan$70.142010-09-28
198121.2Dan$28.742009-06-19
199122.6Jeff$11.942010-01-06
200749.8Bill$17.342010-12-17
201646.1Joe$1.732008-11-05
202400.4Bob$16.142009-04-26
203495.5Matt$70.842009-03-21
204145.3Mark$91.242009-05-19
205582.9Tom$78.442010-03-02
206191.3Jake$46.642010-12-27
20797.5Greg$62.542010-01-15
208973.7Adam$74.642010-12-13
209447.2Steve$86.842008-02-27
21094.3George$61.842008-09-15
21139John$26.442008-10-04
212316.7Phil$66.542009-04-09
213743Jack$16.042008-05-05
214138.4Paul$30.542008-01-24
215584.7Rob$88.842010-07-19
216279.3Walt$7.932008-11-08
217233Nathan$17.742010-11-01
218887.8Dan$15.042010-01-11
219829.3Jeff$59.842009-08-12
220889.7Bill$69.242008-05-27
221123.3Joe$73.142009-03-29
222373.9Bob$4.732008-03-06
223785.6Matt$79.042008-09-07
224904.9Mark$92.942009-08-26
225935.8Tom$51.342009-04-19
226750.5Jake$79.342009-07-19
22731.2Greg$2.532010-02-09
228936.7Adam$91.342010-08-02
229588Steve$74.242009-04-23
230107.7George$63.242008-05-01
231245.7John$75.542010-08-25
232647.8Phil$12.942010-10-19
233714.6Jack$91.542010-02-18
234941.3Paul$82.042009-11-28
235473.3Rob$75.542008-05-13
236893.4Walt$50.642010-11-17
237392.7Nathan$53.742010-12-16
23868.8Dan$47.442010-09-06
239895.2Jeff$6.132009-11-12
240319.1Bill$16.942008-09-12
241434.7Joe$41.542011-02-04
242281.1Bob$6.332008-05-02
243174.8Matt$77.742008-01-24
244859Mark$71.842010-08-30
245471.8Tom$19.142009-11-19
246597.9Jake$8.532008-04-26
247516.5Greg$47.842010-01-08
248460.6Adam$54.642008-05-08
249317.8Steve$44.142008-07-18
250917.4George$76.042009-01-30
251149.1John$19.542010-05-25
252136.1Phil$47.642010-08-05
253252.2Jack$65.142009-11-20
254283Paul$51.042008-12-29
255133.3Rob$98.242009-08-08
256739Walt$57.942009-11-14
257850.4Nathan$9.632008-03-19
258498.6Dan$55.642009-12-11
259620.3Jeff$87.442008-03-04
260803.4Bill$79.142010-08-01
261155.5Joe$94.042008-01-13
262922.3Bob$7.632009-07-17
263751.6Matt$32.942008-06-07
264357.9Mark$61.142010-01-18
265682.4Tom$74.542009-12-28
266198.4Jake$48.442008-08-28
267799.1Greg$33.442008-12-17
268877.4Adam$83.342010-09-21
269501.7Steve$45.342010-04-28
270567.4George$25.642009-08-30
271393.4John$41.142009-06-22
272414.4Phil$33.442009-09-18
273911.4Jack$8.532010-10-03
27459.2Paul$44.342009-07-10
275716.7Rob$12.642008-09-18
276355.7Walt$32.442010-04-01
277573.9Nathan$12.342008-02-20
278887.7Dan$0.032010-10-10
279757.8Jeff$50.242009-01-15
280501.7Bill$6.932009-11-07
28136.9Joe$46.342007-12-27
282512.4Bob$87.742009-01-16
28364.3Matt$78.842009-04-25
284944.6Mark$84.742010-09-20
285436.3Tom$56.442011-02-12
286672.6Jake$92.042008-12-21
287392.6Greg$49.442009-05-13
288446.5Adam$38.142009-05-13
289333Steve$13.942010-12-15
290672.1George$64.142008-01-02
291267.3John$67.842009-06-21
292273.9Phil$19.042009-01-29
293614.3Jack$25.442008-05-29
29440Paul$19.942011-02-04
295908.8Rob$63.542009-09-17
296903.1Walt$30.842009-06-17
297221.2Nathan$70.042011-01-09
298662.1Dan$14.742009-01-23
299103.2Jeff$47.942009-07-03
30046.2Bill$15.242008-05-13
30158.3Joe$41.942010-07-06
302533Bob$69.342011-02-10
303884.6Matt$30.742008-09-30
30424.5Mark$34.742009-05-18
30511.7Tom$25.642008-03-22
306563Jake$15.942009-03-12
30734.1Greg$38.042008-03-30
308998.8Adam$4.232008-09-16
309344.7Steve$14.542010-03-25
310829.5George$19.142010-09-16
311955John$24.942008-11-12
312758Phil$78.342011-01-23
313750.8Jack$66.742008-11-11
314997.8Paul$69.142009-12-18
315443.5Rob$70.342010-10-10
316524Walt$26.642008-02-09
317912Nathan$30.042009-04-24
3181000Dan$29.942009-06-11
319234.5Jeff$64.342009-11-26
320948.4Bill$47.342010-07-05
321813.7Joe$42.842008-02-18
32297.7Bob$18.642010-08-11
32374.3Matt$93.742009-07-22
324357.7Mark$93.442008-07-29
325988Tom$37.842010-10-21
326873.8Jake$90.242008-06-24
327918.3Greg$81.442009-06-06
328342.7Adam$81.442010-05-18
329809Steve$4.832009-03-31
330420.4George$99.742010-09-30
331223John$81.042008-12-06
332275Phil$90.842009-07-09
333109.5Jack$98.242009-04-27
334610.9Paul$34.042009-02-10
335803.7Rob$32.842010-04-23
336699.6Walt$20.142009-12-30
337861.4Nathan$12.042009-05-28
338323.4Dan$46.242008-10-25
33984.3Jeff$27.142008-12-19
340488.6Bill$69.242008-12-15
341365.7Joe$91.542008-05-10
342670.8Bob$19.042008-01-24
343161.5Matt$29.942008-01-03
344588.8Mark$91.042009-01-30
345950.3Tom$71.442010-02-13
346689.5Jake$41.342010-10-04
347330.4Greg$27.442007-12-20
348785Adam$59.842009-06-07
34953.2Steve$68.242010-04-17
350369.6George$17.142009-04-25
351682.4John$53.642009-01-17
352805.3Phil$20.742009-08-24
353836Jack$36.942010-08-05
354848.6Paul$95.742010-04-23
355201Rob$90.742009-05-26
356880.9Walt$59.742010-09-16
357762.2Nathan$92.742008-05-29
358763.1Dan$71.242010-04-21
359226.4Jeff$76.542009-04-18
360960.8Bill$13.542009-11-02
361386.9Joe$81.742008-05-14
362727.6Bob$62.342009-01-08
363257.8Matt$45.942010-03-11
36487Mark$30.742010-01-20
365826Tom$50.842009-10-05
366278.6Jake$38.942008-06-25
367144.2Greg$15.142008-04-02
368284.2Adam$91.442010-07-05
36922Steve$14.142009-10-07
370441.8George$10.142010-03-12
37132.2John$48.842009-08-13
372158.8Phil$21.642008-06-02
373492.4Jack$47.342009-11-14
374194.4Paul$56.042010-11-05
375853.5Rob$38.642009-04-14
376420Walt$66.542010-07-09
377583.4Nathan$80.942010-12-30
378674Dan$9.332010-09-22
379476.8Jeff$11.542008-01-01
38044.9Bill$55.742008-04-27
381748Joe$58.942009-11-13
382268.4Bob$74.842010-07-21
383411.3Matt$24.042008-11-18
38412.8Mark$43.442010-08-29
385921.3Tom$28.842008-09-18
386337.8Jake$70.842010-10-27
387143.3Greg$29.142010-03-20
38899.8Adam$96.542010-07-06
389970.4Steve$44.242010-11-16
390981.5George$48.742009-06-21
39193.8John$23.442008-03-02
392694.2Phil$50.342010-07-16
393510.3Jack$91.442008-02-17
394799.7Paul$92.742009-07-04
395649.5Rob$84.842010-06-02
396885.6Walt$18.642009-06-28
397786.6Nathan$32.942010-05-31
398496.7Dan$42.942010-04-21
399299.9Jeff$39.942008-07-13
400218.1Bill$38.142010-01-27
401693.2Joe$47.442010-10-26
402757.2Bob$16.942009-03-29
403568.9Matt$67.942008-12-20
404620.5Mark$47.842008-09-26
405106.4Tom$12.842008-04-04
406880.1Jake$1.332008-11-05
407361.5Greg$80.042009-11-20
408133.8Adam$29.742008-01-29
409871.1Steve$59.642009-05-05
41050George$81.542010-07-20
411715.4John$50.842008-11-18
412615.3Phil$26.542009-06-01
41318.1Jack$83.442008-05-25
414335Paul$45.442009-11-30
415578.7Rob$56.042010-04-27
416670.5Walt$44.042010-05-12
417948.2Nathan$80.242009-09-23
418554.8Dan$93.642010-09-01
419590.3Jeff$80.742009-05-22
42024.8Bill$85.742008-10-19
421839.9Joe$57.242010-05-29
422129.3Bob$18.742008-01-29
423587.2Matt$20.542010-09-20
424723.7Mark$54.042008-12-27
425338.5Tom$11.942010-10-07
42681Jake$78.942008-12-28
427836.9Greg$73.842008-05-13
428392.7Adam$29.242008-02-29
429245Steve$88.342010-09-19
430693.7George$90.742010-04-06
431956.8John$74.742008-11-27
432727.5Phil$87.742009-07-02
433763Jack$46.442010-02-24
434632Paul$18.742008-09-10
435955.1Rob$52.642009-01-26
436838.7Walt$60.742008-05-27
437162.7Nathan$44.442010-09-27
438288.6Dan$83.642008-06-30
439350.1Jeff$8.132008-02-15
440218.4Bill$77.542010-12-31
441943.2Joe$73.142010-03-14
442240Bob$45.942009-10-22
443724Matt$22.242008-02-09
444413.3Mark$85.442008-09-13
445642.8Tom$80.942010-05-14
446991.3Jake$64.842009-02-13
447129.2Greg$81.042010-07-11
4484.6Adam$9.932010-01-02
449172.2Steve$44.942010-04-06
450222.3George$66.742009-07-19
451179.7John$61.042008-09-11
452884.3Phil$85.042010-02-24
453465.3Jack$57.442010-11-08
454510Paul$98.742010-05-22
455741.8Rob$63.042009-10-13
456499.2Walt$62.142008-08-31
457863.3Nathan$75.042008-01-24
458670.7Dan$75.542008-05-17
459314.2Jeff$92.742009-10-19
46038.7Bill$14.942008-09-28
461537.8Joe$32.942010-09-05
462768.2Bob$21.342010-03-15
463457.5Matt$67.942008-11-07
464368.5Mark$18.942008-10-23
465133.3Tom$93.042010-10-22
466706.9Jake$43.042009-08-10
467927.9Greg$29.342008-10-25
468959.1Adam$96.342008-01-16
46988.8Steve$27.842010-12-24
470667.2George$31.642008-04-13
471912.6John$85.442009-04-29
472768.1Phil$62.242010-01-01
473473.8Jack$8.032008-12-25
474753.4Paul$44.842009-07-31
47520.3Rob$58.142009-05-11
476917.3Walt$28.842010-09-20
477435.6Nathan$21.642008-06-24
478704.3Dan$17.542008-05-12
479728.1Jeff$26.442009-03-29
480678.9Bill$93.142010-03-30
481779.1Joe$84.342009-10-12
482208.3Bob$61.142008-07-31
483850.8Matt$8.532008-10-31
484171.8Mark$83.842010-04-03
485681.4Tom$85.942008-12-04
486121.1Jake$77.642009-11-02
487990.2Greg$21.142010-07-10
488152Adam$91.642011-01-28
489277Steve$64.442008-09-28
490679.5George$32.342008-07-10
491398John$10.242008-01-10
492970.4Phil$31.042009-12-18
493164.7Jack$16.142010-03-26
494438.5Paul$33.242009-09-20
495160.2Rob$1.432009-04-10
496463Walt$13.542008-07-24
49753.9Nathan$12.542009-03-26
498860.6Dan$27.742008-12-18
499842.2Jeff$55.442011-01-02
+ + + \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/demo_Templated.html b/includes/js/dojox/dtl/demos/demo_Templated.html new file mode 100644 index 0000000..b538811 --- /dev/null +++ b/includes/js/dojox/dtl/demos/demo_Templated.html @@ -0,0 +1,36 @@ + + + Demo using dojox.dtl._Templated + + + + +
+ + + diff --git a/includes/js/dojox/dtl/demos/demo_Tree.html b/includes/js/dojox/dtl/demos/demo_Tree.html new file mode 100644 index 0000000..692d863 --- /dev/null +++ b/includes/js/dojox/dtl/demos/demo_Tree.html @@ -0,0 +1,33 @@ + + + Demo to show recursion in DTL + + + + +
+ + + \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/json/blog/get_blog_1.json b/includes/js/dojox/dtl/demos/json/blog/get_blog_1.json new file mode 100644 index 0000000..9c7dd9f --- /dev/null +++ b/includes/js/dojox/dtl/demos/json/blog/get_blog_1.json @@ -0,0 +1 @@ +{"teaser":"I'd be able to write a lot faster.","body":"I think I wouldn't be able to think.","date":1189125242601,"author":"jim"} \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/json/blog/get_blog_3.json b/includes/js/dojox/dtl/demos/json/blog/get_blog_3.json new file mode 100644 index 0000000..7c0a937 --- /dev/null +++ b/includes/js/dojox/dtl/demos/json/blog/get_blog_3.json @@ -0,0 +1 @@ +{"teaser":"There was SO much sand","body":"I tried to walk so fast that I wouldn't leave foot prints.","date":1190245842601,"author":"jim"} \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/json/blog/get_blog_list.json b/includes/js/dojox/dtl/demos/json/blog/get_blog_list.json new file mode 100644 index 0000000..40f14a7 --- /dev/null +++ b/includes/js/dojox/dtl/demos/json/blog/get_blog_list.json @@ -0,0 +1 @@ +{"blog_list":{"3":{"title":"My Trip to the Beach"},"1":{"title":"If I Were a Robot"}}} \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/json/blog/get_page_about.json b/includes/js/dojox/dtl/demos/json/blog/get_page_about.json new file mode 100644 index 0000000..05ddb9c --- /dev/null +++ b/includes/js/dojox/dtl/demos/json/blog/get_page_about.json @@ -0,0 +1 @@ +{"title":"About Jim","body":"

Jim is an avid golfer, enjoys long walks on the beach, and eating hot pockets

When he's not scalding his mouth, you'll find him throwing rocks at pigeons.

"} \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/json/fruit.json b/includes/js/dojox/dtl/demos/json/fruit.json new file mode 100644 index 0000000..e7a0bf8 --- /dev/null +++ b/includes/js/dojox/dtl/demos/json/fruit.json @@ -0,0 +1 @@ +{ items: ["apple", "banana", "pear"] } \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/json/morefruit.json b/includes/js/dojox/dtl/demos/json/morefruit.json new file mode 100644 index 0000000..6a8beea --- /dev/null +++ b/includes/js/dojox/dtl/demos/json/morefruit.json @@ -0,0 +1 @@ +{ items: ["pineapple", "orange", "tomato"] } \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/templates/animation.html b/includes/js/dojox/dtl/demos/templates/animation.html new file mode 100644 index 0000000..56c38f3 --- /dev/null +++ b/includes/js/dojox/dtl/demos/templates/animation.html @@ -0,0 +1,5 @@ +{% load dojox.dtl.contrib.dijit dojox.dtl.contrib.html %} +
+
 
+
 
+
\ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/templates/blog_base.html b/includes/js/dojox/dtl/demos/templates/blog_base.html new file mode 100644 index 0000000..1438a6b --- /dev/null +++ b/includes/js/dojox/dtl/demos/templates/blog_base.html @@ -0,0 +1,8 @@ +
+

+ + +
\ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/templates/blog_detail.html b/includes/js/dojox/dtl/demos/templates/blog_detail.html new file mode 100644 index 0000000..2b6146d --- /dev/null +++ b/includes/js/dojox/dtl/demos/templates/blog_detail.html @@ -0,0 +1,10 @@ + + + +
+

+
posted on by
+

+

+
+ \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/templates/blog_list.html b/includes/js/dojox/dtl/demos/templates/blog_list.html new file mode 100644 index 0000000..2413605 --- /dev/null +++ b/includes/js/dojox/dtl/demos/templates/blog_list.html @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/templates/blog_page.html b/includes/js/dojox/dtl/demos/templates/blog_page.html new file mode 100644 index 0000000..aeeb762 --- /dev/null +++ b/includes/js/dojox/dtl/demos/templates/blog_page.html @@ -0,0 +1,7 @@ + + + +
+ +
+ \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/templates/countrychildren.html b/includes/js/dojox/dtl/demos/templates/countrychildren.html new file mode 100644 index 0000000..fbdbebe --- /dev/null +++ b/includes/js/dojox/dtl/demos/templates/countrychildren.html @@ -0,0 +1 @@ +
  • {{ country.type }}: {{ country.name }}{% if country.children %}
      {% for country in country.childrens %}{% include countrychildren %}{% endfor %}
    {% endif %}
  • \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/templates/gallery.html b/includes/js/dojox/dtl/demos/templates/gallery.html new file mode 100644 index 0000000..7fe6d8c --- /dev/null +++ b/includes/js/dojox/dtl/demos/templates/gallery.html @@ -0,0 +1,16 @@ +{% load dojox.dtl.contrib.data %} +{% bind_data items to store as flickr %} +
    + + + + {% for item in flickr %}{% endfor %} + + + + + +
    + {% if selected %}{% endif %} +
    +
    \ No newline at end of file diff --git a/includes/js/dojox/dtl/demos/templates/nodelist.html b/includes/js/dojox/dtl/demos/templates/nodelist.html new file mode 100644 index 0000000..ddf7def --- /dev/null +++ b/includes/js/dojox/dtl/demos/templates/nodelist.html @@ -0,0 +1,5 @@ +
    +
      + {% for item in items %}
    • {{ item }}
    • {% endfor %} +
    +
    \ No newline at end of file diff --git a/includes/js/dojox/dtl/ext-dojo/NodeList.js b/includes/js/dojox/dtl/ext-dojo/NodeList.js new file mode 100644 index 0000000..64e9a93 --- /dev/null +++ b/includes/js/dojox/dtl/ext-dojo/NodeList.js @@ -0,0 +1,33 @@ +if(!dojo._hasResource["dojox.dtl.ext-dojo.NodeList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.dtl.ext-dojo.NodeList"] = true; +dojo.provide("dojox.dtl.ext-dojo.NodeList"); +dojo.require("dojox.dtl._base"); + +dojo.extend(dojo.NodeList, { + dtl: function(template, context){ + // args: dojox.dtl.__StringArgs|String + // The template string or location + // context: dojox.dtl.__ObjectArgs|Object + // The context object or location + var d = dojox.dtl; + + var self = this; + var render = function(data){ + var content = template.render(new d._Context(context)); + self.forEach(function(node){ + node.innerHTML = content; + }); + } + + d.text._resolveTemplateArg(template).addCallback(function(templateString){ + template = new d.Template(templateString); + d.text._resolveContextArg(context).addCallback(function(contextObject){ + render(contextObject); + }); + }); + + return this; + } +}); + +} diff --git a/includes/js/dojox/dtl/filter/dates.js b/includes/js/dojox/dtl/filter/dates.js new file mode 100644 index 0000000..3ca2022 --- /dev/null +++ b/includes/js/dojox/dtl/filter/dates.js @@ -0,0 +1,54 @@ +if(!dojo._hasResource["dojox.dtl.filter.dates"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.dtl.filter.dates"] = true; +dojo.provide("dojox.dtl.filter.dates"); + +dojo.require("dojox.dtl.utils.date"); + +(function(){ + var ddfd = dojox.dtl.filter.dates; + + dojo.mixin(ddfd, { + _toDate: function(value){ + if(value instanceof Date){ + return value; + } + value = new Date(value); + if(value.getTime() == new Date(0).getTime()){ + return ""; + } + return value; + }, + date: function(value, arg){ + // summary: Formats a date according to the given format + value = ddfd._toDate(value); + if(!value) return ""; + arg = arg || "N j, Y"; + return dojox.dtl.utils.date.format(value, arg); + }, + time: function(value, arg){ + // summary: Formats a time according to the given format + value = ddfd._toDate(value); + if(!value) return ""; + arg = arg || "P"; + return dojox.dtl.utils.date.format(value, arg); + }, + timesince: function(value, arg){ + // summary: Formats a date as the time since that date (i.e. "4 days, 6 hours") + value = ddfd._toDate(value); + if(!value) return ""; + var timesince = dojox.dtl.utils.date.timesince; + if(arg) return timesince(arg, value); + return timesince(value); + }, + timeuntil: function(value, arg){ + // summary: Formats a date as the time until that date (i.e. "4 days, 6 hours") + value = ddfd._toDate(value); + if(!value) return ""; + var timesince = dojox.dtl.utils.date.timesince; + if(arg) return timesince(arg, value); + return timesince(new Date(), value); + } + }); +})(); + +} diff --git a/includes/js/dojox/dtl/filter/htmlstrings.js b/includes/js/dojox/dtl/filter/htmlstrings.js new file mode 100644 index 0000000..d4feb93 --- /dev/null +++ b/includes/js/dojox/dtl/filter/htmlstrings.js @@ -0,0 +1,59 @@ +if(!dojo._hasResource["dojox.dtl.filter.htmlstrings"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.dtl.filter.htmlstrings"] = true; +dojo.provide("dojox.dtl.filter.htmlstrings"); + +dojo.require("dojox.dtl._base"); + +dojo.mixin(dojox.dtl.filter.htmlstrings, { + _escapeamp: /&/g, + _escapelt: //g, + _escapeqt: /'/g, + _escapedblqt: /"/g, + _linebreaksrn: /(\r\n|\n\r)/g, + _linebreaksn: /\n{2,}/g, + _linebreakss: /(^\s+|\s+$)/g, + _linebreaksbr: /\n/g, + _removetagsfind: /[a-z0-9]+/g, + _striptags: /<[^>]*?>/g, + escape: function(value){ + // summary: Escapes a string's HTML + var dh = dojox.dtl.filter.htmlstrings; + return value.replace(dh._escapeamp, '&').replace(dh._escapelt, '<').replace(dh._escapegt, '>').replace(dh._escapedblqt, '"').replace(dh._escapeqt, '''); + }, + linebreaks: function(value){ + // summary: Converts newlines into

    and
    s + var output = []; + var dh = dojox.dtl.filter.htmlstrings; + value = value.replace(dh._linebreaksrn, "\n"); + var parts = value.split(dh._linebreaksn); + for(var i = 0; i < parts.length; i++){ + var part = parts[i].replace(dh._linebreakss, "").replace(dh._linebreaksbr, "
    ") + output.push("

    " + part + "

    "); + } + + return output.join("\n\n"); + }, + linebreaksbr: function(value){ + // summary: Converts newlines into
    s + var dh = dojox.dtl.filter.htmlstrings; + return value.replace(dh._linebreaksrn, "\n").replace(dh._linebreaksbr, "
    "); + }, + removetags: function(value, arg){ + // summary: Removes a space separated list of [X]HTML tags from the output" + var dh = dojox.dtl.filter.htmlstrings; + var tags = []; + var group; + while(group = dh._removetagsfind.exec(arg)){ + tags.push(group[0]); + } + tags = "(" + tags.join("|") + ")"; + return value.replace(new RegExp("]*>", "gi"), ""); + }, + striptags: function(value){ + // summary: Strips all [X]HTML tags + return value.replace(dojox.dtl.filter.htmlstrings._striptags, ""); + } +}); + +} diff --git a/includes/js/dojox/dtl/filter/integers.js b/includes/js/dojox/dtl/filter/integers.js new file mode 100644 index 0000000..0c54a90 --- /dev/null +++ b/includes/js/dojox/dtl/filter/integers.js @@ -0,0 +1,32 @@ +if(!dojo._hasResource["dojox.dtl.filter.integers"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.dtl.filter.integers"] = true; +dojo.provide("dojox.dtl.filter.integers"); + +dojo.mixin(dojox.dtl.filter.integers, { + add: function(value, arg){ + value = parseInt(value); + arg = parseInt(arg); + return isNaN(arg) ? value : value + arg; + }, + get_digit: function(value, arg){ + // summary: + // Given a whole number, returns the 1-based requested digit of it + // desciprtion: + // 1 is the right-most digit, 2 is the second-right-most digit, etc. Returns the + // original value for invalid input (if input or argument is not an integer, + // or if argument is less than 1). Otherwise, output is always an integer. + value = parseInt(value); + arg = parseInt(arg) - 1; + if(arg >= 0){ + value += ""; + if(arg < value.length){ + value = parseInt(value.charAt(arg)); + }else{ + value = 0; + } + } + return (isNaN(value) ? 0 : value); + } +}); + +} diff --git a/includes/js/dojox/dtl/filter/lists.js b/includes/js/dojox/dtl/filter/lists.js new file mode 100644 index 0000000..b095242 --- /dev/null +++ b/includes/js/dojox/dtl/filter/lists.js @@ -0,0 +1,137 @@ +if(!dojo._hasResource["dojox.dtl.filter.lists"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.dtl.filter.lists"] = true; +dojo.provide("dojox.dtl.filter.lists") + +dojo.require("dojox.dtl._base"); + +dojo.mixin(dojox.dtl.filter.lists, { + _dictsort: function(a, b){ + if(a[0] == b[0]) return 0; + return (a[0] < b[0]) ? -1 : 1; + }, + dictsort: function(value, arg){ + // summary: Takes a list of dicts, returns that list sorted by the property given in the argument. + if(!arg) return value; + + var i, item, items = []; + if(!dojo.isArray(value)){ + var obj = value, value = []; + for(var key in obj){ + value.push(obj[k]); + } + } + for(i = 0; i < value.length; i++){ + items.push([new dojox.dtl._Filter('var.' + arg).resolve(new dojox.dtl._Context({ 'var' : value[i]})), value[i]]); + } + items.sort(dojox.dtl.filter.lists._dictsort); + var output = []; + for(i = 0; item = items[i]; i++){ + output.push(item[1]); + } + return output; + }, + dictsortreversed: function(value, arg){ + // summary: Takes a list of dicts, returns that list sorted in reverse order by the property given in the argument. + if(!arg) return value; + + var dictsort = dojox.dtl.filter.lists.dictsort(value, arg); + return dictsort.reverse(); + }, + first: function(value){ + // summary: Returns the first item in a list + return (value.length) ? value[0] : ""; + }, + join: function(value, arg){ + // summary: Joins a list with a string, like Python's ``str.join(list)`` + // description: + // Django throws a compile error, but JS can't do arg checks + // so we're left with run time errors, which aren't wise for something + // as trivial here as an empty arg. + return value.join(arg || ","); + }, + length: function(value){ + // summary: Returns the length of the value - useful for lists + return (isNaN(value.length)) ? (value + "").length : value.length; + }, + length_is: function(value, arg){ + // summary: Returns a boolean of whether the value's length is the argument + return value.length == parseInt(arg); + }, + random: function(value){ + // summary: Returns a random item from the list + return value[Math.floor(Math.random() * value.length)]; + }, + slice: function(value, arg){ + // summary: Returns a slice of the list. + // description: + // Uses the same syntax as Python's list slicing; see + // http://diveintopython.org/native_data_types/lists.html#odbchelper.list.slice + // for an introduction. + // Also uses the optional third value to denote every X item. + arg = arg || ""; + var parts = arg.split(":"); + var bits = []; + for(var i = 0; i < parts.length; i++){ + if(!parts[i].length){ + bits.push(null); + }else{ + bits.push(parseInt(parts[i])); + } + } + + if(bits[0] === null){ + bits[0] = 0; + } + if(bits[0] < 0){ + bits[0] = value.length + bits[0]; + } + if(bits.length < 2 || bits[1] === null){ + bits[1] = value.length; + } + if(bits[1] < 0){ + bits[1] = value.length + bits[1]; + } + + return value.slice(bits[0], bits[1]); + }, + _unordered_list: function(value, tabs){ + var ddl = dojox.dtl.filter.lists; + var i, indent = ""; + for(i = 0; i < tabs; i++){ + indent += "\t"; + } + if(value[1] && value[1].length){ + var recurse = []; + for(i = 0; i < value[1].length; i++){ + recurse.push(ddl._unordered_list(value[1][i], tabs + 1)) + } + return indent + "
  • " + value[0] + "\n" + indent + "
      \n" + recurse.join("\n") + "\n" + indent + "
    \n" + indent + "
  • "; + }else{ + return indent + "
  • " + value[0] + "
  • "; + } + }, + unordered_list: function(value){ + // summary: + // Recursively takes a self-nested list and returns an HTML unordered list -- + // WITHOUT opening and closing