Build 0.4.1.
Showing
4 changed files
with
17 additions
and
17 deletions
1 | // rivets.js | 1 | // rivets.js |
2 | // version: 0.4.0 | 2 | // version: 0.4.1 |
3 | // author: Michael Richards | 3 | // author: Michael Richards |
4 | // license: MIT | 4 | // license: MIT |
5 | (function() { | 5 | (function() { |
... | @@ -88,12 +88,12 @@ | ... | @@ -88,12 +88,12 @@ |
88 | 88 | ||
89 | Binding.prototype.bind = function() { | 89 | Binding.prototype.bind = function() { |
90 | var dependency, keypath, model, _i, _len, _ref, _ref1, _ref2, _results; | 90 | var dependency, keypath, model, _i, _len, _ref, _ref1, _ref2, _results; |
91 | if ((_ref = this.binder.bind) != null) { | ||
92 | _ref.call(this, this.el); | ||
93 | } | ||
91 | if (this.options.bypass) { | 94 | if (this.options.bypass) { |
92 | this.sync(); | 95 | this.sync(); |
93 | } else { | 96 | } else { |
94 | if ((_ref = this.binder.bind) != null) { | ||
95 | _ref.call(this, this.el); | ||
96 | } | ||
97 | Rivets.config.adapter.subscribe(this.model, this.keypath, this.sync); | 97 | Rivets.config.adapter.subscribe(this.model, this.keypath, this.sync); |
98 | if (Rivets.config.preloadData) { | 98 | if (Rivets.config.preloadData) { |
99 | this.sync(); | 99 | this.sync(); |
... | @@ -120,10 +120,10 @@ | ... | @@ -120,10 +120,10 @@ |
120 | 120 | ||
121 | Binding.prototype.unbind = function() { | 121 | Binding.prototype.unbind = function() { |
122 | var keypath, _i, _len, _ref, _ref1, _ref2, _results; | 122 | var keypath, _i, _len, _ref, _ref1, _ref2, _results; |
123 | if ((_ref = this.binder.unbind) != null) { | ||
124 | _ref.call(this, this.el); | ||
125 | } | ||
123 | if (!this.options.bypass) { | 126 | if (!this.options.bypass) { |
124 | if ((_ref = this.binder.unbind) != null) { | ||
125 | _ref.call(this, this.el); | ||
126 | } | ||
127 | Rivets.config.adapter.unsubscribe(this.model, this.keypath, this.sync); | 127 | Rivets.config.adapter.unsubscribe(this.model, this.keypath, this.sync); |
128 | } | 128 | } |
129 | if ((_ref1 = this.options.dependencies) != null ? _ref1.length : void 0) { | 129 | if ((_ref1 = this.options.dependencies) != null ? _ref1.length : void 0) { |
... | @@ -407,10 +407,10 @@ | ... | @@ -407,10 +407,10 @@ |
407 | checked: { | 407 | checked: { |
408 | publishes: true, | 408 | publishes: true, |
409 | bind: function(el) { | 409 | bind: function(el) { |
410 | return bindEvent(el, 'change', this.publish); | 410 | return this.currentListener = bindEvent(el, 'change', this.publish); |
411 | }, | 411 | }, |
412 | unbind: function(el) { | 412 | unbind: function(el) { |
413 | return unbindEvent(el, 'change', this.publish); | 413 | return unbindEvent(el, 'change', this.currentListener); |
414 | }, | 414 | }, |
415 | routine: function(el, value) { | 415 | routine: function(el, value) { |
416 | if (el.type === 'radio') { | 416 | if (el.type === 'radio') { |
... | @@ -423,10 +423,10 @@ | ... | @@ -423,10 +423,10 @@ |
423 | unchecked: { | 423 | unchecked: { |
424 | publishes: true, | 424 | publishes: true, |
425 | bind: function(el) { | 425 | bind: function(el) { |
426 | return bindEvent(el, 'change', this.publish); | 426 | return this.currentListener = bindEvent(el, 'change', this.publish); |
427 | }, | 427 | }, |
428 | unbind: function(el) { | 428 | unbind: function(el) { |
429 | return unbindEvent(el, 'change', this.publish); | 429 | return unbindEvent(el, 'change', this.currentListener); |
430 | }, | 430 | }, |
431 | routine: function(el, value) { | 431 | routine: function(el, value) { |
432 | if (el.type === 'radio') { | 432 | if (el.type === 'radio') { |
... | @@ -448,10 +448,10 @@ | ... | @@ -448,10 +448,10 @@ |
448 | value: { | 448 | value: { |
449 | publishes: true, | 449 | publishes: true, |
450 | bind: function(el) { | 450 | bind: function(el) { |
451 | return bindEvent(el, 'change', this.publish); | 451 | return this.currentListener = bindEvent(el, 'change', this.publish); |
452 | }, | 452 | }, |
453 | unbind: function(el) { | 453 | unbind: function(el) { |
454 | return unbindEvent(el, 'change', this.publish); | 454 | return unbindEvent(el, 'change', this.currentListener); |
455 | }, | 455 | }, |
456 | routine: function(el, value) { | 456 | routine: function(el, value) { |
457 | var o, _i, _len, _ref, _results; | 457 | var o, _i, _len, _ref, _results; | ... | ... |
1 | // rivets.js | 1 | // rivets.js |
2 | // version: 0.4.0 | 2 | // version: 0.4.1 |
3 | // author: Michael Richards | 3 | // author: Michael Richards |
4 | // license: MIT | 4 | // license: MIT |
5 | (function(){var a,b,c,d,e,f=function(a,b){return function(){return a.apply(b,arguments)}},g=[].slice,h=[].indexOf||function(a){for(var b=0,c=this.length;b<c;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 b(b,c,d,e,g){var h,i,j,k;this.el=b,this.type=c,this.model=d,this.keypath=e,this.options=g!=null?g:{},this.unbind=f(this.unbind,this),this.bind=f(this.bind,this),this.publish=f(this.publish,this),this.sync=f(this.sync,this),this.set=f(this.set,this),this.formattedValue=f(this.formattedValue,this);if(!(this.binder=a.binders[c])){k=a.binders;for(h in k)j=k[h],h!=="*"&&h.indexOf("*")!==-1&&(i=new RegExp("^"+h.replace("*",".+")+"$"),i.test(c)&&(this.binder=j,this.args=(new RegExp("^"+h.replace("*","(.+)")+"$")).exec(c),this.args.shift()))}this.binder||(this.binder=a.binders["*"]),this.binder instanceof Function&&(this.binder={routine:this.binder}),this.formatters=this.options.formatters||[]}return b.prototype.formattedValue=function(b){var c,d,e,f,h,i,j,k;i=this.formatters;for(f=0,h=i.length;f<h;f++)d=i[f],c=d.split(/\s+/),e=c.shift(),b=this.model[e]instanceof Function?(j=this.model)[e].apply(j,[b].concat(g.call(c))):a.formatters[e]?(k=a.formatters)[e].apply(k,[b].concat(g.call(c))):void 0;return b},b.prototype.set=function(a){var b;return a=a instanceof Function&&!this.binder["function"]?this.formattedValue(a.call(this.model)):this.formattedValue(a),(b=this.binder.routine)!=null?b.call(this,this.el,a):void 0},b.prototype.sync=function(){return this.set(this.options.bypass?this.model[this.keypath]:a.config.adapter.read(this.model,this.keypath))},b.prototype.publish=function(){return a.config.adapter.publish(this.model,this.keypath,c(this.el))},b.prototype.bind=function(){var b,c,d,e,f,g,h,i,j;this.options.bypass?this.sync():((g=this.binder.bind)!=null&&g.call(this,this.el),a.config.adapter.subscribe(this.model,this.keypath,this.sync),a.config.preloadData&&this.sync());if((h=this.options.dependencies)!=null?h.length:void 0){i=this.options.dependencies,j=[];for(e=0,f=i.length;e<f;e++)b=i[e],/^\./.test(b)?(d=this.model,c=b.substr(1)):(b=b.split("."),d=this.view.models[b.shift()],c=b.join(".")),j.push(a.config.adapter.subscribe(d,c,this.sync));return j}},b.prototype.unbind=function(){var b,c,d,e,f,g,h;this.options.bypass||((e=this.binder.unbind)!=null&&e.call(this,this.el),a.config.adapter.unsubscribe(this.model,this.keypath,this.sync));if((f=this.options.dependencies)!=null?f.length:void 0){g=this.options.dependencies,h=[];for(c=0,d=g.length;c<d;c++)b=g[c],h.push(a.config.adapter.unsubscribe(this.model,b,this.sync));return h}},b}(),a.View=function(){function b(a,b){this.els=a,this.models=b,this.publish=f(this.publish,this),this.sync=f(this.sync,this),this.unbind=f(this.unbind,this),this.bind=f(this.bind,this),this.select=f(this.select,this),this.build=f(this.build,this),this.bindingRegExp=f(this.bindingRegExp,this),this.els.jquery||this.els instanceof Array||(this.els=[this.els]),this.build()}return b.prototype.bindingRegExp=function(){var b;return b=a.config.prefix,b?new RegExp("^data-"+b+"-"):/^data-/},b.prototype.build=function(){var b,c,d,e,f,g,i,j,k,l,m,n=this;this.bindings=[],f=[],b=this.bindingRegExp(),e=function(c){var d,e,g,i,j,k,l,m,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I;if(h.call(f,c)<0){F=c.attributes;for(z=0,C=F.length;z<C;z++){d=F[z];if(b.test(d.name)){x=d.name.replace(b,"");if(!(g=a.binders[x])){G=a.binders;for(m in G)y=G[m],m!=="*"&&m.indexOf("*")!==-1&&(v=new RegExp("^"+m.replace("*",".+")+"$"),v.test(x)&&(g=y))}g||(g=a.binders["*"]);if(g.block){H=c.getElementsByTagName("*");for(A=0,D=H.length;A<D;A++)q=H[A],f.push(q);e=[d]}}}I=e||c.attributes;for(B=0,E=I.length;B<E;B++){d=I[B];if(b.test(d.name)){r={},x=d.name.replace(b,""),u=function(){var a,b,c,e;c=d.value.split("|"),e=[];for(a=0,b=c.length;a<b;a++)t=c[a],e.push(t.trim());return e}(),j=function(){var a,b,c,d;c=u.shift().split("<"),d=[];for(a=0,b=c.length;a<b;a++)k=c[a],d.push(k.trim());return d}(),s=j.shift(),w=s.split(/\.|:/),r.formatters=u,r.bypass=s.indexOf(":")!==-1,w[0]?p=n.models[w.shift()]:(p=n.models,w.shift()),o=w.join(".");if(p){if(l=j.shift())r.dependencies=l.split(/\s+/);i=new a.Binding(c,x,p,o,r),i.view=n,n.bindings.push(i)}}}e&&(e=null)}},l=this.els;for(g=0,j=l.length;g<j;g++){c=l[g],e(c),m=c.getElementsByTagName("*");for(i=0,k=m.length;i<k;i++)d=m[i],e(d)}},b.prototype.select=function(a){var b,c,d,e,f;e=this.bindings,f=[];for(c=0,d=e.length;c<d;c++)b=e[c],a(b)&&f.push(b);return f},b.prototype.bind=function(){var a,b,c,d,e;d=this.bindings,e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a.bind());return e},b.prototype.unbind=function(){var a,b,c,d,e;d=this.bindings,e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a.unbind());return e},b.prototype.sync=function(){var a,b,c,d,e;d=this.bindings,e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a.sync());return e},b.prototype.publish=function(){var a,b,c,d,e;d=this.select(function(a){return a.binder.publishes}),e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a.publish());return e},b}(),b=function(a,b,c,d){var e;return e=function(a){return c.call(d,a)},window.jQuery!=null?(a=jQuery(a),a.on!=null?a.on(b,e):a.bind(b,e)):window.addEventListener!=null?a.addEventListener(b,e,!1):(b="on"+b,a.attachEvent(b,e)),e},e=function(a,b,c){return window.jQuery!=null?(a=jQuery(a),a.off!=null?a.off(b,c):a.unbind(b,c)):window.removeEventListener?a.removeEventListener(b,c,!1):(b="on"+b,a.detachEvent(b,c))},c=function(a){var b,c,d,e;switch(a.type){case"checkbox":return a.checked;case"select-multiple":e=[];for(c=0,d=a.length;c<d;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(a){return b(a,"change",this.publish)},unbind:function(a){return e(a,"change",this.publish)},routine:function(a,b){return a.type==="radio"?a.checked=a.value===b:a.checked=!!b}},unchecked:{publishes:!0,bind:function(a){return b(a,"change",this.publish)},unbind:function(a){return e(a,"change",this.publish)},routine:function(a,b){return a.type==="radio"?a.checked=a.value!==b:a.checked=!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=b!=null?b:""},value:{publishes:!0,bind:function(a){return b(a,"change",this.publish)},unbind:function(a){return e(a,"change",this.publish)},routine:function(a,b){var c,d,e,f,g;if(a.type!=="select-multiple")return a.value=b!=null?b:"";if(b!=null){g=[];for(d=0,e=a.length;d<e;d++)c=a[d],g.push(c.selected=(f=c.value,h.call(b,f)>=0));return g}}},text:function(a,b){return a.innerText!=null?a.innerText=b!=null?b:"":a.textContent=b!=null?b:""},"on-*":{"function":!0,routine:function(a,c){return this.currentListener&&e(a,this.args[0],this.currentListener),this.currentListener=b(a,this.args[0],c,this.model)}},"each-*":{block:!0,bind:function(a,b){return a.removeAttribute(["data",d.config.prefix,this.type].join("-").replace("--","-"))},routine:function(a,b){var c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;if(this.iterated!=null){r=this.iterated;for(l=0,o=r.length;l<o;l++){k=r[l],k.unbind(),s=k.els;for(m=0,p=s.length;m<p;m++)e=s[m],e.parentNode.removeChild(e)}}else this.marker=document.createComment(" rivets: "+this.type+" "),a.parentNode.insertBefore(this.marker,a),a.parentNode.removeChild(a);this.iterated=[],v=[];for(n=0,q=b.length;n<q;n++){f=b[n],c={},t=this.view.models;for(i in t)h=t[i],c[i]=h;c[this.args[0]]=f,g=a.cloneNode(!0),j=this.iterated[this.iterated.length-1]||this.marker,this.marker.parentNode.insertBefore(g,(u=j.nextSibling)!=null?u:null),v.push(this.iterated.push(d.bind(g,c)))}return v}},"class-*":function(a,b){var c;c=" "+a.className+" ";if(!b==(c.indexOf(" "+this.args[0]+" ")!==-1))return a.className=b?""+a.className+" "+this.args[0]:c.replace(" "+this.args[0]+" "," ").trim()},"*":function(a,b){return b?a.setAttribute(this.type,b):a.removeAttribute(this.type)}},a.config={preloadData:!0},a.formatters={},d={binders:a.binders,formatters:a.formatters,config:a.config,configure:function(b){var c,d;b==null&&(b={});for(c in b)d=b[c],a.config[c]=d},bind:function(b,c){var d;return c==null&&(c={}),d=new a.View(b,c),d.bind(),d}},typeof module!="undefined"&&module!==null?module.exports=d:this.rivets=d}).call(this); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
5 | (function(){var e,t,n,r,i,s=function(e,t){return function(){return e.apply(t,arguments)}},o=[].slice,u=[].indexOf||function(e){for(var t=0,n=this.length;t<n;t++)if(t in this&&this[t]===e)return t;return-1};e={},String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),e.Binding=function(){function t(t,n,r,i,o){var u,a,f,l;this.el=t,this.type=n,this.model=r,this.keypath=i,this.options=o!=null?o:{},this.unbind=s(this.unbind,this),this.bind=s(this.bind,this),this.publish=s(this.publish,this),this.sync=s(this.sync,this),this.set=s(this.set,this),this.formattedValue=s(this.formattedValue,this);if(!(this.binder=e.binders[n])){l=e.binders;for(u in l)f=l[u],u!=="*"&&u.indexOf("*")!==-1&&(a=new RegExp("^"+u.replace("*",".+")+"$"),a.test(n)&&(this.binder=f,this.args=(new RegExp("^"+u.replace("*","(.+)")+"$")).exec(n),this.args.shift()))}this.binder||(this.binder=e.binders["*"]),this.binder instanceof Function&&(this.binder={routine:this.binder}),this.formatters=this.options.formatters||[]}return t.prototype.formattedValue=function(t){var n,r,i,s,u,a,f,l;a=this.formatters;for(s=0,u=a.length;s<u;s++)r=a[s],n=r.split(/\s+/),i=n.shift(),t=this.model[i]instanceof Function?(f=this.model)[i].apply(f,[t].concat(o.call(n))):e.formatters[i]?(l=e.formatters)[i].apply(l,[t].concat(o.call(n))):void 0;return t},t.prototype.set=function(e){var t;return e=e instanceof Function&&!this.binder["function"]?this.formattedValue(e.call(this.model)):this.formattedValue(e),(t=this.binder.routine)!=null?t.call(this,this.el,e):void 0},t.prototype.sync=function(){return this.set(this.options.bypass?this.model[this.keypath]:e.config.adapter.read(this.model,this.keypath))},t.prototype.publish=function(){return e.config.adapter.publish(this.model,this.keypath,n(this.el))},t.prototype.bind=function(){var t,n,r,i,s,o,u,a,f;(o=this.binder.bind)!=null&&o.call(this,this.el),this.options.bypass?this.sync():(e.config.adapter.subscribe(this.model,this.keypath,this.sync),e.config.preloadData&&this.sync());if((u=this.options.dependencies)!=null?u.length:void 0){a=this.options.dependencies,f=[];for(i=0,s=a.length;i<s;i++)t=a[i],/^\./.test(t)?(r=this.model,n=t.substr(1)):(t=t.split("."),r=this.view.models[t.shift()],n=t.join(".")),f.push(e.config.adapter.subscribe(r,n,this.sync));return f}},t.prototype.unbind=function(){var t,n,r,i,s,o,u;(i=this.binder.unbind)!=null&&i.call(this,this.el),this.options.bypass||e.config.adapter.unsubscribe(this.model,this.keypath,this.sync);if((s=this.options.dependencies)!=null?s.length:void 0){o=this.options.dependencies,u=[];for(n=0,r=o.length;n<r;n++)t=o[n],u.push(e.config.adapter.unsubscribe(this.model,t,this.sync));return u}},t}(),e.View=function(){function t(e,t){this.els=e,this.models=t,this.publish=s(this.publish,this),this.sync=s(this.sync,this),this.unbind=s(this.unbind,this),this.bind=s(this.bind,this),this.select=s(this.select,this),this.build=s(this.build,this),this.bindingRegExp=s(this.bindingRegExp,this),this.els.jquery||this.els instanceof Array||(this.els=[this.els]),this.build()}return t.prototype.bindingRegExp=function(){var t;return t=e.config.prefix,t?new RegExp("^data-"+t+"-"):/^data-/},t.prototype.build=function(){var t,n,r,i,s,o,a,f,l,c,h,p=this;this.bindings=[],s=[],t=this.bindingRegExp(),i=function(n){var r,i,o,a,f,l,c,h,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A,O,M,_,D,P;if(u.call(s,n)<0){M=n.attributes;for(N=0,L=M.length;N<L;N++){r=M[N];if(t.test(r.name)){x=r.name.replace(t,"");if(!(o=e.binders[x])){_=e.binders;for(h in _)T=_[h],h!=="*"&&h.indexOf("*")!==-1&&(E=new RegExp("^"+h.replace("*",".+")+"$"),E.test(x)&&(o=T))}o||(o=e.binders["*"]);if(o.block){D=n.getElementsByTagName("*");for(C=0,A=D.length;C<A;C++)m=D[C],s.push(m);i=[r]}}}P=i||n.attributes;for(k=0,O=P.length;k<O;k++){r=P[k];if(t.test(r.name)){g={},x=r.name.replace(t,""),w=function(){var e,t,n,i;n=r.value.split("|"),i=[];for(e=0,t=n.length;e<t;e++)b=n[e],i.push(b.trim());return i}(),f=function(){var e,t,n,r;n=w.shift().split("<"),r=[];for(e=0,t=n.length;e<t;e++)l=n[e],r.push(l.trim());return r}(),y=f.shift(),S=y.split(/\.|:/),g.formatters=w,g.bypass=y.indexOf(":")!==-1,S[0]?v=p.models[S.shift()]:(v=p.models,S.shift()),d=S.join(".");if(v){if(c=f.shift())g.dependencies=c.split(/\s+/);a=new e.Binding(n,x,v,d,g),a.view=p,p.bindings.push(a)}}}i&&(i=null)}},c=this.els;for(o=0,f=c.length;o<f;o++){n=c[o],i(n),h=n.getElementsByTagName("*");for(a=0,l=h.length;a<l;a++)r=h[a],i(r)}},t.prototype.select=function(e){var t,n,r,i,s;i=this.bindings,s=[];for(n=0,r=i.length;n<r;n++)t=i[n],e(t)&&s.push(t);return s},t.prototype.bind=function(){var e,t,n,r,i;r=this.bindings,i=[];for(t=0,n=r.length;t<n;t++)e=r[t],i.push(e.bind());return i},t.prototype.unbind=function(){var e,t,n,r,i;r=this.bindings,i=[];for(t=0,n=r.length;t<n;t++)e=r[t],i.push(e.unbind());return i},t.prototype.sync=function(){var e,t,n,r,i;r=this.bindings,i=[];for(t=0,n=r.length;t<n;t++)e=r[t],i.push(e.sync());return i},t.prototype.publish=function(){var e,t,n,r,i;r=this.select(function(e){return e.binder.publishes}),i=[];for(t=0,n=r.length;t<n;t++)e=r[t],i.push(e.publish());return i},t}(),t=function(e,t,n,r){var i;return i=function(e){return n.call(r,e)},window.jQuery!=null?(e=jQuery(e),e.on!=null?e.on(t,i):e.bind(t,i)):window.addEventListener!=null?e.addEventListener(t,i,!1):(t="on"+t,e.attachEvent(t,i)),i},i=function(e,t,n){return window.jQuery!=null?(e=jQuery(e),e.off!=null?e.off(t,n):e.unbind(t,n)):window.removeEventListener?e.removeEventListener(t,n,!1):(t="on"+t,e.detachEvent(t,n))},n=function(e){var t,n,r,i;switch(e.type){case"checkbox":return e.checked;case"select-multiple":i=[];for(n=0,r=e.length;n<r;n++)t=e[n],t.selected&&i.push(t.value);return i;default:return e.value}},e.binders={enabled:function(e,t){return e.disabled=!t},disabled:function(e,t){return e.disabled=!!t},checked:{publishes:!0,bind:function(e){return this.currentListener=t(e,"change",this.publish)},unbind:function(e){return i(e,"change",this.currentListener)},routine:function(e,t){return e.type==="radio"?e.checked=e.value===t:e.checked=!!t}},unchecked:{publishes:!0,bind:function(e){return this.currentListener=t(e,"change",this.publish)},unbind:function(e){return i(e,"change",this.currentListener)},routine:function(e,t){return e.type==="radio"?e.checked=e.value!==t:e.checked=!t}},show:function(e,t){return e.style.display=t?"":"none"},hide:function(e,t){return e.style.display=t?"none":""},html:function(e,t){return e.innerHTML=t!=null?t:""},value:{publishes:!0,bind:function(e){return this.currentListener=t(e,"change",this.publish)},unbind:function(e){return i(e,"change",this.currentListener)},routine:function(e,t){var n,r,i,s,o;if(e.type!=="select-multiple")return e.value=t!=null?t:"";if(t!=null){o=[];for(r=0,i=e.length;r<i;r++)n=e[r],o.push(n.selected=(s=n.value,u.call(t,s)>=0));return o}}},text:function(e,t){return e.innerText!=null?e.innerText=t!=null?t:"":e.textContent=t!=null?t:""},"on-*":{"function":!0,routine:function(e,n){return this.currentListener&&i(e,this.args[0],this.currentListener),this.currentListener=t(e,this.args[0],n,this.model)}},"each-*":{block:!0,bind:function(e,t){return e.removeAttribute(["data",r.config.prefix,this.type].join("-").replace("--","-"))},routine:function(e,t){var n,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E;if(this.iterated!=null){g=this.iterated;for(c=0,d=g.length;c<d;c++){l=g[c],l.unbind(),y=l.els;for(h=0,v=y.length;h<v;h++)i=y[h],i.parentNode.removeChild(i)}}else this.marker=document.createComment(" rivets: "+this.type+" "),e.parentNode.insertBefore(this.marker,e),e.parentNode.removeChild(e);this.iterated=[],E=[];for(p=0,m=t.length;p<m;p++){s=t[p],n={},b=this.view.models;for(a in b)u=b[a],n[a]=u;n[this.args[0]]=s,o=e.cloneNode(!0),f=this.iterated[this.iterated.length-1]||this.marker,this.marker.parentNode.insertBefore(o,(w=f.nextSibling)!=null?w:null),E.push(this.iterated.push(r.bind(o,n)))}return E}},"class-*":function(e,t){var n;n=" "+e.className+" ";if(!t==(n.indexOf(" "+this.args[0]+" ")!==-1))return e.className=t?""+e.className+" "+this.args[0]:n.replace(" "+this.args[0]+" "," ").trim()},"*":function(e,t){return t?e.setAttribute(this.type,t):e.removeAttribute(this.type)}},e.config={preloadData:!0},e.formatters={},r={binders:e.binders,formatters:e.formatters,config:e.config,configure:function(t){var n,r;t==null&&(t={});for(n in t)r=t[n],e.config[n]=r},bind:function(t,n){var r;return n==null&&(n={}),r=new e.View(t,n),r.bind(),r}},typeof module!="undefined"&&module!==null?module.exports=r:this.rivets=r}).call(this); | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | { | 1 | { |
2 | "name" : "rivets", | 2 | "name" : "rivets", |
3 | "description" : "Declarative data binding facility.", | 3 | "description" : "Declarative data binding facility.", |
4 | "version" : "0.4.0", | 4 | "version" : "0.4.1", |
5 | "author" : "Michael Richards", | 5 | "author" : "Michael Richards", |
6 | "url" : "http://rivetsjs.com", | 6 | "url" : "http://rivetsjs.com", |
7 | "main" : "./lib/rivets.js", | 7 | "main" : "./lib/rivets.js", | ... | ... |
-
Please register or sign in to post a comment