d924282f by Michael Richards

Build 0.5.3.

1 parent c4620bf8
......@@ -2,7 +2,7 @@
"name": "rivets",
"repo": "mikeric/rivets",
"description": "Declarative data binding facility.",
"version": "0.5.2",
"version": "0.5.3",
"keywords": ["data binding", "templating"],
"scripts": ["dist/rivets.js"],
"main": "dist/rivets.js",
......
// Rivets.js
// version: 0.5.2
// version: 0.5.3
// author: Michael Richards
// license: MIT
(function() {
......@@ -595,10 +595,17 @@
},
"each-*": {
block: true,
bind: function(el, collection) {
return el.removeAttribute(['data', this.view.config.prefix, this.type].join('-').replace('--', '-'));
bind: function(el) {
var attr;
attr = ['data', this.view.config.prefix, this.type].join('-').replace('--', '-');
this.marker = document.createComment(" rivets: " + this.type + " ");
this.iterated = [];
el.removeAttribute(attr);
el.parentNode.insertBefore(this.marker, el);
return el.parentNode.removeChild(el);
},
unbind: function(el, collection) {
unbind: function(el) {
var view, _i, _len, _ref, _results;
if (this.iterated != null) {
......@@ -612,58 +619,52 @@
}
},
routine: function(el, collection) {
var data, e, item, itemEl, k, m, n, options, previous, v, view, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _ref4, _results;
var data, i, index, k, key, model, modelName, options, previous, template, v, view, _i, _j, _len, _len1, _ref, _ref1, _ref2, _results;
if (this.iterated != null) {
_ref = this.iterated;
modelName = this.args[0];
collection = collection || [];
if (this.iterated.length > collection.length) {
_ref = Array(this.iterated.length - collection.length);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
view = _ref[_i];
i = _ref[_i];
view = this.iterated.pop();
view.unbind();
_ref1 = view.els;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
e = _ref1[_j];
e.parentNode.removeChild(e);
}
this.marker.parentNode.removeChild(view.els[0]);
}
} else {
this.marker = document.createComment(" rivets: " + this.type + " ");
el.parentNode.insertBefore(this.marker, el);
el.parentNode.removeChild(el);
}
this.iterated = [];
if (collection) {
_results = [];
for (_k = 0, _len2 = collection.length; _k < _len2; _k++) {
item = collection[_k];
data = {};
_ref2 = this.view.models;
for (n in _ref2) {
m = _ref2[n];
data[n] = m;
_results = [];
for (index = _j = 0, _len1 = collection.length; _j < _len1; index = ++_j) {
model = collection[index];
data = {};
data[modelName] = model;
if (this.iterated[index] == null) {
_ref1 = this.view.models;
for (key in _ref1) {
model = _ref1[key];
data[key] = model;
}
data[this.args[0]] = item;
itemEl = el.cloneNode(true);
previous = this.iterated.length ? this.iterated[this.iterated.length - 1].els[0] : this.marker;
this.marker.parentNode.insertBefore(itemEl, (_ref3 = previous.nextSibling) != null ? _ref3 : null);
options = {
binders: this.view.options.binders,
formatters: this.view.options.binders,
formatters: this.view.options.formatters,
config: {}
};
if (this.view.options.config) {
_ref4 = this.view.options.config;
for (k in _ref4) {
v = _ref4[k];
options.config[k] = v;
}
_ref2 = this.view.options.config;
for (k in _ref2) {
v = _ref2[k];
options.config[k] = v;
}
options.config.preloadData = true;
view = new Rivets.View(itemEl, data, options);
view.bind();
_results.push(this.iterated.push(view));
template = el.cloneNode(true);
this.iterated.push(rivets.bind(template, data, options));
_results.push(this.marker.parentNode.insertBefore(template, previous.nextSibling));
} else if (this.iterated[index].models[modelName] !== model) {
_results.push(this.iterated[index].update(data));
} else {
_results.push(void 0);
}
return _results;
}
return _results;
}
},
"class-*": function(el, value) {
......
// Rivets.js
// version: 0.5.2
// version: 0.5.3
// author: Michael Richards
// license: MIT
(function(){var t,i=function(t,i){return function(){return t.apply(i,arguments)}},e=[].slice,n=[].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(t,e,n,s,r,o){var h,u,l,a;if(this.view=t,this.el=e,this.type=n,this.key=s,this.keypath=r,this.options=null!=o?o:{},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.formattedValue=i(this.formattedValue,this),!(this.binder=this.view.binders[n])){a=this.view.binders;for(h in a)l=a[h],"*"!==h&&-1!==h.indexOf("*")&&(u=RegExp("^"+h.replace("*",".+")+"$"),u.test(n)&&(this.binder=l,this.args=RegExp("^"+h.replace("*","(.+)")+"$").exec(n),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.view.models[this.key]}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.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,u,l,a;for(r=t.Util.getInputValue(this.el),u=this.formatters.slice(0).reverse(),o=0,h=u.length;h>o;o++)n=u[o],i=n.split(/\s+/),s=i.shift(),(null!=(l=this.view.formatters[s])?l.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,u;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,u=[],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(".")),u.push(this.view.config.adapter.subscribe(e,i,this.sync));return u}},n.prototype.unbind=function(){var t,i,e,n,s,r,o,h,u;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,u=[],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(".")),u.push(this.view.config.adapter.unsubscribe(e,i,this.sync));return u}},n.prototype.update=function(){return this.unbind(),this.model=this.view.models[this.key],this.bind()},n}(),t.View=function(){function e(e,n,s){var r,o,h,u,l,a,d,c,f,p;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.bindingRegExp=i(this.bindingRegExp,this),this.els.jquery||this.els instanceof Array||(this.els=[this.els]),d=["config","binders","formatters"],l=0,a=d.length;a>l;l++){if(o=d[l],this[o]={},this.options[o]){c=this.options[o];for(r in c)h=c[r],this[o][r]=h}f=t[o];for(r in f)h=f[r],null==(p=(u=this[o])[r])&&(u[r]=h)}this.build()}return e.prototype.bindingRegExp=function(){var t;return t=this.config.prefix,t?RegExp("^data-"+t+"-"):/^data-/},e.prototype.build=function(){var i,e,s,r,o,h,u,l,a,d,c,f=this;for(this.bindings=[],o=[],i=this.bindingRegExp(),r=function(e){var s,r,h,u,l,a,d,c,p,b,v,g,y,m,w,x,E,k,j,L,N,U,V,Q,R,B,F,O;if(0>n.call(o,e)){for(R=e.attributes,j=0,U=R.length;U>j;j++)if(s=R[j],i.test(s.name)){if(E=s.name.replace(i,""),!(h=f.binders[E])){B=f.binders;for(d in B)k=B[d],"*"!==d&&-1!==d.indexOf("*")&&(w=RegExp("^"+d.replace("*",".+")+"$"),w.test(E)&&(h=k))}if(h||(h=f.binders["*"]),h.block){for(F=e.getElementsByTagName("*"),L=0,V=F.length;V>L;L++)b=F[L],o.push(b);r=[s]}}for(O=r||e.attributes,N=0,Q=O.length;Q>N;N++)s=O[N],i.test(s.name)&&(v={},E=s.name.replace(i,""),m=function(){var t,i,e,n;for(e=s.value.split("|"),n=[],t=0,i=e.length;i>t;t++)y=e[t],n.push(y.trim());return n}(),u=function(){var t,i,e,n;for(e=m.shift().split("<"),n=[],t=0,i=e.length;i>t;t++)l=e[t],n.push(l.trim());return n}(),g=u.shift(),x=g.split(/\.|:/),v.formatters=m,v.bypass=-1!==g.indexOf(":"),x[0]?c=x.shift():(c=null,x.shift()),p=x.join("."),null!=f.models[c]&&((a=u.shift())&&(v.dependencies=a.split(/\s+/)),f.bindings.push(new t.Binding(f,e,E,c,p,v))));r&&(r=null)}},d=this.els,h=0,l=d.length;l>h;h++)for(e=d[h],r(e),c=e.getElementsByTagName("*"),u=0,a=c.length;a>u;u++)s=c[u],null!=s.attributes&&r(s)},e.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},e.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},e.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},e.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},e.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},e.prototype.update=function(t){var i,e,n,s;null==t&&(t={}),s=[];for(e in t)n=t[e],this.models[e]=n,s.push(function(){var t,n,s,r;for(s=this.select(function(t){return t.key===e}),r=[],t=0,n=s.length;n>t;t++)i=s[t],r.push(i.update());return r}.call(this));return s},e}(),t.Util={bindEvent:function(t,i,e,n){var s;return s=function(t){return e.call(this,t,n)},null!=window.jQuery?(t=jQuery(t),null!=t.on?t.on(i,s):t.bind(i,s)):null!=window.addEventListener?t.addEventListener(i,s,!1):(i="on"+i,t.attachEvent(i,s)),s},unbindEvent:function(t,i,e){return null!=window.jQuery?(t=jQuery(t),null!=t.off?t.off(i,e):t.unbind(i,e)):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 this.currentListener=t.Util.bindEvent(i,"change",this.publish)},unbind:function(i){return t.Util.unbindEvent(i,"change",this.currentListener)},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 this.currentListener=t.Util.bindEvent(i,"change",this.publish)},unbind:function(i){return t.Util.unbindEvent(i,"change",this.currentListener)},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 this.currentListener=t.Util.bindEvent(i,"change",this.publish)},unbind:function(i){return t.Util.unbindEvent(i,"change",this.currentListener)},routine:function(t,i){var e,s,r,o,h,u,l;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(l=[],s=0,r=t.length;r>s;s++)e=t[s],l.push(e.selected=(h=e.value,n.call(i,h)>=0));return l}}else if((null!=i?""+i:void 0)!==(null!=(u=t.value)?""+u: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:""},"on-*":{"function":!0,routine:function(i,e){return this.currentListener&&t.Util.unbindEvent(i,this.args[0],this.currentListener),this.currentListener=t.Util.bindEvent(i,this.args[0],e,this.view)}},"each-*":{block:!0,bind:function(t){return t.removeAttribute(["data",this.view.config.prefix,this.type].join("-").replace("--","-"))},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,u,l,a,d,c,f,p,b,v,g,y,m,w,x,E,k,j,L;if(null!=this.iterated)for(w=this.iterated,p=0,g=w.length;g>p;p++)for(f=w[p],f.unbind(),x=f.els,b=0,y=x.length;y>b;b++)s=x[b],s.parentNode.removeChild(s);else this.marker=document.createComment(" rivets: "+this.type+" "),i.parentNode.insertBefore(this.marker,i),i.parentNode.removeChild(i);if(this.iterated=[],e){for(L=[],v=0,m=e.length;m>v;v++){r=e[v],n={},E=this.view.models;for(l in E)u=E[l],n[l]=u;if(n[this.args[0]]=r,o=i.cloneNode(!0),d=this.iterated.length?this.iterated[this.iterated.length-1].els[0]:this.marker,this.marker.parentNode.insertBefore(o,null!=(k=d.nextSibling)?k:null),a={binders:this.view.options.binders,formatters:this.view.options.binders,config:{}},this.view.options.config){j=this.view.options.config;for(h in j)c=j[h],a.config[h]=c}a.config.preloadData=!0,f=new t.View(o,n,a),f.bind(),L.push(this.iterated.push(f))}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.config={preloadData:!0},t.formatters={},t.factory=function(i){return i.binders=t.binders,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 t,i=function(t,i){return function(){return t.apply(i,arguments)}},e=[].slice,n=[].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(t,e,n,s,r,h){var o,u,l,a;if(this.view=t,this.el=e,this.type=n,this.key=s,this.keypath=r,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.formattedValue=i(this.formattedValue,this),!(this.binder=this.view.binders[n])){a=this.view.binders;for(o in a)l=a[o],"*"!==o&&-1!==o.indexOf("*")&&(u=RegExp("^"+o.replace("*",".+")+"$"),u.test(n)&&(this.binder=l,this.args=RegExp("^"+o.replace("*","(.+)")+"$").exec(n),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.view.models[this.key]}return n.prototype.formattedValue=function(t){var i,n,s,r,h,o;for(o=this.formatters,r=0,h=o.length;h>r;r++)n=o[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.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,h,o,u,l,a;for(r=t.Util.getInputValue(this.el),u=this.formatters.slice(0).reverse(),h=0,o=u.length;o>h;h++)n=u[h],i=n.split(/\s+/),s=i.shift(),(null!=(l=this.view.formatters[s])?l.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,h,o,u;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!=(h=this.options.dependencies)?h.length:void 0){for(o=this.options.dependencies,u=[],n=0,s=o.length;s>n;n++)t=o[n],/^\./.test(t)?(e=this.model,i=t.substr(1)):(t=t.split("."),e=this.view.models[t.shift()],i=t.join(".")),u.push(this.view.config.adapter.subscribe(e,i,this.sync));return u}},n.prototype.unbind=function(){var t,i,e,n,s,r,h,o,u;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!=(h=this.options.dependencies)?h.length:void 0){for(o=this.options.dependencies,u=[],n=0,s=o.length;s>n;n++)t=o[n],/^\./.test(t)?(e=this.model,i=t.substr(1)):(t=t.split("."),e=this.view.models[t.shift()],i=t.join(".")),u.push(this.view.config.adapter.unsubscribe(e,i,this.sync));return u}},n.prototype.update=function(){return this.unbind(),this.model=this.view.models[this.key],this.bind()},n}(),t.View=function(){function e(e,n,s){var r,h,o,u,l,a,d,c,f,p;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.bindingRegExp=i(this.bindingRegExp,this),this.els.jquery||this.els instanceof Array||(this.els=[this.els]),d=["config","binders","formatters"],l=0,a=d.length;a>l;l++){if(h=d[l],this[h]={},this.options[h]){c=this.options[h];for(r in c)o=c[r],this[h][r]=o}f=t[h];for(r in f)o=f[r],null==(p=(u=this[h])[r])&&(u[r]=o)}this.build()}return e.prototype.bindingRegExp=function(){var t;return t=this.config.prefix,t?RegExp("^data-"+t+"-"):/^data-/},e.prototype.build=function(){var i,e,s,r,h,o,u,l,a,d,c,f=this;for(this.bindings=[],h=[],i=this.bindingRegExp(),r=function(e){var s,r,o,u,l,a,d,c,p,b,v,g,y,m,w,x,E,k,j,L,N,U,V,Q,R,B,A,F;if(0>n.call(h,e)){for(R=e.attributes,j=0,U=R.length;U>j;j++)if(s=R[j],i.test(s.name)){if(E=s.name.replace(i,""),!(o=f.binders[E])){B=f.binders;for(d in B)k=B[d],"*"!==d&&-1!==d.indexOf("*")&&(w=RegExp("^"+d.replace("*",".+")+"$"),w.test(E)&&(o=k))}if(o||(o=f.binders["*"]),o.block){for(A=e.getElementsByTagName("*"),L=0,V=A.length;V>L;L++)b=A[L],h.push(b);r=[s]}}for(F=r||e.attributes,N=0,Q=F.length;Q>N;N++)s=F[N],i.test(s.name)&&(v={},E=s.name.replace(i,""),m=function(){var t,i,e,n;for(e=s.value.split("|"),n=[],t=0,i=e.length;i>t;t++)y=e[t],n.push(y.trim());return n}(),u=function(){var t,i,e,n;for(e=m.shift().split("<"),n=[],t=0,i=e.length;i>t;t++)l=e[t],n.push(l.trim());return n}(),g=u.shift(),x=g.split(/\.|:/),v.formatters=m,v.bypass=-1!==g.indexOf(":"),x[0]?c=x.shift():(c=null,x.shift()),p=x.join("."),null!=f.models[c]&&((a=u.shift())&&(v.dependencies=a.split(/\s+/)),f.bindings.push(new t.Binding(f,e,E,c,p,v))));r&&(r=null)}},d=this.els,o=0,l=d.length;l>o;o++)for(e=d[o],r(e),c=e.getElementsByTagName("*"),u=0,a=c.length;a>u;u++)s=c[u],null!=s.attributes&&r(s)},e.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},e.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},e.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},e.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},e.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},e.prototype.update=function(t){var i,e,n,s;null==t&&(t={}),s=[];for(e in t)n=t[e],this.models[e]=n,s.push(function(){var t,n,s,r;for(s=this.select(function(t){return t.key===e}),r=[],t=0,n=s.length;n>t;t++)i=s[t],r.push(i.update());return r}.call(this));return s},e}(),t.Util={bindEvent:function(t,i,e,n){var s;return s=function(t){return e.call(this,t,n)},null!=window.jQuery?(t=jQuery(t),null!=t.on?t.on(i,s):t.bind(i,s)):null!=window.addEventListener?t.addEventListener(i,s,!1):(i="on"+i,t.attachEvent(i,s)),s},unbindEvent:function(t,i,e){return null!=window.jQuery?(t=jQuery(t),null!=t.off?t.off(i,e):t.unbind(i,e)):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 this.currentListener=t.Util.bindEvent(i,"change",this.publish)},unbind:function(i){return t.Util.unbindEvent(i,"change",this.currentListener)},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 this.currentListener=t.Util.bindEvent(i,"change",this.publish)},unbind:function(i){return t.Util.unbindEvent(i,"change",this.currentListener)},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 this.currentListener=t.Util.bindEvent(i,"change",this.publish)},unbind:function(i){return t.Util.unbindEvent(i,"change",this.currentListener)},routine:function(t,i){var e,s,r,h,o,u,l;if(null!=window.jQuery){if(t=jQuery(t),(null!=i?""+i:void 0)!==(null!=(h=t.val())?""+h:void 0))return t.val(null!=i?i:"")}else if("select-multiple"===t.type){if(null!=i){for(l=[],s=0,r=t.length;r>s;s++)e=t[s],l.push(e.selected=(o=e.value,n.call(i,o)>=0));return l}}else if((null!=i?""+i:void 0)!==(null!=(u=t.value)?""+u: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:""},"on-*":{"function":!0,routine:function(i,e){return this.currentListener&&t.Util.unbindEvent(i,this.args[0],this.currentListener),this.currentListener=t.Util.bindEvent(i,this.args[0],e,this.view)}},"each-*":{block:!0,bind:function(t){var i;return 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)},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(t,i){var e,n,s,r,h,o,u,l,a,d,c,f,p,b,v,g,y,m,w,x;if(u=this.args[0],i=i||[],this.iterated.length>i.length)for(y=Array(this.iterated.length-i.length),p=0,v=y.length;v>p;p++)n=y[p],f=this.iterated.pop(),f.unbind(),this.marker.parentNode.removeChild(f.els[0]);for(x=[],s=b=0,g=i.length;g>b;s=++b)if(o=i[s],e={},e[u]=o,null==this.iterated[s]){m=this.view.models;for(h in m)o=m[h],e[h]=o;a=this.iterated.length?this.iterated[this.iterated.length-1].els[0]:this.marker,l={binders:this.view.options.binders,formatters:this.view.options.formatters,config:{}},w=this.view.options.config;for(r in w)c=w[r],l.config[r]=c;l.config.preloadData=!0,d=t.cloneNode(!0),this.iterated.push(rivets.bind(d,e,l)),x.push(this.marker.parentNode.insertBefore(d,a.nextSibling))}else this.iterated[s].models[u]!==o?x.push(this.iterated[s].update(e)):x.push(void 0);return x}},"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.config={preloadData:!0},t.formatters={},t.factory=function(i){return i.binders=t.binders,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
......
{
"name": "rivets",
"description": "Declarative data binding facility.",
"version": "0.5.2",
"version": "0.5.3",
"author": "Michael Richards",
"url": "http://rivetsjs.com",
"main": "./dist/rivets.js",
......
# Rivets.js
# =========
# > version: 0.5.2
# > version: 0.5.3
# > author: Michael Richards
# > license: MIT
# >
......