diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 412eeda..0000000 --- a/.gitattributes +++ /dev/null @@ -1,22 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp -*.sln merge=union -*.csproj merge=union -*.vbproj merge=union -*.fsproj merge=union -*.dbproj merge=union - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 3835d69..0000000 --- a/.gitignore +++ /dev/null @@ -1,217 +0,0 @@ -bower_components/ -node_modules/ - -################# -## Eclipse -################# - -*.pydevproject -.project -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.settings/ -.loadpath - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - - -################# -## Visual Studio -################# - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Bb]in/ -[Oo]bj/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.log -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -.*crunch*.local.xml - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml -*.pubxml - -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -#packages/ - -# Windows Azure Build Output -csx -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml -*.pfx -*.publishsettings - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -App_Data/*.mdf -App_Data/*.ldf - -############# -## Windows detritus -############# - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Mac crap -.DS_Store - - -############# -## Python -############# - -*.py[co] - -# Packages -*.egg -*.egg-info -build/ -eggs/ -parts/ -var/ -sdist/ -develop-eggs/ -.installed.cfg - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox - -#Translations -*.mo - -#Mr Developer -.mr.developer.cfg diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6282792..0000000 --- a/.travis.yml +++ /dev/null @@ -1,2 +0,0 @@ -before_script : cd tests -script: phantomjs phantom.js diff --git a/Examples/ExampleSearchResults/Services/searchResults.txt b/Examples/ExampleSearchResults/Services/searchResults.txt index 544cf01..3fa09c0 100644 --- a/Examples/ExampleSearchResults/Services/searchResults.txt +++ b/Examples/ExampleSearchResults/Services/searchResults.txt @@ -2,7 +2,7 @@ { "id": 2, "name": "An ice sculpture", - "price": 0.00, + "price": 12.50, "tags": ["cold", "ice", "sculpture"], "dimensions": { "length": 7.0, diff --git a/Examples/ExampleSearchResults/Templates/SearchResult.html b/Examples/ExampleSearchResults/Templates/SearchResult.html index fc483d5..70714fe 100644 --- a/Examples/ExampleSearchResults/Templates/SearchResult.html +++ b/Examples/ExampleSearchResults/Templates/SearchResult.html @@ -1,7 +1,7 @@ - + diff --git a/Examples/ExampleSearchResults/search.html b/Examples/ExampleSearchResults/search.html index f1c2f13..95fd493 100644 --- a/Examples/ExampleSearchResults/search.html +++ b/Examples/ExampleSearchResults/search.html @@ -24,12 +24,10 @@

Example of using jQuery.loadTemplate for improved search.

-
- - - - - - - - - - - -
-Loaded with function parameters -
-
- -
- -
-Loaded with template parameters -
-
- -
- -
-Loaded with template as data-bind-template attribute -
-
- -
-Loaded with nested template with function parameters -
-
- diff --git a/Examples/SimpleExample/Templates/simple.html b/Examples/SimpleExample/Templates/simple.html index 2e75af5..ce1e7fd 100644 --- a/Examples/SimpleExample/Templates/simple.html +++ b/Examples/SimpleExample/Templates/simple.html @@ -2,11 +2,8 @@
- -
-
-
+ {"attribute": "content", "value": "post"}, + {"attribute": "data-date", "value": "date"}, + {"attribute": "data-author", "value": "author", "formatter": "sameCaseFormatter", "formatTemplate": "upper"}]'> + \ No newline at end of file diff --git a/Examples/SimpleExample/example.html b/Examples/SimpleExample/example.html index d54b719..c135373 100644 --- a/Examples/SimpleExample/example.html +++ b/Examples/SimpleExample/example.html @@ -9,113 +9,62 @@

Example of loading a template from a script tag within the same document.
- - -
- -
- - - - - - - - - - + }); + \ No newline at end of file diff --git a/Examples/index.html b/Examples/index.html index f14d59a..a68ca08 100644 --- a/Examples/index.html +++ b/Examples/index.html @@ -1,4 +1,5 @@ + @@ -8,8 +9,8 @@ - - + +
@@ -21,9 +22,10 @@

Examples of jQuery.loadTemplate

@@ -49,7 +51,7 @@

Code

