diff --git a/.gitignore b/.gitignore
index 58b805fe..646ac519 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,2 @@
.DS_Store
-node_modules/
\ No newline at end of file
+node_modules/
diff --git a/.npmignore b/.npmignore
deleted file mode 100644
index 83ba5f8b..00000000
--- a/.npmignore
+++ /dev/null
@@ -1,5 +0,0 @@
-css/
-img/
-dist/
-demo.html
-index.html
\ No newline at end of file
diff --git a/bower.json b/bower.json
new file mode 100644
index 00000000..26d9145a
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,26 @@
+{
+ "name": "sheetsee",
+ "version": "1.0.0",
+ "main": [
+ "js/sheetsee.js",
+ "css/sss.css"
+ ],
+ "ignore": [
+ "contributing.md",
+ "docs",
+ "demos",
+ "img",
+ "site"
+ ],
+ "homepage": "http://jlord.github.io/sheetsee.js",
+ "description": "Sheetsee.js is a library for easily creating tables, charts and maps from spreadsheet data.",
+ "keywords": [
+ "spreadsheet",
+ "tables",
+ "maps"
+ ],
+ "dependencies": {
+ "jquery": ">= 1.9.0",
+ "tabletop": ">= 1.3.5"
+ }
+}
diff --git a/buildpage.js b/buildpage.js
index 4e171ff2..c6642dde 100644
--- a/buildpage.js
+++ b/buildpage.js
@@ -42,9 +42,11 @@ function applyTemplate(html, name) {
if (name === "index") {
content.rootstyle = "."
content.rootdoc = "docs"
+ content.rootdemo = "."
} else {
content.rootstyle = ".."
content.rootdoc = "."
+ content.rootdemo = ".."
}
var file = "template.hbs"
var rawTemplate = fs.readFileSync(file).toString()
diff --git a/contributing.md b/contributing.md
new file mode 100644
index 00000000..3296973c
--- /dev/null
+++ b/contributing.md
@@ -0,0 +1,17 @@
+# Contributing to Sheetsee.js
+
+This repository (github/jlord/sheetsee.js) is primarily for documentation and the documentation website. It also contains a copy of a full sheetsee.js (one that includes the map, charts and table portions).
+
+### Use this repository to file issues and pull requests on documentation/documentation site.
+
+The documentation is contained in the `/docs` and `/demos` folders in the root. I build the site (on the `gh-pages` branch) from these files so **submit pull requests against the files in `/docs` and `/demos`** and not the `/site` folder or the `gh-pages` branch.
+
+### For issues and pull requests on the JavaScript, use the repository for the affected portion:
+
+- [sheetsee](http://www.github.com/jlord/sheetsee/issues/new)
+- [sheetsee-core](http://www.github.com/jlord/sheetsee-core/issues/new)
+- [sheetsee-tables](http://www.github.com/jlord/sheetsee-tables/issues/new)
+- [sheetsee-maps](http://www.github.com/jlord/sheetsee-maps/issues/new)
+- [sheetsee-charts](http://www.github.com/jlord/sheetsee-charts/issues/new)
+
+Thank you much! :heart: :octocat:
diff --git a/demos/demo-chart.html b/demos/demo-chart.html
index cc94c234..93fcd577 100644
--- a/demos/demo-chart.html
+++ b/demos/demo-chart.html
@@ -5,7 +5,8 @@
Sheetsee Chart Demo
-
+
+
@@ -46,9 +47,9 @@ Ideas
Demos
Use
-
+
diff --git a/demos/demo-map.html b/demos/demo-map.html
index b5489c66..0be42924 100644
--- a/demos/demo-map.html
+++ b/demos/demo-map.html
@@ -5,13 +5,14 @@
Sheetsee Maps Demo
-
+
+
+#Pagination {background: #eee;}
+.pagination-next, .pagination-pre {cursor: hand;}
+.no-pag {color: #acacac;}
```
## Table Filter/Search
@@ -124,9 +84,77 @@ Sheetsee.initiateTableFilter(tableOptions)
It will connect that input to your data as well as inject this HTML for a button, which you can style yourself in your CSS:
+
```HTML
Clear
no matches
```
+## Example
+
+_HTML_
+
+```HTML
+
+
+```
+
+_Template_
+
+```JavaScript
+
+```
+
+_JavaScript_
+
+```javascript
+
+```
+
+To create another table, simply repeat the steps above (abreviated here below).
+
+_HTML_
+```HTML
+
+
+```
+_Template_
+
+```JavaScript
+
+```
+
+_JavaScript_
+
+```JavaScript
+
+```
+
+Learn more about the things you can do with [ICanHaz.js](http://icanhazjs.com).
+
_[View Demo](/demos/demo-table.html)_
diff --git a/js/sheetsee.js b/js/sheetsee.js
index 72f45e90..359e15cb 100644
--- a/js/sheetsee.js
+++ b/js/sheetsee.js
@@ -1,772 +1,560 @@
;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
-var baseCreateCallback = require('lodash._basecreatecallback'),
- keys = require('lodash.keys'),
- objectTypes = require('lodash._objecttypes');
-
-/**
- * Assigns own enumerable properties of source object(s) to the destination
- * object. Subsequent sources will overwrite property assignments of previous
- * sources. If a callback is provided it will be executed to produce the
- * assigned values. The callback is bound to `thisArg` and invoked with two
- * arguments; (objectValue, sourceValue).
- *
- * @static
- * @memberOf _
- * @type Function
- * @alias extend
- * @category Objects
- * @param {Object} object The destination object.
- * @param {...Object} [source] The source objects.
- * @param {Function} [callback] The function to customize assigning values.
- * @param {*} [thisArg] The `this` binding of `callback`.
- * @returns {Object} Returns the destination object.
- * @example
- *
- * _.assign({ 'name': 'moe' }, { 'age': 40 });
- * // => { 'name': 'moe', 'age': 40 }
- *
- * var defaults = _.partialRight(_.assign, function(a, b) {
- * return typeof a == 'undefined' ? b : a;
- * });
- *
- * var food = { 'name': 'apple' };
- * defaults(food, { 'name': 'banana', 'type': 'fruit' });
- * // => { 'name': 'apple', 'type': 'fruit' }
- */
-var assign = function(object, source, guard) {
- var index, iterable = object, result = iterable;
- if (!iterable) return result;
- var args = arguments,
- argsIndex = 0,
- argsLength = typeof guard == 'number' ? 2 : args.length;
- if (argsLength > 3 && typeof args[argsLength - 2] == 'function') {
- var callback = baseCreateCallback(args[--argsLength - 1], args[argsLength--], 2);
- } else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') {
- callback = args[--argsLength];
- }
- while (++argsIndex < argsLength) {
- iterable = args[argsIndex];
- if (iterable && objectTypes[typeof iterable]) {
- var ownIndex = -1,
- ownProps = objectTypes[typeof iterable] && keys(iterable),
- length = ownProps ? ownProps.length : 0;
-
- while (++ownIndex < length) {
- index = ownProps[ownIndex];
- result[index] = callback ? callback(result[index], iterable[index]) : iterable[index];
- }
- }
- }
- return result
-};
+if (typeof window.Sheetsee === 'undefined') window.Sheetsee = {}; window.Sheetsee = require('sheetsee-core'); var extend = require('lodash.assign'); extend(window.Sheetsee, require('sheetsee-maps'), require('sheetsee-charts'), require('sheetsee-tables')); module.exports = Sheetsee;
+},{"lodash.assign":3,"sheetsee-charts":28,"sheetsee-core":31,"sheetsee-maps":32,"sheetsee-tables":59}],2:[function(require,module,exports){
+/*!
+ICanHaz.js version 0.10.2 -- by @HenrikJoreteg
+More info at: http://icanhazjs.com
+*/
+(function () {
+/*
+ mustache.js — Logic-less templates in JavaScript
-module.exports = assign;
+ See http://mustache.github.com/ for more info.
+*/
-},{"lodash._basecreatecallback":3,"lodash._objecttypes":22,"lodash.keys":23}],3:[function(require,module,exports){
-/**
- * Lo-Dash 2.1.0 (Custom Build)
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
-var bind = require('lodash.bind'),
- identity = require('lodash.identity'),
- setBindData = require('lodash._setbinddata'),
- support = require('lodash.support');
+var Mustache = function () {
+ var _toString = Object.prototype.toString;
-/** Used to detected named functions */
-var reFuncName = /^function[ \n\r\t]+\w/;
+ Array.isArray = Array.isArray || function (obj) {
+ return _toString.call(obj) == "[object Array]";
+ }
-/** Used to detect functions containing a `this` reference */
-var reThis = /\bthis\b/;
+ var _trim = String.prototype.trim, trim;
-/** Native method shortcuts */
-var fnToString = Function.prototype.toString;
+ if (_trim) {
+ trim = function (text) {
+ return text == null ? "" : _trim.call(text);
+ }
+ } else {
+ var trimLeft, trimRight;
-/**
- * The base implementation of `_.createCallback` without support for creating
- * "_.pluck" or "_.where" style callbacks.
- *
- * @private
- * @param {*} [func=identity] The value to convert to a callback.
- * @param {*} [thisArg] The `this` binding of the created callback.
- * @param {number} [argCount] The number of arguments the callback accepts.
- * @returns {Function} Returns a callback function.
- */
-function baseCreateCallback(func, thisArg, argCount) {
- if (typeof func != 'function') {
- return identity;
- }
- // exit early if there is no `thisArg`
- if (typeof thisArg == 'undefined') {
- return func;
- }
- var bindData = func.__bindData__ || (support.funcNames && !func.name);
- if (typeof bindData == 'undefined') {
- var source = reThis && fnToString.call(func);
- if (!support.funcNames && source && !reFuncName.test(source)) {
- bindData = true;
+ // IE doesn't match non-breaking spaces with \s.
+ if ((/\S/).test("\xA0")) {
+ trimLeft = /^[\s\xA0]+/;
+ trimRight = /[\s\xA0]+$/;
+ } else {
+ trimLeft = /^\s+/;
+ trimRight = /\s+$/;
}
- if (support.funcNames || !bindData) {
- // checks if `func` references the `this` keyword and stores the result
- bindData = !support.funcDecomp || reThis.test(source);
- setBindData(func, bindData);
+
+ trim = function (text) {
+ return text == null ? "" :
+ text.toString().replace(trimLeft, "").replace(trimRight, "");
}
}
- // exit early if there are no `this` references or `func` is bound
- if (bindData !== true && (bindData && bindData[1] & 1)) {
- return func;
- }
- switch (argCount) {
- case 1: return function(value) {
- return func.call(thisArg, value);
- };
- case 2: return function(a, b) {
- return func.call(thisArg, a, b);
- };
- case 3: return function(value, index, collection) {
- return func.call(thisArg, value, index, collection);
- };
- case 4: return function(accumulator, value, index, collection) {
- return func.call(thisArg, accumulator, value, index, collection);
- };
- }
- return bind(func, thisArg);
-}
-module.exports = baseCreateCallback;
+ var escapeMap = {
+ "&": "&",
+ "<": "<",
+ ">": ">",
+ '"': '"',
+ "'": '''
+ };
-},{"lodash._setbinddata":4,"lodash.bind":12,"lodash.identity":19,"lodash.support":20}],4:[function(require,module,exports){
-/**
- * Lo-Dash 2.1.0 (Custom Build)
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
-var getObject = require('lodash._getobject'),
- noop = require('lodash._noop'),
- reNative = require('lodash._renative'),
- releaseObject = require('lodash._releaseobject');
+ function escapeHTML(string) {
+ return String(string).replace(/&(?!\w+;)|[<>"']/g, function (s) {
+ return escapeMap[s] || s;
+ });
+ }
-/** Used for native method references */
-var objectProto = Object.prototype;
+ var regexCache = {};
+ var Renderer = function () {};
-var defineProperty = (function() {
- try {
- var o = {},
- func = reNative.test(func = Object.defineProperty) && func,
- result = func(o, o, o) && func;
- } catch(e) { }
- return result;
-}());
+ Renderer.prototype = {
+ otag: "{{",
+ ctag: "}}",
+ pragmas: {},
+ buffer: [],
+ pragmas_implemented: {
+ "IMPLICIT-ITERATOR": true
+ },
+ context: {},
-/**
- * Sets `this` binding data on a given function.
- *
- * @private
- * @param {Function} func The function to set data on.
- * @param {*} value The value to set.
- */
-var setBindData = !defineProperty ? noop : function(func, value) {
- var descriptor = getObject();
- descriptor.value = value;
- defineProperty(func, '__bindData__', descriptor);
- releaseObject(descriptor);
-};
+ render: function (template, context, partials, in_recursion) {
+ // reset buffer & set context
+ if (!in_recursion) {
+ this.context = context;
+ this.buffer = []; // TODO: make this non-lazy
+ }
-module.exports = setBindData;
+ // fail fast
+ if (!this.includes("", template)) {
+ if (in_recursion) {
+ return template;
+ } else {
+ this.send(template);
+ return;
+ }
+ }
-},{"lodash._getobject":5,"lodash._noop":7,"lodash._releaseobject":8,"lodash._renative":11}],5:[function(require,module,exports){
-/**
- * Lo-Dash 2.1.0 (Custom Build)
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
-var objectPool = require('lodash._objectpool');
+ // get the pragmas together
+ template = this.render_pragmas(template);
-/**
- * Gets an object from the object pool or creates a new one if the pool is empty.
- *
- * @private
- * @returns {Object} The object from the pool.
- */
-function getObject() {
- return objectPool.pop() || {
- 'array': null,
- 'cache': null,
- 'configurable': false,
- 'criteria': null,
- 'enumerable': false,
- 'false': false,
- 'index': 0,
- 'leading': false,
- 'maxWait': 0,
- 'null': false,
- 'number': null,
- 'object': null,
- 'push': null,
- 'string': null,
- 'trailing': false,
- 'true': false,
- 'undefined': false,
- 'value': null,
- 'writable': false
- };
-}
+ // render the template
+ var html = this.render_section(template, context, partials);
-module.exports = getObject;
+ // render_section did not find any sections, we still need to render the tags
+ if (html === false) {
+ html = this.render_tags(template, context, partials, in_recursion);
+ }
-},{"lodash._objectpool":6}],6:[function(require,module,exports){
-/**
- * Lo-Dash 2.1.0 (Custom Build)
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
+ if (in_recursion) {
+ return html;
+ } else {
+ this.sendLines(html);
+ }
+ },
-/** Used to pool arrays and objects used internally */
-var objectPool = [];
+ /*
+ Sends parsed lines
+ */
+ send: function (line) {
+ if (line !== "") {
+ this.buffer.push(line);
+ }
+ },
-module.exports = objectPool;
+ sendLines: function (text) {
+ if (text) {
+ var lines = text.split("\n");
+ for (var i = 0; i < lines.length; i++) {
+ this.send(lines[i]);
+ }
+ }
+ },
-},{}],7:[function(require,module,exports){
-/**
- * Lo-Dash 2.1.0 (Custom Build)
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
+ /*
+ Looks for %PRAGMAS
+ */
+ render_pragmas: function (template) {
+ // no pragmas
+ if (!this.includes("%", template)) {
+ return template;
+ }
-/**
- * A no-operation function.
- *
- * @private
- */
-function noop() {
- // no operation performed
-}
+ var that = this;
+ var regex = this.getCachedRegex("render_pragmas", function (otag, ctag) {
+ return new RegExp(otag + "%([\\w-]+) ?([\\w]+=[\\w]+)?" + ctag, "g");
+ });
-module.exports = noop;
+ return template.replace(regex, function (match, pragma, options) {
+ if (!that.pragmas_implemented[pragma]) {
+ throw({message:
+ "This implementation of mustache doesn't understand the '" +
+ pragma + "' pragma"});
+ }
+ that.pragmas[pragma] = {};
+ if (options) {
+ var opts = options.split("=");
+ that.pragmas[pragma][opts[0]] = opts[1];
+ }
+ return "";
+ // ignore unknown pragmas silently
+ });
+ },
-},{}],8:[function(require,module,exports){
-/**
- * Lo-Dash 2.1.0 (Custom Build)
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
-var maxPoolSize = require('lodash._maxpoolsize'),
- objectPool = require('lodash._objectpool');
+ /*
+ Tries to find a partial in the curent scope and render it
+ */
+ render_partial: function (name, context, partials) {
+ name = trim(name);
+ if (!partials || partials[name] === undefined) {
+ throw({message: "unknown_partial '" + name + "'"});
+ }
+ if (!context || typeof context[name] != "object") {
+ return this.render(partials[name], context, partials, true);
+ }
+ return this.render(partials[name], context[name], partials, true);
+ },
-/**
- * Releases the given object back to the object pool.
- *
- * @private
- * @param {Object} [object] The object to release.
- */
-function releaseObject(object) {
- var cache = object.cache;
- if (cache) {
- releaseObject(cache);
- }
- object.array = object.cache = object.criteria = object.object = object.number = object.string = object.value = null;
- if (objectPool.length < maxPoolSize) {
- objectPool.push(object);
- }
-}
+ /*
+ Renders inverted (^) and normal (#) sections
+ */
+ render_section: function (template, context, partials) {
+ if (!this.includes("#", template) && !this.includes("^", template)) {
+ // did not render anything, there were no sections
+ return false;
+ }
-module.exports = releaseObject;
+ var that = this;
-},{"lodash._maxpoolsize":9,"lodash._objectpool":10}],9:[function(require,module,exports){
-/**
- * Lo-Dash 2.1.0 (Custom Build)
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
+ var regex = this.getCachedRegex("render_section", function (otag, ctag) {
+ // This regex matches _the first_ section ({{#foo}}{{/foo}}), and captures the remainder
+ return new RegExp(
+ "^([\\s\\S]*?)" + // all the crap at the beginning that is not {{*}} ($1)
-/** Used as the max size of the `arrayPool` and `objectPool` */
-var maxPoolSize = 40;
+ otag + // {{
+ "(\\^|\\#)\\s*(.+)\\s*" + // #foo (# == $2, foo == $3)
+ ctag + // }}
-module.exports = maxPoolSize;
+ "\n*([\\s\\S]*?)" + // between the tag ($2). leading newlines are dropped
-},{}],10:[function(require,module,exports){
-module.exports=require(6)
-},{}],11:[function(require,module,exports){
-/**
- * Lo-Dash 2.1.0 (Custom Build)
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
+ otag + // {{
+ "\\/\\s*\\3\\s*" + // /foo (backreference to the opening tag).
+ ctag + // }}
-/** Used for native method references */
-var objectProto = Object.prototype;
+ "\\s*([\\s\\S]*)$", // everything else in the string ($4). leading whitespace is dropped.
-/** Used to detect if a method is native */
-var reNative = RegExp('^' +
- String(objectProto.valueOf)
- .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
- .replace(/valueOf|for [^\]]+/g, '.+?') + '$'
-);
+ "g");
+ });
-module.exports = reNative;
-},{}],12:[function(require,module,exports){
-/**
- * Lo-Dash 2.1.0 (Custom Build)
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
-var createBound = require('lodash._createbound'),
- reNative = require('lodash._renative');
+ // for each {{#foo}}{{/foo}} section do...
+ return template.replace(regex, function (match, before, type, name, content, after) {
+ // before contains only tags, no sections
+ var renderedBefore = before ? that.render_tags(before, context, partials, true) : "",
-/**
- * Used for `Array` method references.
- *
- * Normally `Array.prototype` would suffice, however, using an array literal
- * avoids issues in Narwhal.
- */
-var arrayRef = [];
+ // after may contain both sections and tags, so use full rendering function
+ renderedAfter = after ? that.render(after, context, partials, true) : "",
-/* Native method shortcuts for methods with the same name as other `lodash` methods */
-var nativeSlice = arrayRef.slice;
+ // will be computed below
+ renderedContent,
-/**
- * Creates a function that, when called, invokes `func` with the `this`
- * binding of `thisArg` and prepends any additional `bind` arguments to those
- * provided to the bound function.
- *
- * @static
- * @memberOf _
- * @category Functions
- * @param {Function} func The function to bind.
- * @param {*} [thisArg] The `this` binding of `func`.
- * @param {...*} [arg] Arguments to be partially applied.
- * @returns {Function} Returns the new bound function.
- * @example
- *
- * var func = function(greeting) {
- * return greeting + ' ' + this.name;
- * };
- *
- * func = _.bind(func, { 'name': 'moe' }, 'hi');
- * func();
- * // => 'hi moe'
- */
-function bind(func, thisArg) {
- return arguments.length > 2
- ? createBound(func, 17, nativeSlice.call(arguments, 2), null, thisArg)
- : createBound(func, 1, null, null, thisArg);
-}
-
-module.exports = bind;
-
-},{"lodash._createbound":13,"lodash._renative":18}],13:[function(require,module,exports){
-/**
- * Lo-Dash 2.1.0 (Custom Build)
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
-var createObject = require('lodash._createobject'),
- isFunction = require('lodash.isfunction'),
- isObject = require('lodash.isobject'),
- reNative = require('lodash._renative'),
- setBindData = require('lodash._setbinddata'),
- support = require('lodash.support');
-
-/**
- * Used for `Array` method references.
- *
- * Normally `Array.prototype` would suffice, however, using an array literal
- * avoids issues in Narwhal.
- */
-var arrayRef = [];
-
-/** Used for native method references */
-var objectProto = Object.prototype;
+ value = that.find(name, context);
-/** Native method shortcuts */
-var push = arrayRef.push,
- toString = objectProto.toString,
- unshift = arrayRef.unshift;
+ if (type === "^") { // inverted section
+ if (!value || Array.isArray(value) && value.length === 0) {
+ // false or empty list, render it
+ renderedContent = that.render(content, context, partials, true);
+ } else {
+ renderedContent = "";
+ }
+ } else if (type === "#") { // normal section
+ if (Array.isArray(value)) { // Enumerable, Let's loop!
+ renderedContent = that.map(value, function (row) {
+ return that.render(content, that.create_context(row), partials, true);
+ }).join("");
+ } else if (that.is_object(value)) { // Object, Use it as subcontext!
+ renderedContent = that.render(content, that.create_context(value),
+ partials, true);
+ } else if (typeof value == "function") {
+ // higher order section
+ renderedContent = value.call(context, content, function (text) {
+ return that.render(text, context, partials, true);
+ });
+ } else if (value) { // boolean section
+ renderedContent = that.render(content, context, partials, true);
+ } else {
+ renderedContent = "";
+ }
+ }
-/* Native method shortcuts for methods with the same name as other `lodash` methods */
-var nativeBind = reNative.test(nativeBind = toString.bind) && nativeBind,
- nativeSlice = arrayRef.slice;
+ return renderedBefore + renderedContent + renderedAfter;
+ });
+ },
-/**
- * Creates a function that, when called, either curries or invokes `func`
- * with an optional `this` binding and partially applied arguments.
- *
- * @private
- * @param {Function|string} func The function or method name to reference.
- * @param {number} bitmask The bitmask of method flags to compose.
- * The bitmask may be composed of the following flags:
- * 1 - `_.bind`
- * 2 - `_.bindKey`
- * 4 - `_.curry`
- * 8 - `_.curry` (bound)
- * 16 - `_.partial`
- * 32 - `_.partialRight`
- * @param {Array} [partialArgs] An array of arguments to prepend to those
- * provided to the new function.
- * @param {Array} [partialRightArgs] An array of arguments to append to those
- * provided to the new function.
- * @param {*} [thisArg] The `this` binding of `func`.
- * @param {number} [arity] The arity of `func`.
- * @returns {Function} Returns the new bound function.
- */
-function createBound(func, bitmask, partialArgs, partialRightArgs, thisArg, arity) {
- var isBind = bitmask & 1,
- isBindKey = bitmask & 2,
- isCurry = bitmask & 4,
- isCurryBound = bitmask & 8,
- isPartial = bitmask & 16,
- isPartialRight = bitmask & 32,
- key = func;
+ /*
+ Replace {{foo}} and friends with values from our view
+ */
+ render_tags: function (template, context, partials, in_recursion) {
+ // tit for tat
+ var that = this;
- if (!isBindKey && !isFunction(func)) {
- throw new TypeError;
- }
- if (isPartial && !partialArgs.length) {
- bitmask &= ~16;
- isPartial = partialArgs = false;
- }
- if (isPartialRight && !partialRightArgs.length) {
- bitmask &= ~32;
- isPartialRight = partialRightArgs = false;
- }
- var bindData = func && func.__bindData__;
- if (bindData) {
- if (isBind && !(bindData[1] & 1)) {
- bindData[4] = thisArg;
- }
- if (!isBind && bindData[1] & 1) {
- bitmask |= 8;
- }
- if (isCurry && !(bindData[1] & 4)) {
- bindData[5] = arity;
- }
- if (isPartial) {
- push.apply(bindData[2] || (bindData[2] = []), partialArgs);
- }
- if (isPartialRight) {
- push.apply(bindData[3] || (bindData[3] = []), partialRightArgs);
- }
- bindData[1] |= bitmask;
- return createBound.apply(null, bindData);
- }
- // use `Function#bind` if it exists and is fast
- // (in V8 `Function#bind` is slower except when partially applied)
- if (isBind && !(isBindKey || isCurry || isPartialRight) &&
- (support.fastBind || (nativeBind && isPartial))) {
- if (isPartial) {
- var args = [thisArg];
- push.apply(args, partialArgs);
- }
- var bound = isPartial
- ? nativeBind.apply(func, args)
- : nativeBind.call(func, thisArg);
- }
- else {
- bound = function() {
- // `Function#bind` spec
- // http://es5.github.io/#x15.3.4.5
- var args = arguments,
- thisBinding = isBind ? thisArg : this;
+ var new_regex = function () {
+ return that.getCachedRegex("render_tags", function (otag, ctag) {
+ return new RegExp(otag + "(=|!|>|&|\\{|%)?([^#\\^]+?)\\1?" + ctag + "+", "g");
+ });
+ };
- if (isCurry || isPartial || isPartialRight) {
- args = nativeSlice.call(args);
- if (isPartial) {
- unshift.apply(args, partialArgs);
- }
- if (isPartialRight) {
- push.apply(args, partialRightArgs);
+ var regex = new_regex();
+ var tag_replace_callback = function (match, operator, name) {
+ switch(operator) {
+ case "!": // ignore comments
+ return "";
+ case "=": // set new delimiters, rebuild the replace regexp
+ that.set_delimiters(name);
+ regex = new_regex();
+ return "";
+ case ">": // render partial
+ return that.render_partial(name, context, partials);
+ case "{": // the triple mustache is unescaped
+ case "&": // & operator is an alternative unescape method
+ return that.find(name, context);
+ default: // escape the value
+ return escapeHTML(that.find(name, context));
}
- if (isCurry && args.length < arity) {
- bitmask |= 16 & ~32;
- return createBound(func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity);
+ };
+ var lines = template.split("\n");
+ for(var i = 0; i < lines.length; i++) {
+ lines[i] = lines[i].replace(regex, tag_replace_callback, this);
+ if (!in_recursion) {
+ this.send(lines[i]);
}
}
- if (isBindKey) {
- func = thisBinding[key];
- }
- if (this instanceof bound) {
- // ensure `new bound` is an instance of `func`
- thisBinding = createObject(func.prototype);
- // mimic the constructor's `return` behavior
- // http://es5.github.io/#x13.2.2
- var result = func.apply(thisBinding, args);
- return isObject(result) ? result : thisBinding;
+ if (in_recursion) {
+ return lines.join("\n");
}
- return func.apply(thisBinding, args);
- };
- }
- setBindData(bound, nativeSlice.call(arguments));
- return bound;
-}
+ },
-module.exports = createBound;
+ set_delimiters: function (delimiters) {
+ var dels = delimiters.split(" ");
+ this.otag = this.escape_regex(dels[0]);
+ this.ctag = this.escape_regex(dels[1]);
+ },
-},{"lodash._createobject":14,"lodash._renative":18,"lodash._setbinddata":4,"lodash.isfunction":16,"lodash.isobject":17,"lodash.support":20}],14:[function(require,module,exports){
-/**
- * Lo-Dash 2.1.0 (Custom Build)
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
-var isObject = require('lodash.isobject'),
- noop = require('lodash._noop'),
- reNative = require('lodash._renative');
+ escape_regex: function (text) {
+ // thank you Simon Willison
+ if (!arguments.callee.sRE) {
+ var specials = [
+ '/', '.', '*', '+', '?', '|',
+ '(', ')', '[', ']', '{', '}', '\\'
+ ];
+ arguments.callee.sRE = new RegExp(
+ '(\\' + specials.join('|\\') + ')', 'g'
+ );
+ }
+ return text.replace(arguments.callee.sRE, '\\$1');
+ },
-/** Used for native method references */
-var objectProto = Object.prototype;
+ /*
+ find `name` in current `context`. That is find me a value
+ from the view object
+ */
+ find: function (name, context) {
+ name = trim(name);
-/* Native method shortcuts for methods with the same name as other `lodash` methods */
-var nativeCreate = reNative.test(nativeCreate = Object.create) && nativeCreate;
+ // Checks whether a value is thruthy or false or 0
+ function is_kinda_truthy(bool) {
+ return bool === false || bool === 0 || bool;
+ }
-/**
- * Creates a new object with the specified `prototype`.
- *
- * @private
- * @param {Object} prototype The prototype object.
- * @returns {Object} Returns the new object.
- */
-function createObject(prototype) {
- return isObject(prototype) ? nativeCreate(prototype) : {};
-}
+ var value;
-module.exports = createObject;
+ // check for dot notation eg. foo.bar
+ if (name.match(/([a-z_]+)\./ig)) {
+ var childValue = this.walk_context(name, context);
+ if (is_kinda_truthy(childValue)) {
+ value = childValue;
+ }
+ } else {
+ if (is_kinda_truthy(context[name])) {
+ value = context[name];
+ } else if (is_kinda_truthy(this.context[name])) {
+ value = this.context[name];
+ }
+ }
-},{"lodash._noop":15,"lodash._renative":18,"lodash.isobject":17}],15:[function(require,module,exports){
-module.exports=require(7)
-},{}],16:[function(require,module,exports){
-/**
- * Lo-Dash 2.1.0 (Custom Build)
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
+ if (typeof value == "function") {
+ return value.apply(context);
+ }
+ if (value !== undefined) {
+ return value;
+ }
+ // silently ignore unkown variables
+ return "";
+ },
-/**
- * Checks if `value` is a function.
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if the `value` is a function, else `false`.
- * @example
- *
- * _.isFunction(_);
- * // => true
- */
-function isFunction(value) {
- return typeof value == 'function';
-}
+ walk_context: function (name, context) {
+ var path = name.split('.');
+ // if the var doesn't exist in current context, check the top level context
+ var value_context = (context[path[0]] != undefined) ? context : this.context;
+ var value = value_context[path.shift()];
+ while (value != undefined && path.length > 0) {
+ value_context = value;
+ value = value[path.shift()];
+ }
+ // if the value is a function, call it, binding the correct context
+ if (typeof value == "function") {
+ return value.apply(value_context);
+ }
+ return value;
+ },
-module.exports = isFunction;
+ // Utility methods
-},{}],17:[function(require,module,exports){
-/**
- * Lo-Dash 2.1.0 (Custom Build)
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
-var objectTypes = require('lodash._objecttypes');
+ /* includes tag */
+ includes: function (needle, haystack) {
+ return haystack.indexOf(this.otag + needle) != -1;
+ },
-/**
- * Checks if `value` is the language type of Object.
- * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @category Objects
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if the `value` is an object, else `false`.
- * @example
- *
- * _.isObject({});
- * // => true
- *
- * _.isObject([1, 2, 3]);
- * // => true
- *
- * _.isObject(1);
- * // => false
- */
-function isObject(value) {
- // check if the value is the ECMAScript language type of Object
- // http://es5.github.io/#x8
- // and avoid a V8 bug
- // http://code.google.com/p/v8/issues/detail?id=2291
- return !!(value && objectTypes[typeof value]);
-}
+ // by @langalex, support for arrays of strings
+ create_context: function (_context) {
+ if (this.is_object(_context)) {
+ return _context;
+ } else {
+ var iterator = ".";
+ if (this.pragmas["IMPLICIT-ITERATOR"]) {
+ iterator = this.pragmas["IMPLICIT-ITERATOR"].iterator;
+ }
+ var ctx = {};
+ ctx[iterator] = _context;
+ return ctx;
+ }
+ },
-module.exports = isObject;
+ is_object: function (a) {
+ return a && typeof a == "object";
+ },
-},{"lodash._objecttypes":22}],18:[function(require,module,exports){
-module.exports=require(11)
-},{}],19:[function(require,module,exports){
-/**
- * Lo-Dash 2.1.0 (Custom Build)
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
+ /*
+ Why, why, why? Because IE. Cry, cry cry.
+ */
+ map: function (array, fn) {
+ if (typeof array.map == "function") {
+ return array.map(fn);
+ } else {
+ var r = [];
+ var l = array.length;
+ for(var i = 0; i < l; i++) {
+ r.push(fn(array[i]));
+ }
+ return r;
+ }
+ },
-/**
- * This method returns the first argument provided to it.
- *
- * @static
- * @memberOf _
- * @category Utilities
- * @param {*} value Any value.
- * @returns {*} Returns `value`.
- * @example
- *
- * var moe = { 'name': 'moe' };
- * moe === _.identity(moe);
- * // => true
- */
-function identity(value) {
- return value;
-}
+ getCachedRegex: function (name, generator) {
+ var byOtag = regexCache[this.otag];
+ if (!byOtag) {
+ byOtag = regexCache[this.otag] = {};
+ }
-module.exports = identity;
+ var byCtag = byOtag[this.ctag];
+ if (!byCtag) {
+ byCtag = byOtag[this.ctag] = {};
+ }
-},{}],20:[function(require,module,exports){
-var global=typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};/**
- * Lo-Dash 2.1.0 (Custom Build)
- * Build: `lodash modularize modern exports="npm" -o ./npm`
- * Copyright 2012-2013 The Dojo Foundation
- * Based on Underscore.js 1.5.2
- * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license
- */
-var reNative = require('lodash._renative');
+ var regex = byCtag[name];
+ if (!regex) {
+ regex = byCtag[name] = generator(this.otag, this.ctag);
+ }
-/** Used to detect functions containing a `this` reference */
-var reThis = /\bthis\b/;
+ return regex;
+ }
+ };
-/** Used for native method references */
-var objectProto = Object.prototype;
+ return({
+ name: "mustache.js",
+ version: "0.4.0",
-/** Native method shortcuts */
-var toString = objectProto.toString;
+ /*
+ Turns a template and view into HTML
+ */
+ to_html: function (template, view, partials, send_fun) {
+ var renderer = new Renderer();
+ if (send_fun) {
+ renderer.send = send_fun;
+ }
+ renderer.render(template, view || {}, partials);
+ if (!send_fun) {
+ return renderer.buffer.join("\n");
+ }
+ }
+ });
+}();
+/*!
+ ICanHaz.js -- by @HenrikJoreteg
+*/
+/*global */
+(function () {
+ function trim(stuff) {
+ if (''.trim) return stuff.trim();
+ else return stuff.replace(/^\s+/, '').replace(/\s+$/, '');
+ }
-/* Native method shortcuts for methods with the same name as other `lodash` methods */
-var nativeBind = reNative.test(nativeBind = toString.bind) && nativeBind;
+ // Establish the root object, `window` in the browser, or `global` on the server.
+ var root = this;
-/** Detect various environments */
-var isIeOpera = reNative.test(global.attachEvent),
- isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera);
+ var ich = {
+ VERSION: "0.10.2",
+ templates: {},
-/**
- * An object used to flag environments features.
- *
- * @static
- * @memberOf _
- * @type Object
- */
-var support = {};
+ // grab jquery or zepto if it's there
+ $: (typeof window !== 'undefined') ? window.jQuery || window.Zepto || null : null,
-/**
- * Detect if `Function#bind` exists and is inferred to be fast (all but V8).
- *
- * @memberOf _.support
- * @type boolean
- */
-support.fastBind = nativeBind && !isV8;
+ // public function for adding templates
+ // can take a name and template string arguments
+ // or can take an object with name/template pairs
+ // We're enforcing uniqueness to avoid accidental template overwrites.
+ // If you want a different template, it should have a different name.
+ addTemplate: function (name, templateString) {
+ if (typeof name === 'object') {
+ for (var template in name) {
+ this.addTemplate(template, name[template]);
+ }
+ return;
+ }
+ if (ich[name]) {
+ console.error("Invalid name: " + name + ".");
+ } else if (ich.templates[name]) {
+ console.error("Template \"" + name + " \" exists");
+ } else {
+ ich.templates[name] = templateString;
+ ich[name] = function (data, raw) {
+ data = data || {};
+ var result = Mustache.to_html(ich.templates[name], data, ich.templates);
+ return (ich.$ && !raw) ? ich.$(trim(result)) : result;
+ };
+ }
+ },
-/**
- * Detect if functions can be decompiled by `Function#toString`
- * (all but PS3 and older Opera mobile browsers & avoided in Windows 8 apps).
- *
- * @memberOf _.support
- * @type boolean
- */
-support.funcDecomp = !reNative.test(global.WinRTError) && reThis.test(function() { return this; });
+ // clears all retrieval functions and empties cache
+ clearAll: function () {
+ for (var key in ich.templates) {
+ delete ich[key];
+ }
+ ich.templates = {};
+ },
-/**
- * Detect if `Function#name` is supported (all but IE).
- *
- * @memberOf _.support
- * @type boolean
- */
-support.funcNames = typeof Function.name == 'string';
+ // clears/grabs
+ refresh: function () {
+ ich.clearAll();
+ ich.grabTemplates();
+ },
-module.exports = support;
+ // grabs templates from the DOM and caches them.
+ // Loop through and add templates.
+ // Whitespace at beginning and end of all templates inside
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+