5988bc88 by Michael Richards

Merge branch 'master' into adapters

2 parents 532ea233 5471cb20
......@@ -2,7 +2,7 @@
"name": "rivets",
"repo": "mikeric/rivets",
"description": "Declarative data binding facility.",
"version": "0.5.11",
"version": "0.5.12",
"keywords": ["data binding", "templating"],
"scripts": ["dist/rivets.js"],
"main": "dist/rivets.js",
......
// Rivets.js
// version: 0.5.11
// version: 0.5.12
// author: Michael Richards
// license: MIT
(function() {
......@@ -21,7 +21,6 @@
Rivets.Binding = (function() {
function Binding(view, el, type, key, keypath, options) {
var identifier, regexp, value, _ref;
this.view = view;
this.el = el;
this.type = type;
......@@ -36,7 +35,7 @@
this.set = __bind(this.set, this);
this.eventHandler = __bind(this.eventHandler, this);
this.formattedValue = __bind(this.formattedValue, this);
if (!(this.binder = Rivets.internalBinders[this.type] || this.view.binders[type])) {
if (!(this.binder = this.view.binders[type])) {
_ref = this.view.binders;
for (identifier in _ref) {
value = _ref[identifier];
......@@ -62,7 +61,6 @@
Binding.prototype.formattedValue = function(value) {
var args, formatter, id, _i, _len, _ref;
_ref = this.formatters;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
formatter = _ref[_i];
......@@ -80,7 +78,6 @@
Binding.prototype.eventHandler = function(fn) {
var binding, handler;
handler = (binding = this).view.config.handler;
return function(ev) {
return handler.call(fn, this, ev, binding);
......@@ -89,7 +86,6 @@
Binding.prototype.set = function(value) {
var _ref;
value = value instanceof Function && !this.binder["function"] ? this.formattedValue(value.call(this.model)) : this.formattedValue(value);
return (_ref = this.binder.routine) != null ? _ref.call(this, this.el, value) : void 0;
};
......@@ -100,7 +96,6 @@
Binding.prototype.publish = function() {
var args, formatter, id, value, _i, _len, _ref, _ref1, _ref2;
value = Rivets.Util.getInputValue(this.el);
_ref = this.formatters.slice(0).reverse();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
......@@ -116,7 +111,6 @@
Binding.prototype.bind = function() {
var dependency, keypath, model, _i, _len, _ref, _ref1, _ref2, _results;
if ((_ref = this.binder.bind) != null) {
_ref.call(this, this.el);
}
......@@ -149,7 +143,6 @@
Binding.prototype.unbind = function() {
var dependency, keypath, model, _i, _len, _ref, _ref1, _ref2, _results;
if ((_ref = this.binder.unbind) != null) {
_ref.call(this, this.el);
}
......@@ -177,7 +170,6 @@
Binding.prototype.update = function(models) {
var _ref;
if (models == null) {
models = {};
}
......@@ -211,7 +203,6 @@
function ComponentBinding(view, el, type) {
var attribute, _i, _len, _ref, _ref1;
this.view = view;
this.el = el;
this.type = type;
......@@ -236,8 +227,7 @@
ComponentBinding.prototype.sync = function() {};
ComponentBinding.prototype.locals = function(models) {
var inverse, key, model, path, result, _i, _len, _ref, _ref1, _ref2;
var inverse, key, model, path, result, _i, _len, _ref, _ref1;
if (models == null) {
models = this.view.models;
}
......@@ -253,7 +243,7 @@
}
for (key in models) {
model = models[key];
if ((_ref2 = result[key]) == null) {
if (result[key] == null) {
result[key] = model;
}
}
......@@ -262,13 +252,11 @@
ComponentBinding.prototype.update = function(models) {
var _ref;
return (_ref = this.componentView) != null ? _ref.update(this.locals(models)) : void 0;
};
ComponentBinding.prototype.bind = function() {
var el, _ref;
if (this.componentView != null) {
return (_ref = this.componentView) != null ? _ref.bind() : void 0;
} else {
......@@ -280,7 +268,6 @@
ComponentBinding.prototype.unbind = function() {
var _ref;
return (_ref = this.componentView) != null ? _ref.unbind() : void 0;
};
......@@ -288,10 +275,38 @@
})(Rivets.Binding);
Rivets.TextBinding = (function(_super) {
__extends(TextBinding, _super);
function TextBinding(view, el, type, key, keypath, options) {
this.view = view;
this.el = el;
this.type = type;
this.key = key;
this.keypath = keypath;
this.options = options != null ? options : {};
this.sync = __bind(this.sync, this);
this.formatters = this.options.formatters || [];
this.model = this.key ? this.view.models[this.key] : this.view.models;
}
TextBinding.prototype.binder = {
routine: function(node, value) {
return node.data = value != null ? value : '';
}
};
TextBinding.prototype.sync = function() {
return TextBinding.__super__.sync.apply(this, arguments);
};
return TextBinding;
})(Rivets.Binding);
Rivets.View = (function() {
function View(els, models, options) {
var k, option, v, _base, _i, _len, _ref, _ref1, _ref2, _ref3;
var k, option, v, _base, _i, _len, _ref, _ref1, _ref2;
this.els = els;
this.models = models;
this.options = options != null ? options : {};
......@@ -321,7 +336,7 @@
_ref2 = Rivets[option];
for (k in _ref2) {
v = _ref2[k];
if ((_ref3 = (_base = this[option])[k]) == null) {
if ((_base = this[option])[k] == null) {
_base[k] = v;
}
}
......@@ -331,7 +346,6 @@
View.prototype.bindingRegExp = function() {
var prefix;
prefix = this.config.prefix;
if (prefix) {
return new RegExp("^data-" + prefix + "-");
......@@ -342,25 +356,21 @@
View.prototype.componentRegExp = function() {
var _ref, _ref1;
return new RegExp("^" + ((_ref = (_ref1 = this.config.prefix) != null ? _ref1.toUpperCase() : void 0) != null ? _ref : 'RV') + "-");
};
View.prototype.build = function() {
var bindingRegExp, buildBinding, componentRegExp, el, parse, skipNodes, _i, _len, _ref,
_this = this;
this.bindings = [];
skipNodes = [];
bindingRegExp = this.bindingRegExp();
componentRegExp = this.componentRegExp();
buildBinding = function(node, type, declaration) {
buildBinding = function(binding, node, type, declaration) {
var context, ctx, dependencies, key, keypath, options, path, pipe, pipes, splitPath;
options = {};
pipes = (function() {
var _i, _len, _ref, _results;
_ref = declaration.split('|');
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
......@@ -371,7 +381,6 @@
})();
context = (function() {
var _i, _len, _ref, _results;
_ref = pipes.shift().split('<');
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
......@@ -394,11 +403,10 @@
if (dependencies = context.shift()) {
options.dependencies = dependencies.split(/\s+/);
}
return _this.bindings.push(new Rivets.Binding(_this, node, type, key, keypath, options));
return _this.bindings.push(new Rivets[binding](_this, node, type, key, keypath, options));
};
parse = function(node) {
var attribute, attributes, binder, childNode, delimiters, identifier, n, parser, regexp, restTokens, startToken, text, token, tokens, type, value, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4, _results;
if (__indexOf.call(skipNodes, node) < 0) {
if (node.nodeType === Node.TEXT_NODE) {
parser = Rivets.TextTemplateParser;
......@@ -407,18 +415,17 @@
if (!(tokens.length === 1 && tokens[0].type === parser.types.text)) {
startToken = tokens[0], restTokens = 2 <= tokens.length ? __slice.call(tokens, 1) : [];
node.data = startToken.value;
switch (startToken.type) {
case 0:
node.data = startToken.value;
break;
case 1:
buildBinding(node, 'textNode', startToken.value);
if (startToken.type === 0) {
node.data = startToken.value;
} else {
buildBinding('TextBinding', node, null, startToken.value);
}
for (_i = 0, _len = restTokens.length; _i < _len; _i++) {
token = restTokens[_i];
node.parentNode.appendChild((text = document.createTextNode(token.value)));
text = document.createTextNode(token.value);
node.parentNode.appendChild(text);
if (token.type === 1) {
buildBinding(text, 'textNode', token.value);
buildBinding('TextBinding', text, null, token.value);
}
}
}
......@@ -461,7 +468,7 @@
attribute = _ref3[_l];
if (bindingRegExp.test(attribute.name)) {
type = attribute.name.replace(bindingRegExp, '');
buildBinding(node, type, attribute.value);
buildBinding('Binding', node, type, attribute.value);
}
}
}
......@@ -483,7 +490,6 @@
View.prototype.select = function(fn) {
var binding, _i, _len, _ref, _results;
_ref = this.bindings;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
......@@ -497,7 +503,6 @@
View.prototype.bind = function() {
var binding, _i, _len, _ref, _results;
_ref = this.bindings;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
......@@ -509,7 +514,6 @@
View.prototype.unbind = function() {
var binding, _i, _len, _ref, _results;
_ref = this.bindings;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
......@@ -521,7 +525,6 @@
View.prototype.sync = function() {
var binding, _i, _len, _ref, _results;
_ref = this.bindings;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
......@@ -533,7 +536,6 @@
View.prototype.publish = function() {
var binding, _i, _len, _ref, _results;
_ref = this.select(function(b) {
return b.binder.publishes;
});
......@@ -547,7 +549,6 @@
View.prototype.update = function(models) {
var binding, key, model, _i, _len, _ref, _results;
if (models == null) {
models = {};
}
......@@ -578,7 +579,6 @@
TextTemplateParser.parse = function(template, delimiters) {
var index, lastIndex, lastToken, length, substring, tokens, value;
tokens = [];
length = template.length;
index = 0;
......@@ -661,7 +661,6 @@
},
getInputValue: function(el) {
var o, _i, _len, _results;
if (window.jQuery != null) {
el = jQuery(el);
switch (el[0].type) {
......@@ -708,7 +707,6 @@
},
routine: function(el, value) {
var _ref;
if (el.type === 'radio') {
return el.checked = ((_ref = el.value) != null ? _ref.toString() : void 0) === (value != null ? value.toString() : void 0);
} else {
......@@ -726,7 +724,6 @@
},
routine: function(el, value) {
var _ref;
if (el.type === 'radio') {
return el.checked = ((_ref = el.value) != null ? _ref.toString() : void 0) !== (value != null ? value.toString() : void 0);
} else {
......@@ -753,7 +750,6 @@
},
routine: function(el, value) {
var o, _i, _len, _ref, _ref1, _ref2, _results;
if (window.jQuery != null) {
el = jQuery(el);
if ((value != null ? value.toString() : void 0) !== ((_ref = el.val()) != null ? _ref.toString() : void 0)) {
......@@ -786,7 +782,6 @@
block: true,
bind: function(el) {
var attr, declaration;
if (this.marker == null) {
attr = ['data', this.view.config.prefix, this.type].join('-').replace('--', '-');
declaration = el.getAttribute(attr);
......@@ -798,12 +793,10 @@
},
unbind: function() {
var _ref;
return (_ref = this.nested) != null ? _ref.unbind() : void 0;
},
routine: function(el, value) {
var key, model, models, options, _ref;
if (!!value === (this.nested == null)) {
if (value) {
models = {};
......@@ -827,7 +820,8 @@
}
},
update: function(models) {
return this.nested.update(models);
var _ref;
return (_ref = this.nested) != null ? _ref.update(models) : void 0;
}
},
unless: {
......@@ -863,7 +857,6 @@
block: true,
bind: function(el) {
var attr;
if (this.marker == null) {
attr = ['data', this.view.config.prefix, this.type].join('-').replace('--', '-');
this.marker = document.createComment(" rivets: " + this.type + " ");
......@@ -875,7 +868,6 @@
},
unbind: function(el) {
var view, _i, _len, _ref, _results;
if (this.iterated != null) {
_ref = this.iterated;
_results = [];
......@@ -887,8 +879,7 @@
}
},
routine: function(el, collection) {
var data, i, index, k, key, model, modelName, options, previous, template, v, view, _i, _j, _len, _len1, _ref, _ref1, _ref2, _ref3, _results;
var data, i, index, k, key, model, modelName, options, previous, template, v, view, _i, _j, _len, _len1, _ref, _ref1, _ref2, _results;
modelName = this.args[0];
collection = collection || [];
if (this.iterated.length > collection.length) {
......@@ -909,7 +900,7 @@
_ref1 = this.view.models;
for (key in _ref1) {
model = _ref1[key];
if ((_ref2 = data[key]) == null) {
if (data[key] == null) {
data[key] = model;
}
}
......@@ -919,9 +910,9 @@
formatters: this.view.options.formatters,
config: {}
};
_ref3 = this.view.options.config;
for (k in _ref3) {
v = _ref3[k];
_ref2 = this.view.options.config;
for (k in _ref2) {
v = _ref2[k];
options.config[k] = v;
}
options.config.preloadData = true;
......@@ -940,7 +931,6 @@
},
update: function(models) {
var data, key, model, view, _i, _len, _ref, _results;
data = {};
for (key in models) {
model = models[key];
......@@ -959,7 +949,6 @@
},
"class-*": function(el, value) {
var elClass;
elClass = " " + el.className + " ";
if (!value === (elClass.indexOf(" " + this.args[0] + " ") !== -1)) {
return el.className = value ? "" + el.className + " " + this.args[0] : elClass.replace(" " + this.args[0] + " ", ' ').trim();
......@@ -974,12 +963,6 @@
}
};
Rivets.internalBinders = {
textNode: function(node, value) {
return node.data = value != null ? value : '';
}
};
Rivets.components = {};
Rivets.config = {
......@@ -999,7 +982,6 @@
exports.config = Rivets.config;
exports.configure = function(options) {
var property, value;
if (options == null) {
options = {};
}
......@@ -1010,7 +992,6 @@
};
return exports.bind = function(el, models, options) {
var view;
if (models == null) {
models = {};
}
......
// Rivets.js
// version: 0.5.11
// version: 0.5.12
// author: Michael Richards
// license: MIT
(function(){var t,i=function(t,i){return function(){return t.apply(i,arguments)}},e=[].slice,n={}.hasOwnProperty,s=function(t,i){function e(){this.constructor=t}for(var s in i)n.call(i,s)&&(t[s]=i[s]);return e.prototype=i.prototype,t.prototype=new e,t.__super__=i.prototype,t},r=[].indexOf||function(t){for(var i=0,e=this.length;e>i;i++)if(i in this&&this[i]===t)return i;return-1};t={},String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),t.Binding=function(){function n(e,n,s,r,o,h){var l,u,a,d;if(this.view=e,this.el=n,this.type=s,this.key=r,this.keypath=o,this.options=null!=h?h:{},this.update=i(this.update,this),this.unbind=i(this.unbind,this),this.bind=i(this.bind,this),this.publish=i(this.publish,this),this.sync=i(this.sync,this),this.set=i(this.set,this),this.eventHandler=i(this.eventHandler,this),this.formattedValue=i(this.formattedValue,this),!(this.binder=t.internalBinders[this.type]||this.view.binders[s])){d=this.view.binders;for(l in d)a=d[l],"*"!==l&&-1!==l.indexOf("*")&&(u=RegExp("^"+l.replace("*",".+")+"$"),u.test(s)&&(this.binder=a,this.args=RegExp("^"+l.replace("*","(.+)")+"$").exec(s),this.args.shift()))}this.binder||(this.binder=this.view.binders["*"]),this.binder instanceof Function&&(this.binder={routine:this.binder}),this.formatters=this.options.formatters||[],this.model=this.key?this.view.models[this.key]:this.view.models}return n.prototype.formattedValue=function(t){var i,n,s,r,o,h;for(h=this.formatters,r=0,o=h.length;o>r;r++)n=h[r],i=n.split(/\s+/),s=i.shift(),n=this.model[s]instanceof Function?this.model[s]:this.view.formatters[s],(null!=n?n.read:void 0)instanceof Function?t=n.read.apply(n,[t].concat(e.call(i))):n instanceof Function&&(t=n.apply(null,[t].concat(e.call(i))));return t},n.prototype.eventHandler=function(t){var i,e;return e=(i=this).view.config.handler,function(n){return e.call(t,this,n,i)}},n.prototype.set=function(t){var i;return t=t instanceof Function&&!this.binder["function"]?this.formattedValue(t.call(this.model)):this.formattedValue(t),null!=(i=this.binder.routine)?i.call(this,this.el,t):void 0},n.prototype.sync=function(){return this.set(this.options.bypass?this.model[this.keypath]:this.view.config.adapter.read(this.model,this.keypath))},n.prototype.publish=function(){var i,n,s,r,o,h,l,u,a;for(r=t.Util.getInputValue(this.el),l=this.formatters.slice(0).reverse(),o=0,h=l.length;h>o;o++)n=l[o],i=n.split(/\s+/),s=i.shift(),(null!=(u=this.view.formatters[s])?u.publish:void 0)&&(r=(a=this.view.formatters[s]).publish.apply(a,[r].concat(e.call(i))));return this.view.config.adapter.publish(this.model,this.keypath,r)},n.prototype.bind=function(){var t,i,e,n,s,r,o,h,l;if(null!=(r=this.binder.bind)&&r.call(this,this.el),this.options.bypass?this.sync():(this.view.config.adapter.subscribe(this.model,this.keypath,this.sync),this.view.config.preloadData&&this.sync()),null!=(o=this.options.dependencies)?o.length:void 0){for(h=this.options.dependencies,l=[],n=0,s=h.length;s>n;n++)t=h[n],/^\./.test(t)?(e=this.model,i=t.substr(1)):(t=t.split("."),e=this.view.models[t.shift()],i=t.join(".")),l.push(this.view.config.adapter.subscribe(e,i,this.sync));return l}},n.prototype.unbind=function(){var t,i,e,n,s,r,o,h,l;if(null!=(r=this.binder.unbind)&&r.call(this,this.el),this.options.bypass||this.view.config.adapter.unsubscribe(this.model,this.keypath,this.sync),null!=(o=this.options.dependencies)?o.length:void 0){for(h=this.options.dependencies,l=[],n=0,s=h.length;s>n;n++)t=h[n],/^\./.test(t)?(e=this.model,i=t.substr(1)):(t=t.split("."),e=this.view.models[t.shift()],i=t.join(".")),l.push(this.view.config.adapter.unsubscribe(e,i,this.sync));return l}},n.prototype.update=function(t){var i;return null==t&&(t={}),this.key?t[this.key]&&(this.options.bypass||this.view.config.adapter.unsubscribe(this.model,this.keypath,this.sync),this.model=t[this.key],this.options.bypass?this.sync():(this.view.config.adapter.subscribe(this.model,this.keypath,this.sync),this.view.config.preloadData&&this.sync())):this.sync(),null!=(i=this.binder.update)?i.call(this,t):void 0},n}(),t.ComponentBinding=function(e){function n(e,n,s){var o,h,l,u,a;for(this.view=e,this.el=n,this.type=s,this.unbind=i(this.unbind,this),this.bind=i(this.bind,this),this.update=i(this.update,this),this.locals=i(this.locals,this),this.component=t.components[this.type],this.attributes={},this.inflections={},u=this.el.attributes||[],h=0,l=u.length;l>h;h++)o=u[h],a=o.name,r.call(this.component.attributes,a)>=0?this.attributes[o.name]=o.value:this.inflections[o.name]=o.value}return s(n,e),n.prototype.sync=function(){},n.prototype.locals=function(t){var i,e,n,s,r,o,h,l,u,a;null==t&&(t=this.view.models),r={},l=this.inflections;for(e in l)for(i=l[e],u=i.split("."),o=0,h=u.length;h>o;o++)s=u[o],r[e]=(r[e]||t)[s];for(e in t)n=t[e],null==(a=r[e])&&(r[e]=n);return r},n.prototype.update=function(t){var i;return null!=(i=this.componentView)?i.update(this.locals(t)):void 0},n.prototype.bind=function(){var i,e;return null!=this.componentView?null!=(e=this.componentView)?e.bind():void 0:(i=this.component.build.call(this.attributes),(this.componentView=new t.View(i,this.locals(),this.view.options)).bind(),this.el.parentNode.replaceChild(i,this.el))},n.prototype.unbind=function(){var t;return null!=(t=this.componentView)?t.unbind():void 0},n}(t.Binding),t.View=function(){function n(e,n,s){var r,o,h,l,u,a,d,p,c,f;for(this.els=e,this.models=n,this.options=null!=s?s:{},this.update=i(this.update,this),this.publish=i(this.publish,this),this.sync=i(this.sync,this),this.unbind=i(this.unbind,this),this.bind=i(this.bind,this),this.select=i(this.select,this),this.build=i(this.build,this),this.componentRegExp=i(this.componentRegExp,this),this.bindingRegExp=i(this.bindingRegExp,this),this.els.jquery||this.els instanceof Array||(this.els=[this.els]),d=["config","binders","formatters"],u=0,a=d.length;a>u;u++){if(o=d[u],this[o]={},this.options[o]){p=this.options[o];for(r in p)h=p[r],this[o][r]=h}c=t[o];for(r in c)h=c[r],null==(f=(l=this[o])[r])&&(l[r]=h)}this.build()}return n.prototype.bindingRegExp=function(){var t;return t=this.config.prefix,t?RegExp("^data-"+t+"-"):/^data-/},n.prototype.componentRegExp=function(){var t,i;return RegExp("^"+(null!=(t=null!=(i=this.config.prefix)?i.toUpperCase():void 0)?t:"RV")+"-")},n.prototype.build=function(){var i,n,s,o,h,l,u,a,d,p=this;for(this.bindings=[],l=[],i=this.bindingRegExp(),s=this.componentRegExp(),n=function(i,e,n){var s,r,o,h,l,u,a,d,c,f;return u={},c=function(){var t,i,e,s;for(e=n.split("|"),s=[],t=0,i=e.length;i>t;t++)d=e[t],s.push(d.trim());return s}(),s=function(){var t,i,e,n;for(e=c.shift().split("<"),n=[],t=0,i=e.length;i>t;t++)r=e[t],n.push(r.trim());return n}(),a=s.shift(),f=a.split(/\.|:/),u.formatters=c,u.bypass=-1!==a.indexOf(":"),f[0]?h=f.shift():(h=null,f.shift()),l=f.join("."),(o=s.shift())&&(u.dependencies=o.split(/\s+/)),p.bindings.push(new t.Binding(p,i,e,h,l,u))},h=function(o){var u,a,d,c,f,b,v,g,y,m,w,x,k,E,N,V,j,R,C,U,B,T,O,Q,A,D,L,_,F,H,S,$;if(0>r.call(l,o)){if(o.nodeType===Node.TEXT_NODE){if(g=t.TextTemplateParser,(f=p.config.templateDelimiters)&&(E=g.parse(o.data,f)).length&&(1!==E.length||E[0].type!==g.types.text)){switch(w=E[0],m=E.length>=2?e.call(E,1):[],o.data=w.value,w.type){case 0:o.data=w.value;break;case 1:n(o,"textNode",w.value)}for(j=0,B=m.length;B>j;j++)k=m[j],o.parentNode.appendChild(x=document.createTextNode(k.value)),1===k.type&&n(x,"textNode",k.value)}}else if(s.test(o.tagName))N=o.tagName.replace(s,"").toLowerCase(),p.bindings.push(new t.ComponentBinding(p,o,N));else if(null!=o.attributes){for(L=o.attributes,R=0,T=L.length;T>R;R++)if(u=L[R],i.test(u.name)){if(N=u.name.replace(i,""),!(d=p.binders[N])){_=p.binders;for(b in _)V=_[b],"*"!==b&&-1!==b.indexOf("*")&&(y=RegExp("^"+b.replace("*",".+")+"$"),y.test(N)&&(d=V))}if(d||(d=p.binders["*"]),d.block){for(F=o.childNodes,C=0,O=F.length;O>C;C++)v=F[C],l.push(v);a=[u]}}for(H=a||o.attributes,U=0,Q=H.length;Q>U;U++)u=H[U],i.test(u.name)&&(N=u.name.replace(i,""),n(o,N,u.value))}for(S=o.childNodes,$=[],D=0,A=S.length;A>D;D++)c=S[D],$.push(h(c));return $}},d=this.els,u=0,a=d.length;a>u;u++)o=d[u],h(o)},n.prototype.select=function(t){var i,e,n,s,r;for(s=this.bindings,r=[],e=0,n=s.length;n>e;e++)i=s[e],t(i)&&r.push(i);return r},n.prototype.bind=function(){var t,i,e,n,s;for(n=this.bindings,s=[],i=0,e=n.length;e>i;i++)t=n[i],s.push(t.bind());return s},n.prototype.unbind=function(){var t,i,e,n,s;for(n=this.bindings,s=[],i=0,e=n.length;e>i;i++)t=n[i],s.push(t.unbind());return s},n.prototype.sync=function(){var t,i,e,n,s;for(n=this.bindings,s=[],i=0,e=n.length;e>i;i++)t=n[i],s.push(t.sync());return s},n.prototype.publish=function(){var t,i,e,n,s;for(n=this.select(function(t){return t.binder.publishes}),s=[],i=0,e=n.length;e>i;i++)t=n[i],s.push(t.publish());return s},n.prototype.update=function(t){var i,e,n,s,r,o,h;null==t&&(t={});for(e in t)n=t[e],this.models[e]=n;for(o=this.bindings,h=[],s=0,r=o.length;r>s;s++)i=o[s],h.push(i.update(t));return h},n}(),t.TextTemplateParser=function(){function t(){}return t.types={text:0,binding:1},t.parse=function(t,i){var e,n,s,r,o,h,l;for(h=[],r=t.length,e=0,n=0;r>n;){if(e=t.indexOf(i[0],n),0>e){h.push({type:this.types.text,value:t.slice(n)});break}if(e>0&&e>n&&h.push({type:this.types.text,value:t.slice(n,e)}),n=e+2,e=t.indexOf(i[1],n),0>e){o=t.slice(n-2),s=h[h.length-1],(null!=s?s.type:void 0)===this.types.text?s.value+=o:h.push({type:this.types.text,value:o});break}l=t.slice(n,e).trim(),h.push({type:this.types.binding,value:l}),n=e+2}return h},t}(),t.Util={bindEvent:function(t,i,e){return null!=window.jQuery?(t=jQuery(t),null!=t.on?t.on(i,e):t.bind(i,e)):null!=window.addEventListener?t.addEventListener(i,e,!1):(i="on"+i,t.attachEvent(i,e))},unbindEvent:function(t,i,e){return null!=window.jQuery?(t=jQuery(t),null!=t.off?t.off(i,e):t.unbind(i,e)):null!=window.removeEventListener?t.removeEventListener(i,e,!1):(i="on"+i,t.detachEvent(i,e))},getInputValue:function(t){var i,e,n,s;if(null!=window.jQuery)switch(t=jQuery(t),t[0].type){case"checkbox":return t.is(":checked");default:return t.val()}else switch(t.type){case"checkbox":return t.checked;case"select-multiple":for(s=[],e=0,n=t.length;n>e;e++)i=t[e],i.selected&&s.push(i.value);return s;default:return t.value}}},t.binders={enabled:function(t,i){return t.disabled=!i},disabled:function(t,i){return t.disabled=!!i},checked:{publishes:!0,bind:function(i){return t.Util.bindEvent(i,"change",this.publish)},unbind:function(i){return t.Util.unbindEvent(i,"change",this.publish)},routine:function(t,i){var e;return t.checked="radio"===t.type?(null!=(e=t.value)?""+e:void 0)===(null!=i?""+i:void 0):!!i}},unchecked:{publishes:!0,bind:function(i){return t.Util.bindEvent(i,"change",this.publish)},unbind:function(i){return t.Util.unbindEvent(i,"change",this.publish)},routine:function(t,i){var e;return t.checked="radio"===t.type?(null!=(e=t.value)?""+e:void 0)!==(null!=i?""+i:void 0):!i}},show:function(t,i){return t.style.display=i?"":"none"},hide:function(t,i){return t.style.display=i?"none":""},html:function(t,i){return t.innerHTML=null!=i?i:""},value:{publishes:!0,bind:function(i){return t.Util.bindEvent(i,"change",this.publish)},unbind:function(i){return t.Util.unbindEvent(i,"change",this.publish)},routine:function(t,i){var e,n,s,o,h,l,u;if(null!=window.jQuery){if(t=jQuery(t),(null!=i?""+i:void 0)!==(null!=(o=t.val())?""+o:void 0))return t.val(null!=i?i:"")}else if("select-multiple"===t.type){if(null!=i){for(u=[],n=0,s=t.length;s>n;n++)e=t[n],u.push(e.selected=(h=e.value,r.call(i,h)>=0));return u}}else if((null!=i?""+i:void 0)!==(null!=(l=t.value)?""+l:void 0))return t.value=null!=i?i:""}},text:function(t,i){return null!=t.innerText?t.innerText=null!=i?i:"":t.textContent=null!=i?i:""},"if":{block:!0,bind:function(t){var i,e;return null==this.marker?(i=["data",this.view.config.prefix,this.type].join("-").replace("--","-"),e=t.getAttribute(i),this.marker=document.createComment(" rivets: "+this.type+" "+e+" "),t.removeAttribute(i),t.parentNode.insertBefore(this.marker,t),t.parentNode.removeChild(t)):void 0},unbind:function(){var t;return null!=(t=this.nested)?t.unbind():void 0},routine:function(i,e){var n,s,r,o,h;if(!!e==(null==this.nested)){if(e){r={},h=this.view.models;for(n in h)s=h[n],r[n]=s;return o={binders:this.view.options.binders,formatters:this.view.options.formatters,config:this.view.options.config},(this.nested=new t.View(i,r,o)).bind(),this.marker.parentNode.insertBefore(i,this.marker.nextSibling)}return i.parentNode.removeChild(i),this.nested.unbind(),delete this.nested}},update:function(t){return this.nested.update(t)}},unless:{block:!0,bind:function(i){return t.binders["if"].bind.call(this,i)},unbind:function(){return t.binders["if"].unbind.call(this)},routine:function(i,e){return t.binders["if"].routine.call(this,i,!e)},update:function(i){return t.binders["if"].update.call(this,i)}},"on-*":{"function":!0,unbind:function(i){return this.handler?t.Util.unbindEvent(i,this.args[0],this.handler):void 0},routine:function(i,e){return this.handler&&t.Util.unbindEvent(i,this.args[0],this.handler),t.Util.bindEvent(i,this.args[0],this.handler=this.eventHandler(e))}},"each-*":{block:!0,bind:function(t){var i;return null==this.marker?(i=["data",this.view.config.prefix,this.type].join("-").replace("--","-"),this.marker=document.createComment(" rivets: "+this.type+" "),this.iterated=[],t.removeAttribute(i),t.parentNode.insertBefore(this.marker,t),t.parentNode.removeChild(t)):void 0},unbind:function(){var t,i,e,n,s;if(null!=this.iterated){for(n=this.iterated,s=[],i=0,e=n.length;e>i;i++)t=n[i],s.push(t.unbind());return s}},routine:function(i,e){var n,s,r,o,h,l,u,a,d,p,c,f,b,v,g,y,m,w,x,k,E;if(u=this.args[0],e=e||[],this.iterated.length>e.length)for(m=Array(this.iterated.length-e.length),b=0,g=m.length;g>b;b++)s=m[b],f=this.iterated.pop(),f.unbind(),this.marker.parentNode.removeChild(f.els[0]);for(E=[],r=v=0,y=e.length;y>v;r=++v)if(l=e[r],n={},n[u]=l,null==this.iterated[r]){w=this.view.models;for(h in w)l=w[h],null==(x=n[h])&&(n[h]=l);d=this.iterated.length?this.iterated[this.iterated.length-1].els[0]:this.marker,a={binders:this.view.options.binders,formatters:this.view.options.formatters,config:{}},k=this.view.options.config;for(o in k)c=k[o],a.config[o]=c;a.config.preloadData=!0,p=i.cloneNode(!0),f=new t.View(p,n,a),f.bind(),this.iterated.push(f),E.push(this.marker.parentNode.insertBefore(p,d.nextSibling))}else this.iterated[r].models[u]!==l?E.push(this.iterated[r].update(n)):E.push(void 0);return E},update:function(t){var i,e,n,s,r,o,h,l;i={};for(e in t)n=t[e],e!==this.args[0]&&(i[e]=n);for(h=this.iterated,l=[],r=0,o=h.length;o>r;r++)s=h[r],l.push(s.update(i));return l}},"class-*":function(t,i){var e;return e=" "+t.className+" ",!i==(-1!==e.indexOf(" "+this.args[0]+" "))?t.className=i?""+t.className+" "+this.args[0]:e.replace(" "+this.args[0]+" "," ").trim():void 0},"*":function(t,i){return i?t.setAttribute(this.type,i):t.removeAttribute(this.type)}},t.internalBinders={textNode:function(t,i){return t.data=null!=i?i:""}},t.components={},t.config={preloadData:!0,handler:function(t,i,e){return this.call(t,i,e.view.models)}},t.formatters={},t.factory=function(i){return i._=t,i.binders=t.binders,i.components=t.components,i.formatters=t.formatters,i.config=t.config,i.configure=function(i){var e,n;null==i&&(i={});for(e in i)n=i[e],t.config[e]=n},i.bind=function(i,e,n){var s;return null==e&&(e={}),null==n&&(n={}),s=new t.View(i,e,n),s.bind(),s}},"object"==typeof exports?t.factory(exports):"function"==typeof define&&define.amd?define(["exports"],function(i){return t.factory(this.rivets=i),i}):t.factory(this.rivets={})}).call(this);
\ No newline at end of file
!function(){var a,b=function(a,b){return function(){return a.apply(b,arguments)}},c=[].slice,d={}.hasOwnProperty,e=function(a,b){function c(){this.constructor=a}for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},f=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};a={},String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),a.Binding=function(){function d(a,c,d,e,f,g){var h,i,j,k;if(this.view=a,this.el=c,this.type=d,this.key=e,this.keypath=f,this.options=null!=g?g:{},this.update=b(this.update,this),this.unbind=b(this.unbind,this),this.bind=b(this.bind,this),this.publish=b(this.publish,this),this.sync=b(this.sync,this),this.set=b(this.set,this),this.eventHandler=b(this.eventHandler,this),this.formattedValue=b(this.formattedValue,this),!(this.binder=this.view.binders[d])){k=this.view.binders;for(h in k)j=k[h],"*"!==h&&-1!==h.indexOf("*")&&(i=new RegExp("^"+h.replace("*",".+")+"$"),i.test(d)&&(this.binder=j,this.args=new RegExp("^"+h.replace("*","(.+)")+"$").exec(d),this.args.shift()))}this.binder||(this.binder=this.view.binders["*"]),this.binder instanceof Function&&(this.binder={routine:this.binder}),this.formatters=this.options.formatters||[],this.model=this.key?this.view.models[this.key]:this.view.models}return d.prototype.formattedValue=function(a){var b,d,e,f,g,h;for(h=this.formatters,f=0,g=h.length;g>f;f++)d=h[f],b=d.split(/\s+/),e=b.shift(),d=this.model[e]instanceof Function?this.model[e]:this.view.formatters[e],(null!=d?d.read:void 0)instanceof Function?a=d.read.apply(d,[a].concat(c.call(b))):d instanceof Function&&(a=d.apply(null,[a].concat(c.call(b))));return a},d.prototype.eventHandler=function(a){var b,c;return c=(b=this).view.config.handler,function(d){return c.call(a,this,d,b)}},d.prototype.set=function(a){var b;return a=a instanceof Function&&!this.binder["function"]?this.formattedValue(a.call(this.model)):this.formattedValue(a),null!=(b=this.binder.routine)?b.call(this,this.el,a):void 0},d.prototype.sync=function(){return this.set(this.options.bypass?this.model[this.keypath]:this.view.config.adapter.read(this.model,this.keypath))},d.prototype.publish=function(){var b,d,e,f,g,h,i,j,k;for(f=a.Util.getInputValue(this.el),i=this.formatters.slice(0).reverse(),g=0,h=i.length;h>g;g++)d=i[g],b=d.split(/\s+/),e=b.shift(),(null!=(j=this.view.formatters[e])?j.publish:void 0)&&(f=(k=this.view.formatters[e]).publish.apply(k,[f].concat(c.call(b))));return this.view.config.adapter.publish(this.model,this.keypath,f)},d.prototype.bind=function(){var a,b,c,d,e,f,g,h,i;if(null!=(f=this.binder.bind)&&f.call(this,this.el),this.options.bypass?this.sync():(this.view.config.adapter.subscribe(this.model,this.keypath,this.sync),this.view.config.preloadData&&this.sync()),null!=(g=this.options.dependencies)?g.length:void 0){for(h=this.options.dependencies,i=[],d=0,e=h.length;e>d;d++)a=h[d],/^\./.test(a)?(c=this.model,b=a.substr(1)):(a=a.split("."),c=this.view.models[a.shift()],b=a.join(".")),i.push(this.view.config.adapter.subscribe(c,b,this.sync));return i}},d.prototype.unbind=function(){var a,b,c,d,e,f,g,h,i;if(null!=(f=this.binder.unbind)&&f.call(this,this.el),this.options.bypass||this.view.config.adapter.unsubscribe(this.model,this.keypath,this.sync),null!=(g=this.options.dependencies)?g.length:void 0){for(h=this.options.dependencies,i=[],d=0,e=h.length;e>d;d++)a=h[d],/^\./.test(a)?(c=this.model,b=a.substr(1)):(a=a.split("."),c=this.view.models[a.shift()],b=a.join(".")),i.push(this.view.config.adapter.unsubscribe(c,b,this.sync));return i}},d.prototype.update=function(a){var b;return null==a&&(a={}),this.key?a[this.key]&&(this.options.bypass||this.view.config.adapter.unsubscribe(this.model,this.keypath,this.sync),this.model=a[this.key],this.options.bypass?this.sync():(this.view.config.adapter.subscribe(this.model,this.keypath,this.sync),this.view.config.preloadData&&this.sync())):this.sync(),null!=(b=this.binder.update)?b.call(this,a):void 0},d}(),a.ComponentBinding=function(c){function d(c,d,e){var g,h,i,j,k;for(this.view=c,this.el=d,this.type=e,this.unbind=b(this.unbind,this),this.bind=b(this.bind,this),this.update=b(this.update,this),this.locals=b(this.locals,this),this.component=a.components[this.type],this.attributes={},this.inflections={},j=this.el.attributes||[],h=0,i=j.length;i>h;h++)g=j[h],k=g.name,f.call(this.component.attributes,k)>=0?this.attributes[g.name]=g.value:this.inflections[g.name]=g.value}return e(d,c),d.prototype.sync=function(){},d.prototype.locals=function(a){var b,c,d,e,f,g,h,i,j;null==a&&(a=this.view.models),f={},i=this.inflections;for(c in i)for(b=i[c],j=b.split("."),g=0,h=j.length;h>g;g++)e=j[g],f[c]=(f[c]||a)[e];for(c in a)d=a[c],null==f[c]&&(f[c]=d);return f},d.prototype.update=function(a){var b;return null!=(b=this.componentView)?b.update(this.locals(a)):void 0},d.prototype.bind=function(){var b,c;return null!=this.componentView?null!=(c=this.componentView)?c.bind():void 0:(b=this.component.build.call(this.attributes),(this.componentView=new a.View(b,this.locals(),this.view.options)).bind(),this.el.parentNode.replaceChild(b,this.el))},d.prototype.unbind=function(){var a;return null!=(a=this.componentView)?a.unbind():void 0},d}(a.Binding),a.TextBinding=function(a){function c(a,c,d,e,f,g){this.view=a,this.el=c,this.type=d,this.key=e,this.keypath=f,this.options=null!=g?g:{},this.sync=b(this.sync,this),this.formatters=this.options.formatters||[],this.model=this.key?this.view.models[this.key]:this.view.models}return e(c,a),c.prototype.binder={routine:function(a,b){return a.data=null!=b?b:""}},c.prototype.sync=function(){return c.__super__.sync.apply(this,arguments)},c}(a.Binding),a.View=function(){function d(c,d,e){var f,g,h,i,j,k,l,m,n;for(this.els=c,this.models=d,this.options=null!=e?e:{},this.update=b(this.update,this),this.publish=b(this.publish,this),this.sync=b(this.sync,this),this.unbind=b(this.unbind,this),this.bind=b(this.bind,this),this.select=b(this.select,this),this.build=b(this.build,this),this.componentRegExp=b(this.componentRegExp,this),this.bindingRegExp=b(this.bindingRegExp,this),this.els.jquery||this.els instanceof Array||(this.els=[this.els]),l=["config","binders","formatters"],j=0,k=l.length;k>j;j++){if(g=l[j],this[g]={},this.options[g]){m=this.options[g];for(f in m)h=m[f],this[g][f]=h}n=a[g];for(f in n)h=n[f],null==(i=this[g])[f]&&(i[f]=h)}this.build()}return d.prototype.bindingRegExp=function(){var a;return a=this.config.prefix,a?new RegExp("^data-"+a+"-"):/^data-/},d.prototype.componentRegExp=function(){var a,b;return new RegExp("^"+(null!=(a=null!=(b=this.config.prefix)?b.toUpperCase():void 0)?a:"RV")+"-")},d.prototype.build=function(){var b,d,e,g,h,i,j,k,l,m=this;for(this.bindings=[],i=[],b=this.bindingRegExp(),e=this.componentRegExp(),d=function(b,c,d,e){var f,g,h,i,j,k,l,n,o,p;return k={},o=function(){var a,b,c,d;for(c=e.split("|"),d=[],a=0,b=c.length;b>a;a++)n=c[a],d.push(n.trim());return d}(),f=function(){var a,b,c,d;for(c=o.shift().split("<"),d=[],a=0,b=c.length;b>a;a++)g=c[a],d.push(g.trim());return d}(),l=f.shift(),p=l.split(/\.|:/),k.formatters=o,k.bypass=-1!==l.indexOf(":"),p[0]?i=p.shift():(i=null,p.shift()),j=p.join("."),(h=f.shift())&&(k.dependencies=h.split(/\s+/)),m.bindings.push(new a[b](m,c,d,i,j,k))},h=function(g){var j,k,l,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P;if(f.call(i,g)<0){if(g.nodeType===Node.TEXT_NODE){if(r=a.TextTemplateParser,(o=m.config.templateDelimiters)&&(x=r.parse(g.data,o)).length&&(1!==x.length||x[0].type!==r.types.text))for(u=x[0],t=2<=x.length?c.call(x,1):[],g.data=u.value,0===u.type?g.data=u.value:d("TextBinding",g,null,u.value),A=0,E=t.length;E>A;A++)w=t[A],v=document.createTextNode(w.value),g.parentNode.appendChild(v),1===w.type&&d("TextBinding",v,null,w.value)}else if(e.test(g.tagName))y=g.tagName.replace(e,"").toLowerCase(),m.bindings.push(new a.ComponentBinding(m,g,y));else if(null!=g.attributes){for(K=g.attributes,B=0,F=K.length;F>B;B++)if(j=K[B],b.test(j.name)){if(y=j.name.replace(b,""),!(l=m.binders[y])){L=m.binders;for(p in L)z=L[p],"*"!==p&&-1!==p.indexOf("*")&&(s=new RegExp("^"+p.replace("*",".+")+"$"),s.test(y)&&(l=z))}if(l||(l=m.binders["*"]),l.block){for(M=g.childNodes,C=0,G=M.length;G>C;C++)q=M[C],i.push(q);k=[j]}}for(N=k||g.attributes,D=0,H=N.length;H>D;D++)j=N[D],b.test(j.name)&&(y=j.name.replace(b,""),d("Binding",g,y,j.value))}for(O=g.childNodes,P=[],J=0,I=O.length;I>J;J++)n=O[J],P.push(h(n));return P}},l=this.els,j=0,k=l.length;k>j;j++)g=l[j],h(g)},d.prototype.select=function(a){var b,c,d,e,f;for(e=this.bindings,f=[],c=0,d=e.length;d>c;c++)b=e[c],a(b)&&f.push(b);return f},d.prototype.bind=function(){var a,b,c,d,e;for(d=this.bindings,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.bind());return e},d.prototype.unbind=function(){var a,b,c,d,e;for(d=this.bindings,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.unbind());return e},d.prototype.sync=function(){var a,b,c,d,e;for(d=this.bindings,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.sync());return e},d.prototype.publish=function(){var a,b,c,d,e;for(d=this.select(function(a){return a.binder.publishes}),e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.publish());return e},d.prototype.update=function(a){var b,c,d,e,f,g,h;null==a&&(a={});for(c in a)d=a[c],this.models[c]=d;for(g=this.bindings,h=[],e=0,f=g.length;f>e;e++)b=g[e],h.push(b.update(a));return h},d}(),a.TextTemplateParser=function(){function a(){}return a.types={text:0,binding:1},a.parse=function(a,b){var c,d,e,f,g,h,i;for(h=[],f=a.length,c=0,d=0;f>d;){if(c=a.indexOf(b[0],d),0>c){h.push({type:this.types.text,value:a.slice(d)});break}if(c>0&&c>d&&h.push({type:this.types.text,value:a.slice(d,c)}),d=c+2,c=a.indexOf(b[1],d),0>c){g=a.slice(d-2),e=h[h.length-1],(null!=e?e.type:void 0)===this.types.text?e.value+=g:h.push({type:this.types.text,value:g});break}i=a.slice(d,c).trim(),h.push({type:this.types.binding,value:i}),d=c+2}return h},a}(),a.Util={bindEvent:function(a,b,c){return null!=window.jQuery?(a=jQuery(a),null!=a.on?a.on(b,c):a.bind(b,c)):null!=window.addEventListener?a.addEventListener(b,c,!1):(b="on"+b,a.attachEvent(b,c))},unbindEvent:function(a,b,c){return null!=window.jQuery?(a=jQuery(a),null!=a.off?a.off(b,c):a.unbind(b,c)):null!=window.removeEventListener?a.removeEventListener(b,c,!1):(b="on"+b,a.detachEvent(b,c))},getInputValue:function(a){var b,c,d,e;if(null!=window.jQuery)switch(a=jQuery(a),a[0].type){case"checkbox":return a.is(":checked");default:return a.val()}else switch(a.type){case"checkbox":return a.checked;case"select-multiple":for(e=[],c=0,d=a.length;d>c;c++)b=a[c],b.selected&&e.push(b.value);return e;default:return a.value}}},a.binders={enabled:function(a,b){return a.disabled=!b},disabled:function(a,b){return a.disabled=!!b},checked:{publishes:!0,bind:function(b){return a.Util.bindEvent(b,"change",this.publish)},unbind:function(b){return a.Util.unbindEvent(b,"change",this.publish)},routine:function(a,b){var c;return a.checked="radio"===a.type?(null!=(c=a.value)?c.toString():void 0)===(null!=b?b.toString():void 0):!!b}},unchecked:{publishes:!0,bind:function(b){return a.Util.bindEvent(b,"change",this.publish)},unbind:function(b){return a.Util.unbindEvent(b,"change",this.publish)},routine:function(a,b){var c;return a.checked="radio"===a.type?(null!=(c=a.value)?c.toString():void 0)!==(null!=b?b.toString():void 0):!b}},show:function(a,b){return a.style.display=b?"":"none"},hide:function(a,b){return a.style.display=b?"none":""},html:function(a,b){return a.innerHTML=null!=b?b:""},value:{publishes:!0,bind:function(b){return a.Util.bindEvent(b,"change",this.publish)},unbind:function(b){return a.Util.unbindEvent(b,"change",this.publish)},routine:function(a,b){var c,d,e,g,h,i,j;if(null!=window.jQuery){if(a=jQuery(a),(null!=b?b.toString():void 0)!==(null!=(g=a.val())?g.toString():void 0))return a.val(null!=b?b:"")}else if("select-multiple"===a.type){if(null!=b){for(j=[],d=0,e=a.length;e>d;d++)c=a[d],j.push(c.selected=(h=c.value,f.call(b,h)>=0));return j}}else if((null!=b?b.toString():void 0)!==(null!=(i=a.value)?i.toString():void 0))return a.value=null!=b?b:""}},text:function(a,b){return null!=a.innerText?a.innerText=null!=b?b:"":a.textContent=null!=b?b:""},"if":{block:!0,bind:function(a){var b,c;return null==this.marker?(b=["data",this.view.config.prefix,this.type].join("-").replace("--","-"),c=a.getAttribute(b),this.marker=document.createComment(" rivets: "+this.type+" "+c+" "),a.removeAttribute(b),a.parentNode.insertBefore(this.marker,a),a.parentNode.removeChild(a)):void 0},unbind:function(){var a;return null!=(a=this.nested)?a.unbind():void 0},routine:function(b,c){var d,e,f,g,h;if(!!c==(null==this.nested)){if(c){f={},h=this.view.models;for(d in h)e=h[d],f[d]=e;return g={binders:this.view.options.binders,formatters:this.view.options.formatters,config:this.view.options.config},(this.nested=new a.View(b,f,g)).bind(),this.marker.parentNode.insertBefore(b,this.marker.nextSibling)}return b.parentNode.removeChild(b),this.nested.unbind(),delete this.nested}},update:function(a){var b;return null!=(b=this.nested)?b.update(a):void 0}},unless:{block:!0,bind:function(b){return a.binders["if"].bind.call(this,b)},unbind:function(){return a.binders["if"].unbind.call(this)},routine:function(b,c){return a.binders["if"].routine.call(this,b,!c)},update:function(b){return a.binders["if"].update.call(this,b)}},"on-*":{"function":!0,unbind:function(b){return this.handler?a.Util.unbindEvent(b,this.args[0],this.handler):void 0},routine:function(b,c){return this.handler&&a.Util.unbindEvent(b,this.args[0],this.handler),a.Util.bindEvent(b,this.args[0],this.handler=this.eventHandler(c))}},"each-*":{block:!0,bind:function(a){var b;return null==this.marker?(b=["data",this.view.config.prefix,this.type].join("-").replace("--","-"),this.marker=document.createComment(" rivets: "+this.type+" "),this.iterated=[],a.removeAttribute(b),a.parentNode.insertBefore(this.marker,a),a.parentNode.removeChild(a)):void 0},unbind:function(){var a,b,c,d,e;if(null!=this.iterated){for(d=this.iterated,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.unbind());return e}},routine:function(b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;if(j=this.args[0],c=c||[],this.iterated.length>c.length)for(t=Array(this.iterated.length-c.length),p=0,r=t.length;r>p;p++)e=t[p],o=this.iterated.pop(),o.unbind(),this.marker.parentNode.removeChild(o.els[0]);for(w=[],f=q=0,s=c.length;s>q;f=++q)if(i=c[f],d={},d[j]=i,null==this.iterated[f]){u=this.view.models;for(h in u)i=u[h],null==d[h]&&(d[h]=i);l=this.iterated.length?this.iterated[this.iterated.length-1].els[0]:this.marker,k={binders:this.view.options.binders,formatters:this.view.options.formatters,config:{}},v=this.view.options.config;for(g in v)n=v[g],k.config[g]=n;k.config.preloadData=!0,m=b.cloneNode(!0),o=new a.View(m,d,k),o.bind(),this.iterated.push(o),w.push(this.marker.parentNode.insertBefore(m,l.nextSibling))}else this.iterated[f].models[j]!==i?w.push(this.iterated[f].update(d)):w.push(void 0);return w},update:function(a){var b,c,d,e,f,g,h,i;b={};for(c in a)d=a[c],c!==this.args[0]&&(b[c]=d);for(h=this.iterated,i=[],f=0,g=h.length;g>f;f++)e=h[f],i.push(e.update(b));return i}},"class-*":function(a,b){var c;return c=" "+a.className+" ",!b==(-1!==c.indexOf(" "+this.args[0]+" "))?a.className=b?""+a.className+" "+this.args[0]:c.replace(" "+this.args[0]+" "," ").trim():void 0},"*":function(a,b){return b?a.setAttribute(this.type,b):a.removeAttribute(this.type)}},a.components={},a.config={preloadData:!0,handler:function(a,b,c){return this.call(a,b,c.view.models)}},a.formatters={},a.factory=function(b){return b._=a,b.binders=a.binders,b.components=a.components,b.formatters=a.formatters,b.config=a.config,b.configure=function(b){var c,d;null==b&&(b={});for(c in b)d=b[c],a.config[c]=d},b.bind=function(b,c,d){var e;return null==c&&(c={}),null==d&&(d={}),e=new a.View(b,c,d),e.bind(),e}},"object"==typeof exports?a.factory(exports):"function"==typeof define&&define.amd?define(["exports"],function(b){return a.factory(this.rivets=b),b}):a.factory(this.rivets={})}.call(this);
\ No newline at end of file
......
{
"name": "rivets",
"description": "Declarative data binding facility.",
"version": "0.5.11",
"version": "0.5.12",
"author": "Michael Richards",
"url": "http://rivetsjs.com",
"main": "./dist/rivets.js",
......
# Rivets.js
# =========
# > version: 0.5.11
# > version: 0.5.12
# > author: Michael Richards
# > license: MIT
# >
......