\r\n\r\nAnd to use this do the following:\r\n\r\n $(\"#template-container\").loadTemplate($(\"#template\"),\r\n\t\t{\r\n author: 'Joe Bloggs',\r\n date: '25th May 2013',\r\n authorPicture: 'Authors/JoeBloggs.jpg',\r\n post: 'This is the contents of my post'\r\n });\r\n\r\nSimilarly the content of the template could be held in a separate html file without the enclosing script tag, and used like the following:\r\n\r\n $(\"#template-container\").loadTemplate(\"Templates/template.html\",\r\n\t\t{\r\n author: 'Joe Bloggs',\r\n date: '25th May 2013',\r\n authorPicture: 'Authors/JoeBloggs.jpg',\r\n post: 'This is the contents of my post'\r\n });\r\n\r\nThe plugin has a number of data-... attributes that can be used to populate various attributes with the data. There is also the powerful data-template-bind attribute that accepts a JSON object, enabling binding to any attribute, or the content of the element.\r\n\r\n### Data Formatters\r\n\r\nIt is also possible to define data formatters. These are assigned through the `$.addTemplateFormatter` method. This function either accepts a map of functions and the keys that they will be referenced by, or a single function with a single key as two separate parameters. Each formatter takes two values, the value being assigned, and a template to use to define how this data is displayed. The data-format-template may be empty. Example usage of this is below:\r\n\r\n $.addTemplateFormatter(\"UpperCaseFormatter\",\r\n function(value, template) {\r\n return value.toUpperCase();\r\n });\r\n\r\nAlternatively with a map:\r\n\r\n $.addTemplateFormatter({\r\n UpperCaseFormatter : function(value, template) {\r\n return value.toUpperCase();\r\n },\r\n LowerCaseFormatter : function(value, template) {\r\n return value.toLowerCase();\r\n },\r\n SameCaseFormatter : function(value, template) {\r\n if(template == \"upper\") {\r\n\t\t\t\t\treturn value.toUpperCase();\r\n\t\t\t\t} else {\r\n\t\t\t\t\treturn value.toLowerCase();\r\n\t\t\t\t}\r\n }\r\n });\r\n\r\nTo call these formatters, simply the following will work:\r\n\r\n\t
\r\n\r\nFormatters must be added before they are used else a template will not be able to access them. Formatters are used at the time of populating the data. You can also target any binding with the \"data-format-target\". The value of this is the binding to target so to target data-alt binding, set 'data-format-target=\"alt\"'.\r\n\r\n### Options\r\n\r\nThere are a number of options the plugin accepts. These are:\r\n\r\n- \"overwriteCache\" (default false) - Whether to ignore the cache and reload the template (if you've previously loaded the template, but it might have changed, you'll want to set this to true.\r\n- \"complete\" (default null) - Callback function to call on complete. Will always be called regardless of success or failure.\r\n- \"success\" (default null) - Callback function to call on successful completion.\r\n- \"error\" (default, outputting error message to template container) - Callback function to call on error.\r\n- \"errorMessage\" (default \"There was an error loading the template.\") - Error message for the default error callback to use. This will not be used if you set an error callback function.\r\n- \"isFile\" (default undefined) - flag to help speed up the process of deciding where to load the template from. Set to true if the template is an external file to load via ajax, false if it's a jQuery selector for an element in the document. Default undefined means the plugin will check first in the document, then attempt to load external file.\r\n- \"paged\" (default false) - A boolean flag to indicate whether arrays should be paged.\r\n- \"pageNo\" (default 1) - An integer for which page to display if the data is being paged.\r\n- \"elemPerPage\" (default 10) - The number of elements to display per page if the data is being paged.\r\n\r\n## Future Plans\r\n\r\nI would like to develop the plugin further so it would be possible to watch the objects holding the data, so any changes to the data would be reflected in the UI. This would have to be simple, lightweight, and ideally would work just with natural JavaScript objects. I also welcome any ideas as to how the plugin could be improved.","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file diff --git a/readme.md b/readme.md deleted file mode 100644 index 3b0970f..0000000 --- a/readme.md +++ /dev/null @@ -1,160 +0,0 @@ -# jQuery.loadTemplate -[![CDNJS version](https://img.shields.io/cdnjs/v/jquery.loadtemplate.svg)](https://cdnjs.com/libraries/jquery.loadtemplate) - -jQuery Template is a jQuery plugin that makes using templates easy and quick. The plugin supports loading HTML files as templates, or taking a jQuery object as the template (usually using script tags to hold the template). - -## Features - -jQuery.LoadTemplate provides the following: - -- Define Templates to display data -- Provide Formatters to process data into a more readable format -- Cache templates and data client side and pass processing to the client, allowing for a great user experience. -- Powerful but simple syntax, utilising pure html for templates. - -## Getting Started - -Simply clone the repo. The only file required is the jquery.loadTemplate-version.js file in the jquery.loadTemplate folder. There is also a folder for examples in the same folder. Take a look at the index file in here for examples and the code to create the examples. - -To see examples of usage, visit the project page: [http://codepb.github.io/jquery-template/](http://codepb.github.io/jquery-template/) - -## Potential Applications - -jQuery.loadTemplate was originally designed with a single page application for a blog in mind. The idea was to create templates for blog posts, post snippets, etc. This could then be called from the client when required, and cached. The post data was sent as a JSON object from the server, and processed into the templates using the plugin. This meant a very light load on the server, and a great user experience, with smooth page transitions, and JavaScript engines doing all the work. - -However I saw many other potential applications for this. Any application that deals with a large amount of data displayed in a regular format, for example search results, live commentary, blogs, online stores, social media sites, and the list could go on. - -## How it works - -The plugin parses a template using data attributes to populate the data. Simply pass in a JavaScript object, and the plugin does the rest. - -An example template is below: - - - -And to use this do the following: - - $("#template-container").loadTemplate($("#template"), - { - author: 'Joe Bloggs', - date: '25th May 2013', - authorPicture: 'Authors/JoeBloggs.jpg', - post: 'This is the contents of my post' - }); - -Similarly the content of the template could be held in a separate html file without the enclosing script tag, and used like the following: - - $("#template-container").loadTemplate("Templates/template.html", - { - author: 'Joe Bloggs', - date: '25th May 2013', - authorPicture: 'Authors/JoeBloggs.jpg', - post: 'This is the contents of my post' - }); - -The plugin has a number of data-... attributes that can be used to populate various attributes with the data. There is also the powerful data-template-bind attribute that accepts a JSON object, enabling binding to any attribute, or the content of the element. - -#### Arrays - -You can pass an array of objects instead of a single object and the template will be populated and added to the container for each item in the array. There are options built in that allow you to page the results from an array as well. See the options section below and the included examples. - -### Data Formatters - -It is also possible to define data formatters. These are assigned through the `$.addTemplateFormatter` method. This function either accepts a map of functions and the keys that they will be referenced by, or a single function with a single key as two separate parameters. Each formatter takes two values, the value being assigned, and a template to use to define how this data is displayed. The data-format-options may be empty. Example usage of this is below: - - $.addTemplateFormatter("UpperCaseFormatter", - function(value, template) { - return value.toUpperCase(); - }); - -Alternatively with a map: - - $.addTemplateFormatter({ - UpperCaseFormatter : function(value, template) { - return value.toUpperCase(); - }, - LowerCaseFormatter : function(value, template) { - return value.toLowerCase(); - }, - SameCaseFormatter : function(value, template) { - if(template == "upper") { - return value.toUpperCase(); - } else { - return value.toLowerCase(); - } - } - }); - -To call these formatters, simply the following will work: - -
- -Formatters must be added before they are used else a template will not be able to access them. Formatters are used at the time of populating the data. You can also target any binding with the "data-format-target". The value of this is the binding to target so to target data-alt binding, set 'data-format-target="alt"'. - -### Bindings -There are a number of different bindings and ways to bind the data. The following attributes are available: - -- "data-innerHTML" (>= 1.4.5) - binds the value supplied to the content (innerHTML) of the element (uses $(elem).html(value)) -- "data-content" - alias for the newer "data-innerHTML" -- "data-content-text" - binds the value supplied to the content of the element as text (uses $(elem).text(value)) -- "data-content-append" - appends the value to the end of the element (uses $(elem).append(value)) -- "data-content-prepend" - prepends the value to the beginning of the element (uses $(elem).prepend(value)) -- "data-id" - sets the id of the element to the value provided (uses $(elem).attr("id", value)); -- "data-href" - sets the href value of the element to the value provided (uses $(elem).attr("href", value)); -- "data-alt" - sets the alt value of the element to the value provided (uses $(elem).attr("alt", value)); -- "data-value" - sets the value attribute of the element to the value provided (uses $(elem).val(value)) -- "data-class" - sets the class attribute of the element to the value provided (uses $(elem).class(value)) -- "data-css" - sets the CSS attribute of the element to the value provided (uses $(elem).css(value)) -- "data-link" - sets the innerHtml of the element to be a link to the value provided (wraps the content in an <a> tag). -- "data-link-wrap" - wraps the element in a link to the value provided. Same as "data-link", but the <a> tag wraps the element as well as the content. -- "data-options" - adds options to a select box. The value for this should reference an array of strings, each option will be output as a separate option. The value will be the same as the displayed text for each option. For a more powerful version of this look at the data-template-bind option. - -On top of the attributes above, there is also a "data-template-bind" attribute. This is designed to handle more complex situations and allows a wide range of control. The attribute takes a JSON string and allows multiple bindings and options to be set in the one attribute. - -The "data-template-bind" value should be an array of objects. Each object represents one complete binding. Each object can contain the following properties: - -- "value" (required) - The property representing the value to bind to. -- "attribute" (required) - The attribute to bind to. This can be any attribute accepted by the jQuery.attr() method or one of the following: "content" - same as data-content, binds the innerHTML, "contentAppend" - same as data-append, appends the value, "contentPrepend" - same as data-prepend, prepends the value, "options" - same as data-options, but provides greater control. The value attribute for this is an object with a value property and a content property, and this will bind the value of the option to the value property, and the innerText of the option to the content property. -- "formatter" (optional) - provides the formatter to apply to the specific binding. Multiple different attributes can use different formatters using this syntax. -- "formatOptions" (optional) - the options to pass to the formatter applied. - -An example of using the "data-template-bind" attribute would be the following: - -
- -### Options - -There are a number of options the plugin accepts. These can be set by passing an object containing the settings you would like to set as the third parameter to .loadTemplate: - - $(container).loadTemplate(template, data, { append: true, elemPerPage: 20 }); - -The full list of options are: - -- "overwriteCache" (default false) - Whether to ignore the cache and reload the template (if you've previously loaded the template, but it might have changed, you'll want to set this to true. -- "async" (default true) - Whether to load templates asynchronously (if templates require an Ajax call) -- "complete" (default null) - Callback function to call on complete. Will always be called regardless of success or failure. -- "success" (default null) - Callback function to call on successful completion. -- "error" (default, outputting error message to template container) - Callback function to call on error. -- "errorMessage" (default "There was an error loading the template.") - Error message for the default error callback to use. This will not be used if you set an error callback function. -- "isFile" (default undefined) - flag to help speed up the process of deciding where to load the template from. Set to true if the template is an external file to load via ajax, false if it's a jQuery selector for an element in the document. Default undefined means the plugin will check first in the document, then attempt to load external file. -- "paged" (default false) - A boolean flag to indicate whether arrays should be paged. -- "pageNo" (default 1) - An integer for which page to display if the data is being paged. -- "elemPerPage" (default 10) - The number of elements to display per page if the data is being paged. -- "append" (default false) - If set to true, the template will be appended to the element rather than replacing the contents of the element. -- "prepend" (default false) - If set to true, the template will be prepended to the element rather than replacing the contents of the element. The append option takes priority over prepend, so if both options are set to true, the element is appended and not prepended. -- "beforeInsert" (default null) - Callback function to be called before inserting the template into the document. The format of the function is function($elem) where $elem is the jQuery object of the populated template about to be inserted into the document. -- "afterInsert" (default null) - As above, a callback function to be called after inserting the template into the document. The format is the same as above. -- "bindingOptions" (default all flags false): add flags to ignore certain types of values. {"ignoreUndefined": false, "ignoreNull": false, "ignoreEmptyString": false}. The flags you set here, are overwritten on an element level by those specified in a template with a "data-binding-options" or a "data-template-bind" attribute. Examples can be found in the Examples/OptionalBinding folder. - -## Future Plans - -I would like to develop the plugin further so it would be possible to watch the objects holding the data, so any changes to the data would be reflected in the UI. This would have to be simple, lightweight, and ideally would work just with natural JavaScript objects. I also welcome any ideas as to how the plugin could be improved. diff --git a/stylesheets/print.css b/stylesheets/print.css new file mode 100644 index 0000000..541695b --- /dev/null +++ b/stylesheets/print.css @@ -0,0 +1,226 @@ +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} +body { + font-size: 13px; + line-height: 1.5; + font-family: 'Helvetica Neue', Helvetica, Arial, serif; + color: #000; +} + +a { + color: #d5000d; + font-weight: bold; +} + +header { + padding-top: 35px; + padding-bottom: 10px; +} + +header h1 { + font-weight: bold; + letter-spacing: -1px; + font-size: 48px; + color: #303030; + line-height: 1.2; +} + +header h2 { + letter-spacing: -1px; + font-size: 24px; + color: #aaa; + font-weight: normal; + line-height: 1.3; +} +#downloads { + display: none; +} +#main_content { + padding-top: 20px; +} + +code, pre { + font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal; + color: #222; + margin-bottom: 30px; + font-size: 12px; +} + +code { + padding: 0 3px; +} + +pre { + border: solid 1px #ddd; + padding: 20px; + overflow: auto; +} +pre code { + padding: 0; +} + +ul, ol, dl { + margin-bottom: 20px; +} + + +/* COMMON STYLES */ + +table { + width: 100%; + border: 1px solid #ebebeb; +} + +th { + font-weight: 500; +} + +td { + border: 1px solid #ebebeb; + text-align: center; + font-weight: 300; +} + +form { + background: #f2f2f2; + padding: 20px; + +} + + +/* GENERAL ELEMENT TYPE STYLES */ + +h1 { + font-size: 2.8em; +} + +h2 { + font-size: 22px; + font-weight: bold; + color: #303030; + margin-bottom: 8px; +} + +h3 { + color: #d5000d; + font-size: 18px; + font-weight: bold; + margin-bottom: 8px; +} + +h4 { + font-size: 16px; + color: #303030; + font-weight: bold; +} + +h5 { + font-size: 1em; + color: #303030; +} + +h6 { + font-size: .8em; + color: #303030; +} + +p { + font-weight: 300; + margin-bottom: 20px; +} + +a { + text-decoration: none; +} + +p a { + font-weight: 400; +} + +blockquote { + font-size: 1.6em; + border-left: 10px solid #e9e9e9; + margin-bottom: 20px; + padding: 0 0 0 30px; +} + +ul li { + list-style: disc inside; + padding-left: 20px; +} + +ol li { + list-style: decimal inside; + padding-left: 3px; +} + +dl dd { + font-style: italic; + font-weight: 100; +} + +footer { + margin-top: 40px; + padding-top: 20px; + padding-bottom: 30px; + font-size: 13px; + color: #aaa; +} + +footer a { + color: #666; +} + +/* MISC */ +.clearfix:after { + clear: both; + content: '.'; + display: block; + visibility: hidden; + height: 0; +} + +.clearfix {display: inline-block;} +* html .clearfix {height: 1%;} +.clearfix {display: block;} \ No newline at end of file diff --git a/stylesheets/pygment_trac.css b/stylesheets/pygment_trac.css new file mode 100644 index 0000000..c6a6452 --- /dev/null +++ b/stylesheets/pygment_trac.css @@ -0,0 +1,69 @@ +.highlight { background: #ffffff; } +.highlight .c { color: #999988; font-style: italic } /* Comment */ +.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ +.highlight .k { font-weight: bold } /* Keyword */ +.highlight .o { font-weight: bold } /* Operator */ +.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */ +.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */ +.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ +.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */ +.highlight .ge { font-style: italic } /* Generic.Emph */ +.highlight .gr { color: #aa0000 } /* Generic.Error */ +.highlight .gh { color: #999999 } /* Generic.Heading */ +.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ +.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */ +.highlight .go { color: #888888 } /* Generic.Output */ +.highlight .gp { color: #555555 } /* Generic.Prompt */ +.highlight .gs { font-weight: bold } /* Generic.Strong */ +.highlight .gu { color: #800080; font-weight: bold; } /* Generic.Subheading */ +.highlight .gt { color: #aa0000 } /* Generic.Traceback */ +.highlight .kc { font-weight: bold } /* Keyword.Constant */ +.highlight .kd { font-weight: bold } /* Keyword.Declaration */ +.highlight .kn { font-weight: bold } /* Keyword.Namespace */ +.highlight .kp { font-weight: bold } /* Keyword.Pseudo */ +.highlight .kr { font-weight: bold } /* Keyword.Reserved */ +.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */ +.highlight .m { color: #009999 } /* Literal.Number */ +.highlight .s { color: #d14 } /* Literal.String */ +.highlight .na { color: #008080 } /* Name.Attribute */ +.highlight .nb { color: #0086B3 } /* Name.Builtin */ +.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */ +.highlight .no { color: #008080 } /* Name.Constant */ +.highlight .ni { color: #800080 } /* Name.Entity */ +.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */ +.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */ +.highlight .nn { color: #555555 } /* Name.Namespace */ +.highlight .nt { color: #000080 } /* Name.Tag */ +.highlight .nv { color: #008080 } /* Name.Variable */ +.highlight .ow { font-weight: bold } /* Operator.Word */ +.highlight .w { color: #bbbbbb } /* Text.Whitespace */ +.highlight .mf { color: #009999 } /* Literal.Number.Float */ +.highlight .mh { color: #009999 } /* Literal.Number.Hex */ +.highlight .mi { color: #009999 } /* Literal.Number.Integer */ +.highlight .mo { color: #009999 } /* Literal.Number.Oct */ +.highlight .sb { color: #d14 } /* Literal.String.Backtick */ +.highlight .sc { color: #d14 } /* Literal.String.Char */ +.highlight .sd { color: #d14 } /* Literal.String.Doc */ +.highlight .s2 { color: #d14 } /* Literal.String.Double */ +.highlight .se { color: #d14 } /* Literal.String.Escape */ +.highlight .sh { color: #d14 } /* Literal.String.Heredoc */ +.highlight .si { color: #d14 } /* Literal.String.Interpol */ +.highlight .sx { color: #d14 } /* Literal.String.Other */ +.highlight .sr { color: #009926 } /* Literal.String.Regex */ +.highlight .s1 { color: #d14 } /* Literal.String.Single */ +.highlight .ss { color: #990073 } /* Literal.String.Symbol */ +.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */ +.highlight .vc { color: #008080 } /* Name.Variable.Class */ +.highlight .vg { color: #008080 } /* Name.Variable.Global */ +.highlight .vi { color: #008080 } /* Name.Variable.Instance */ +.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */ + +.type-csharp .highlight .k { color: #0000FF } +.type-csharp .highlight .kt { color: #0000FF } +.type-csharp .highlight .nf { color: #000000; font-weight: normal } +.type-csharp .highlight .nc { color: #2B91AF } +.type-csharp .highlight .nn { color: #000000 } +.type-csharp .highlight .s { color: #A31515 } +.type-csharp .highlight .sc { color: #A31515 } diff --git a/stylesheets/stylesheet.css b/stylesheets/stylesheet.css new file mode 100644 index 0000000..020ad6d --- /dev/null +++ b/stylesheets/stylesheet.css @@ -0,0 +1,371 @@ +/* http://meyerweb.com/eric/tools/css/reset/ + v2.0 | 20110126 + License: none (public domain) +*/ +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} + +/* LAYOUT STYLES */ +body { + font-size: 1em; + line-height: 1.5; + background: #e7e7e7 url(../images/body-bg.png) 0 0 repeat; + font-family: 'Helvetica Neue', Helvetica, Arial, serif; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8); + color: #6d6d6d; +} + +a { + color: #d5000d; +} +a:hover { + color: #c5000c; +} + +header { + padding-top: 35px; + padding-bottom: 25px; +} + +header h1 { + font-family: 'Chivo', 'Helvetica Neue', Helvetica, Arial, serif; font-weight: 900; + letter-spacing: -1px; + font-size: 48px; + color: #303030; + line-height: 1.2; +} + +header h2 { + letter-spacing: -1px; + font-size: 24px; + color: #aaa; + font-weight: normal; + line-height: 1.3; +} + +#container { + background: transparent url(../images/highlight-bg.jpg) 50% 0 no-repeat; + min-height: 595px; +} + +.inner { + width: 620px; + margin: 0 auto; +} + +#container .inner img { + max-width: 100%; +} + +#downloads { + margin-bottom: 40px; +} + +a.button { + -moz-border-radius: 30px; + -webkit-border-radius: 30px; + border-radius: 30px; + border-top: solid 1px #cbcbcb; + border-left: solid 1px #b7b7b7; + border-right: solid 1px #b7b7b7; + border-bottom: solid 1px #b3b3b3; + color: #303030; + line-height: 25px; + font-weight: bold; + font-size: 15px; + padding: 12px 8px 12px 8px; + display: block; + float: left; + width: 179px; + margin-right: 14px; + background: #fdfdfd; /* Old browsers */ + background: -moz-linear-gradient(top, #fdfdfd 0%, #f2f2f2 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fdfdfd), color-stop(100%,#f2f2f2)); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, #fdfdfd 0%,#f2f2f2 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, #fdfdfd 0%,#f2f2f2 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, #fdfdfd 0%,#f2f2f2 100%); /* IE10+ */ + background: linear-gradient(top, #fdfdfd 0%,#f2f2f2 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fdfdfd', endColorstr='#f2f2f2',GradientType=0 ); /* IE6-9 */ + -webkit-box-shadow: 10px 10px 5px #888; + -moz-box-shadow: 10px 10px 5px #888; + box-shadow: 0px 1px 5px #e8e8e8; +} +a.button:hover { + border-top: solid 1px #b7b7b7; + border-left: solid 1px #b3b3b3; + border-right: solid 1px #b3b3b3; + border-bottom: solid 1px #b3b3b3; + background: #fafafa; /* Old browsers */ + background: -moz-linear-gradient(top, #fdfdfd 0%, #f6f6f6 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fdfdfd), color-stop(100%,#f6f6f6)); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, #fdfdfd 0%,#f6f6f6 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, #fdfdfd 0%,#f6f6f6 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, #fdfdfd 0%,#f6f6f6 100%); /* IE10+ */ + background: linear-gradient(top, #fdfdfd 0%,#f6f6f6, 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fdfdfd', endColorstr='#f6f6f6',GradientType=0 ); /* IE6-9 */ +} + +a.button span { + padding-left: 50px; + display: block; + height: 23px; +} + +#download-zip span { + background: transparent url(../images/zip-icon.png) 12px 50% no-repeat; +} +#download-tar-gz span { + background: transparent url(../images/tar-gz-icon.png) 12px 50% no-repeat; +} +#view-on-github span { + background: transparent url(../images/octocat-icon.png) 12px 50% no-repeat; +} +#view-on-github { + margin-right: 0; +} + +code, pre { + font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal; + color: #222; + margin-bottom: 30px; + font-size: 14px; +} + +code { + background-color: #f2f2f2; + border: solid 1px #ddd; + padding: 0 3px; +} + +pre { + padding: 20px; + background: #303030; + color: #f2f2f2; + text-shadow: none; + overflow: auto; +} +pre code { + color: #f2f2f2; + background-color: #303030; + border: none; + padding: 0; +} + +ul, ol, dl { + margin-bottom: 20px; +} + + +/* COMMON STYLES */ + +hr { + height: 1px; + line-height: 1px; + margin-top: 1em; + padding-bottom: 1em; + border: none; + background: transparent url('../images/hr.png') 50% 0 no-repeat; +} + +strong { + font-weight: bold; +} + +em { + font-style: italic; +} + +table { + width: 100%; + border: 1px solid #ebebeb; +} + +th { + font-weight: 500; +} + +td { + border: 1px solid #ebebeb; + text-align: center; + font-weight: 300; +} + +form { + background: #f2f2f2; + padding: 20px; + +} + + +/* GENERAL ELEMENT TYPE STYLES */ + +h1 { + font-size: 32px; +} + +h2 { + font-size: 22px; + font-weight: bold; + color: #303030; + margin-bottom: 8px; +} + +h3 { + color: #d5000d; + font-size: 18px; + font-weight: bold; + margin-bottom: 8px; +} + +h4 { + font-size: 16px; + color: #303030; + font-weight: bold; +} + +h5 { + font-size: 1em; + color: #303030; +} + +h6 { + font-size: .8em; + color: #303030; +} + +p { + font-weight: 300; + margin-bottom: 20px; +} + +a { + text-decoration: none; +} + +p a { + font-weight: 400; +} + +blockquote { + font-size: 1.6em; + border-left: 10px solid #e9e9e9; + margin-bottom: 20px; + padding: 0 0 0 30px; +} + +ul li { + list-style: disc inside; + padding-left: 20px; +} + +ol li { + list-style: decimal inside; + padding-left: 3px; +} + +dl dt { + color: #303030; +} + +footer { + background: transparent url('../images/hr.png') 0 0 no-repeat; + margin-top: 40px; + padding-top: 20px; + padding-bottom: 30px; + font-size: 13px; + color: #aaa; +} + +footer a { + color: #666; +} +footer a:hover { + color: #444; +} + +/* MISC */ +.clearfix:after { + clear: both; + content: '.'; + display: block; + visibility: hidden; + height: 0; +} + +.clearfix {display: inline-block;} +* html .clearfix {height: 1%;} +.clearfix {display: block;} + +/* #Media Queries +================================================== */ + +/* Smaller than standard 960 (devices and browsers) */ +@media only screen and (max-width: 959px) {} + +/* Tablet Portrait size to standard 960 (devices and browsers) */ +@media only screen and (min-width: 768px) and (max-width: 959px) {} + +/* All Mobile Sizes (devices and browser) */ +@media only screen and (max-width: 767px) { + header { + padding-top: 10px; + padding-bottom: 10px; + } + #downloads { + margin-bottom: 25px; + } + #download-zip, #download-tar-gz { + display: none; + } + .inner { + width: 94%; + margin: 0 auto; + } +} + +/* Mobile Landscape Size to Tablet Portrait (devices and browsers) */ +@media only screen and (min-width: 480px) and (max-width: 767px) {} + +/* Mobile Portrait Size to Mobile Landscape Size (devices and browsers) */ +@media only screen and (max-width: 479px) {} diff --git a/tests/files/bindingOptions.js b/tests/files/bindingOptions.js deleted file mode 100644 index 5497175..0000000 --- a/tests/files/bindingOptions.js +++ /dev/null @@ -1,79 +0,0 @@ -(function () { - - var data = [{ - "title": "Super Mario World 2", - "subtitle": "Yoshi's Island" - },{ - "title": "The Little Prince", - "subtitle": null - },{ - "title": "The Da Vinci Code" - },{ - "title": "Lord of the Flies", - "subtitle": "" - }]; - - function testLoadWithFunctionParameters() { - $("#bindingOptionsContainer").loadTemplate($("#templateWithoutBindingOptions"), data, {bindingOptions: {"ignoreUndefined": true, "ignoreNull": true, "ignoreEmptyString": true}}); - } - - function testLoadWithTemplateAttributes() { - $("#bindingOptionsContainer").loadTemplate($("#templateWithBindingOptions"), data); - } - - function testLoadTemplateWithBindingOptionsInDataTemplateBindAttribute() { - $("#bindingOptionsContainer").loadTemplate($("#templateWithBindingOptionsAsDataBindTemplateAttribute"), data); - } - - function test(assert, async) { - return [ - { - name: "jQuery Loaded", - test: function () { - assert(jQuery); - } - }, - { - name: "loadTemplate Loaded", - test: function () { - assert(typeof $.fn.loadTemplate === 'function'); - } - }, - { - name: "Load template with binding options as function parameters", - test: function () { - testLoadWithFunctionParameters(); - - var childs = $('#bindingOptionsContainer h4').length; - assert(childs === 1); - } - }, - { - name: "Load template with binding options as template attributes", - setup: function () { - $('#bindingOptionsContainer').empty(); - }, - test: function () { - testLoadWithTemplateAttributes(); - - var childs = $('#bindingOptionsContainer h4').length; - assert(childs === 1); - } - }, - { - name: "Load template with binding options in 'data-template-bind' attribute", - setup: function () { - $('#bindingOptionsContainer').empty(); - }, - test: function () { - testLoadTemplateWithBindingOptionsInDataTemplateBindAttribute(); - - var childs = $('#bindingOptionsContainer h4').length; - assert(childs === 1); - } - }]; - } - - addTests(test); - -})(); diff --git a/tests/files/callback.js b/tests/files/callback.js deleted file mode 100644 index 40abd43..0000000 --- a/tests/files/callback.js +++ /dev/null @@ -1,103 +0,0 @@ -(function(){ - var data = [ - { - "name" : "test1", - "id" : 1 - }, - { - "name" : "test2", - "id" : 2 - }, - { - "name" : "test3", - "id" : 3 - }, - { - "name" : "test4", - "id" : 4 - }, - { - "name" : "test5", - "id" : 5 - } - ]; - - function callback(assert){ - var beforeInsertCounter = 0, - afterInsertCounter = 0, - successCounter = 0, - errorCounter = 0, - completeCounter = 0; - - var sequence = []; - var elemSequence = []; - return { - name: "Number of Call Callbacks", - setup: function(){ - $("#render").loadTemplate("#template", data, { - beforeInsert : function(elem){ - sequence.push('before'); - - if ($('#render').children().length === beforeInsertCounter) { - elemSequence.push(true); - } - - ++beforeInsertCounter; - - - }, - afterInsert : function(elem){ - sequence.push('after'); - - ++afterInsertCounter; - - if ($('#render').children().length === afterInsertCounter) { - elemSequence.push(true); - } - - }, - complete : function(){ - sequence.push('complete'); - ++completeCounter; - }, - success : function(){ - sequence.push('success'); - ++successCounter; - }, - error : function(){ - sequence.push('error'); - ++errorCounter; - } - }); - }, - test: function () { - - //make sure every callback is being called as expected - - //before Insert & after Insert counter == 5 - //if we have an array of elements before & after inserts will be - //called before and after inserting each element - assert("Before Insert Counter 5 = " + beforeInsertCounter, 5 === beforeInsertCounter); - assert("After Insert Counter 5 = " + afterInsertCounter, 5 === afterInsertCounter); - - //no error expected - assert("Error Counter 0 = " + errorCounter, 0 === errorCounter); - - //those should be called once - assert("Success Counter 1 = " + successCounter, 1 === successCounter); - assert("Complete Counter 1 = " + completeCounter, 1 === completeCounter); - - //sequence by now should be - var expected = 'before,after,before,after,before,after,before,after,before,after,complete,success'; - var got = sequence.toString(); - assert("Sequence " + got + " = " + expected, expected == got ); - - assert("Element Sequence Call 10 == " + elemSequence.length, elemSequence.length === 10); - - } - }; - } - - addTests(callback); - -})(); diff --git a/tests/files/error.js b/tests/files/error.js deleted file mode 100644 index e33fcf4..0000000 --- a/tests/files/error.js +++ /dev/null @@ -1,95 +0,0 @@ -(function () { - var data = [ - { - "name": "test1", - "id": 1 - }, - { - "name": "test2", - "id": 2 - }, - { - "name": "test3", - "id": 3 - }, - { - "name": "test4", - "id": 4 - }, - { - "name": "test5", - "id": 5 - } - ]; - - function errorsHandle(assert, async) { - var successCounter = 0, - errorCounter = 0, - completeCounter = 0, - sequence = []; - - return { - name: "Custom Error Callback", - setup: function () { - - }, - test: function () { - $("#render").loadTemplate('test.html', data, { - complete: function () { - sequence.push('complete'); - ++completeCounter; - //success callback will not be fired - assert("Success Counter 0 = " + successCounter, 0 === successCounter); - - //error should be fired - assert("Error Counter 1 = " + errorCounter, 1 === errorCounter); - - //complete should be called even with errors - assert("Complete Counter 1 = " + completeCounter, 1 === completeCounter); - - //sequence by now should be - var expected = 'error,complete'; - var got = sequence.toString(); - assert("Sequence " + expected + " = " + got, expected == got); - }, - success: function () { - sequence.push('success'); - ++successCounter; - }, - error: function () { - sequence.push('error'); - ++errorCounter; - } - }); - - - } - }; - } - - function deafultError(assert, async) { - var successCounter = 0, - errorCounter = 0, - completeCounter = 0, - sequence = []; - - return { - name: "Default Error Callback", - setup: function () { - - }, - test: function () { - $("#render").loadTemplate('doesnotexists/test.html', data, { - complete: function () { - var got = $('#render').text(); - var expected = "There was an error loading the template."; - assert("Error Message " + expected + " = " + got, got == expected); - } - }); - } - }; - } - - addTests(errorsHandle, deafultError); - -})(); diff --git a/tests/files/formatters.js b/tests/files/formatters.js deleted file mode 100644 index bb9b986..0000000 --- a/tests/files/formatters.js +++ /dev/null @@ -1,128 +0,0 @@ -(function(){ - - var data = [ - { - "name" : "test1", - "id" : 1 - }, - { - "name" : "test2", - "id" : 2 - }, - { - "name" : "test3", - "id" : 3 - } - ]; - - //data formatters - //single data formatter - $.addTemplateFormatter("singleFormatter", - function(value, template) { - $(this).addClass('red'); - return value.toUpperCase(); - } - ); - - $.addTemplateFormatter("singleFormatter2", - function(value, template) { - return 99; - } - ); - - //multiple data formatters - $.addTemplateFormatter({ - UpperCaseFormatter : function(value, template) { - $(this).addClass('red'); - return value.toUpperCase(); - }, - idFormatter : function(value, template) { - if (value === 2){ - $(this).addClass('yellow'); - } - return 'xx'; - }, - SameCaseFormatter : function(value, template) { - if(template == "upper") { - return value.toUpperCase(); - } else { - return value.toLowerCase(); - } - } - }); - - /** - * general Formatter test - */ - function general(assert){ - return { - name: "Templates Formatter", - setup: function(){ - $("#render").loadTemplate("#template2", data); - }, - test: function () { - $('#render div.name').each(function(i){ - var val = $(this).text(); - - //all names must be in uppercases - var match = data[i].name.toUpperCase(); - assert("match " + val + " !== " + match, val === match); - - //upperCaseFormatter manipulate element by adding a red class - //check if we got that correctly - var red = $(this).hasClass('red'); - assert("has class red", red); - - //id also has been overriden to 'xx' - var id = $(this).next().text(); - assert("xx id", "xx" === id); - }); - } - }; - } - - /** - * This test make sure that all added formatters will be available - * even if we mix by adding single function formatter or multiple key - * value style - */ - function singleFormatter (assert){ - return { - name: "Single Formatter", - setup: function(){ - $("#render").loadTemplate("#template3", data); - }, - test: function () { - $('#render div.name').each(function(i){ - var val = $(this).text(); - - var match = data[i].name.toUpperCase(); - assert("match " + val + " !== " + match, val === match); - - //upperCaseFormatter manipulate element by adding a red class - //check if we got that correctly - var red = $(this).hasClass('red'); - assert("has class red", red); - - //id also has been overriden to 'xx' - var id = $(this).next().text(); - assert("id xx !== " + id, "xx" === id); - - //hidden value manipulated by singleFormatter2 - //using data-format-target to target value attr - var hidVal = $(this).nextAll('.hidden').val(); - assert( "Hidden Value " + hidVal +" !== 99", hidVal == 99); - - }); - } - }; - } - - //TODO - function SameCaseFormatter (assert){ - - } - - addTests(general,singleFormatter); - -})(); diff --git a/tests/files/general.js b/tests/files/general.js deleted file mode 100644 index 0a8ab46..0000000 --- a/tests/files/general.js +++ /dev/null @@ -1,205 +0,0 @@ -(function () { - - var data = [ - { - "name": "test1", - "id": 1 - }, - { - "name": "test2", - "id": 2 - }, - { - "name": "test3", - "id": 3 - } - ]; - - var nestedData = { - testSingle: "singleString", - testArray: ["testString1", "testString2", "testString3", 4] - } - - function testRender() { - $("#render").loadTemplate("#template", data, { - beforeInsert: function (ele) { - var val = ele.find('.hidden').val(); - if (val == 2) { - ele.css({ - background: "red" - }); - } - } - }); - } - - function testRenderSingle(inputData) { - $("#render").loadTemplate("#template", inputData); - } - - function test(assert, async) { - return [ - { - name: "jQuery Loaded", - test: function () { - assert(jQuery); - } - }, - { - name: "loadTemplate Loaded", - test: function () { - assert(typeof $.fn.loadTemplate === 'function'); - } - }, - { - name: "Simple Rendering", - test: function () { - testRender(); - //we rendered 3 elements - var childs = $('#render').children().length; - assert(childs === data.length); - } - }, - { - name: "Override Rendering", - test: function () { - testRender(); - //we rendered another 3 elements should overwrite - var childs = $('#render').children().length; - assert(childs === data.length); - } - }, - { - name: "Append Elements To the View", - setup: function () { - $("#render").loadTemplate("#template", [ - { - name: "befor last", - id: 4 - }, - { - name: "last", - id: 5 - } - ], { append: true }); - }, - test: function () { - //append 2 more elements so we should get 5 - var childs = $('#render').children().length; - assert("5 elements", childs === 5); - //must be last element - var val = $('#render div.container:last input.hidden').val(); - assert("last element id", val == 5); - } - }, - { - name: "Prepend Elements To the View", - setup: function () { - $("#render").loadTemplate("#template", [ - { - name: "first", - id: 1 - }, - { - name: "second", - id: 999 - } - ], { prepend: true }); - }, - test: function () { - //we prepend another 2 element = 7 elements total - var childs = $('#render').children().length; - assert("7 elements", childs === 7); - - //since it's a prepend "first" must be first element - var ele = $('#render').children().first(); - var id = ele.find('input.hidden').val(); - var name = ele.find(".name").text(); - assert("first id 1 !== " + id, id == 1); - assert("first name 'first' !== " + name, "first" == name); - } - }, - { - name: "Bind Value", - test: function () { - testRenderSingle(data[0]); - var val = $('#render input.hidden').val(); - assert(val + " != " + data[0]['id'], val == data[0]['id']); - } - }, - { - name: "Paged Render First Page", - setup: function () { - $("#render").loadTemplate("#template", data, { - paged: true, - pageNo: 1, - elemPerPage: 2 - }); - }, - test: function () { - //we should have 2 elements - var childs = $('#render').children(); - assert('2 elements', childs.length === 2); - //first id is 1 - var val = childs.first().find('input.hidden').val(); - assert('match first id', val == 1); - //second id is 2 - var val = childs.last().find('input.hidden').val(); - assert('match second id', val == 2); - } - }, - { - name: "Paged Render Second Page", - setup: function () { - $("#render").loadTemplate("#template", data, { - paged: true, - pageNo: 2, - elemPerPage: 2 - }); - }, - test: function () { - //we expect 1 element "the last one" - var childs = $('#render').children(); - assert('One element', childs.length === 1); - //it's id is 3 - var val = childs.last().find('input.hidden').val(); - assert('match last id', val == 3); - } - }, - { - name: 'Test binding to "this"', - test: function () { - $("#render").loadTemplate("#thisTemplate", nestedData.testArray); - var childs = $('#render').children(); - assert('All four rendered', childs.length === 4); - assert('Binding to "this"', $(childs[0]).text() === nestedData.testArray[0]); - } - }, - - { - name: "Test nesting templates", - test: function () { - $("#render").loadTemplate("#nestTemplate", nestedData); - var $rendered = $('#render'); - assert('Single Worked', $(".single-attribute", $rendered).text() === nestedData.testSingle); - var $templateBind = $('.template-bind-nest ul', $rendered); - assert('data-template-bind nest worked', $templateBind.length === 1 && $templateBind.children().length == 4); - var $attribute = $('.attribute-nest ul', $rendered); - assert('attributes nest worked"', $attribute.length === 1 && $attribute.children().length == 4); - } - } - //, - //{ - // name : "Find what is async", - // test : function(){ - // setTimeout(async(function () { // wru.async - // assert(1==1); // wru.assert - // }), 1000); - // } - //} - ]; - } - - addTests(test); - -})(); diff --git a/tests/index.html b/tests/index.html deleted file mode 100644 index f0786d9..0000000 --- a/tests/index.html +++ /dev/null @@ -1,136 +0,0 @@ - - - - loadTemplate Test Suite - - - - - - - - - - - - - - - -
should disappear
- - - - - - - - - - - - - - - - - - - - - - -
- -
- - - diff --git a/tests/phantom.js b/tests/phantom.js deleted file mode 100644 index 23451f9..0000000 --- a/tests/phantom.js +++ /dev/null @@ -1,79 +0,0 @@ - -var page = require('webpage').create(); -var fs = require('fs'); - -page.onConsoleMessage = function (msg, line, source) { - console.error(msg); -}; - -page.onClosing = function(){ - console.log('closed'); -}; - -function createReport(obj) { - - var totalErrors = 0, - totalPasses = 0; - - console.log("======================================"); - for (key in obj){ - var report = obj[key], - reportText = " \n " + key + " "; - - totalPasses += report.passes; - totalErrors += report.fails; - if (report.fails > 0) { - reportText += '.....(faild)'; - for (name in report.errors){ - reportText += '\n -> ' + name; - var list = report.errors[name]; - for(var i = 0; i < list.length; i++){ - reportText += '\n --> ' + list[i]; - } - } - } else { - reportText += '......(ok)'; - } - console.log(reportText); - } - - console.log("\n======================================"); - console.log("= Done Testing"); - console.log("= Total Tests : " + (totalPasses + totalErrors)); - console.log("= Passed Tests: " + totalPasses); - console.log("= Failed Tests: " + totalErrors); - - //page.render('view.png'); - phantom.exit(totalErrors); -} - -//this should be run on a server -//but for now local file seems ok -page.open('index.html', function(status) { - //var timeout = setTimeout(function(){ - var evaluate = function(){ - return page.evaluate(function(phantom) { - if (phantomExit) { - return phantomReport; - } - return false; - }); - }; - - var timeout; - var interv = setInterval(function(){ - var ret = evaluate(); - if (typeof ret === 'object') { - createReport(ret); - clearInterval(this); - if (timeout) clearTimeout(timeout); - } - },100); - - //on timeout - timeout = setTimeout(function(){ - clearInterval(interv); - createReport(ret); - },10000); - -}); diff --git a/tests/testRunner.js b/tests/testRunner.js deleted file mode 100644 index 8d1461c..0000000 --- a/tests/testRunner.js +++ /dev/null @@ -1,111 +0,0 @@ -var testObject = []; -var scriptTestFiles = []; -var currnetTestFileCounter = 0; -var phantomReport = {}; -var phantomExit = false; - -function addTests() { - - for (var i = 0; i < arguments.length; i++){ - testObject.push(arguments[i]); - } - - var file = scriptTestFiles[currnetTestFileCounter++]; - //hack wru to get better reporting - testObject.push(function(){ - return { - teardown :function(){ - var ele = $('#wru').find('div:last'); - var report = $('
Done Testsing ' + file + '
'); - $('#wru').append(report); - - var elements = $('.testfile:last').prevUntil('.testfile'), - errors = 0, - passes = 0; - - var phantom = phantomReport[file] = { - errors : {}, - passes : 0, - fails : 0 - }; - - elements.each(function(){ - var error = $(this).find('li'); - errors += error.length; - if (error.length > 0) { - var errorText = $(this).children().first().text(); - phantom.errors[errorText] = []; - $(error).each(function(){ - phantom.errors[errorText].push($(this).text()); - }); - } - - var pass = $(this).find('span:first').text(); - if (pass) { - var n = /\w+\s+\((\d+)/.exec(pass); - if (n) passes += parseInt(n[1]); - } - }); - - phantom.passes = passes; - phantom.fails = errors; - if (errors > 0) { - report.text(report.text() + " ( " + errors + " Errors & " + passes + " Passed )").css({ - background : "red", - color : "white" - }); - } else { - report.text(report.text() + " ( " + passes + " Tests Passed )"); - } - - ele.remove(); - } - } - return false; - }); -} - -function loadTestFile(src){ - document.write('<' + 'script src="' + src + '"' + - ' type="text/javascript"><' + '/script>'); -} - -function runTests(files) { - $(files).each(function(i,val){ - scriptTestFiles.push(val); - loadTestFile(val); - }); -} - -function wru(wru){ - var assert = wru.assert, - async = wru.async, - log = wru.log; - - testObject.push(function(assert,async){ - return { - name : '', - teardown : function(){ - $('.final').parent().hide(); - phantomExit = true; - } - }; - }); - - var run = function(obj){ - for (var i = 0; i < obj.length; i++){ - var action = obj[i]; - if ($.isArray(action)) { - run(action); - continue; - } - var ret = obj[i](assert,async); - if (ret) wru.test(ret); - } - }; - - run(testObject); - //remove wru headers as we generated our own header reports - $('#wru').find('strong:not(:first)').remove(); - $('#wru').find('.fail strong').remove(); -} diff --git a/tests/wru.js b/tests/wru.js deleted file mode 100644 index f8feede..0000000 --- a/tests/wru.js +++ /dev/null @@ -1 +0,0 @@ -wru(function(Y){function j(){A=K.call(m);if(A){if(typeof A=="function"){A={name:A[S]||"anonymous",test:A}}(P=l(l(Z.node,"div"),"span"))[E]=((ag(A,S)&&A[S])||(ag(A,e)&&A[e])||Q)+i+i;a=[];u=[];T=[];ab={};b("setup");T[ah]||b("test");N||r()}else{t()}}function p(aj){try{return O.call(h,aj)}catch(ai){return h.createElement(aj)}}function l(ai,aj){return ai.appendChild(p(aj))}function g(ai){P[E]=x.call(P[E],0,-2)+i+ai}function t(){var ak=Z.node.insertBefore(p("div"),Z.node.firstChild),al,aj,ai;if(ad){ai=aj="error";al="There Are Errors: "+ad}else{if(C){ai=aj="fail";al=C+" Tests Failed"}else{ai=aj="pass";al="Passed "+s+" Tests"}}Z.status=ai;ak[E]=""+al+"";ak.className=aj}function G(){var ai=this.lastChild.style;ai.display=ai.display=="none"?"block":"none"}function c(ai){P[E]+="";(P.onclick=G).call(P)}function r(){f();s+=a[ah];C+=u[ah];ad+=T[ah];g("("+v.call([a[ah],M=u[ah],T[ah]],", ")+")");P=P.parentNode;T[ah]?c(T,W="error"):(M?c(u,W="fail"):W="pass");P.className=W;M=0;W=i;j()}function b(ai){if(ag(A,ai)){try{A[ai](ab)}catch(aj){aa.call(T,i+aj)}}}function ag(aj,ai){return q.call(aj,ai)}function w(){return F()<0.5?-1:1}function f(){if(R){H(R);R=0}b("teardown")}var Z={timeout:y,assert:function U(aj,ai){if(arguments[ah]==1){ai=aj;aj=Q}z=I;aa.call(ai?a:u,W+aj);return ai},async:function V(ak,an,al,am){var ai=al||Z.timeout||(Z.timeout=y);am=++N;if(typeof ak=="function"){ai=an||Z.timeout;an=ak;ak="asynchronous test #"+am}al=X(function(){am=0;aa.call(u,ak);--N||(R=X(r,0))},L(ai)||Z.timeout);return function aj(){if(!am){return}z=ae;W=ak+": ";try{an.apply(this,arguments)}catch(ao){z=I;aa.call(T,W+ao)}W=i;if(z){H(al);--N||(R=X(r,0))}}},test:function n(ai,aj){Z.after=aj||function(){};m=J.apply(m,[ai]);Z.random&&af.call(m,w);N||j()}},I=true,ae=!I,y=100,i=" ",Q="unknown",ah="length",S="name",e="description",D="
  • ",d="
  • ",k="\\|/-",q=Z.hasOwnProperty,W=i,ac=W.charAt,x=W.slice,m=[],J=m.concat,v=m.join,aa=m.push,K=m.shift,af=m.sort,N=0,M=0,s=0,C=0,ad=0,R=0,E="innerHTML",h=Y.document,O=h.createElement,B,L,F,X,H,A,P,a,u,T,ab,z;B=Y.Math;L=B.abs;F=B.random;X=Y.setTimeout;H=Y.clearTimeout;Z.node=(h.getElementById("wru")||h.body||h.documentElement);Y.setInterval(function(){N&&g(ac.call(k,M++%4))},y);undefined;Z.log=function o(aj,ai){ai?alert(aj):(typeof console!="undefined")&&console.log(aj)};y*=y;Z.random=ae;return Z}(this));