1e6b3edf by Michael Richards

Build 0.3.6.

1 parent 078497e0
1 // rivets.js 1 // rivets.js
2 // version: 0.3.5 2 // version: 0.3.6
3 // author: Michael Richards 3 // author: Michael Richards
4 // license: MIT 4 // license: MIT
5 (function() { 5 (function() {
...@@ -26,14 +26,18 @@ ...@@ -26,14 +26,18 @@
26 this.options = options != null ? options : {}; 26 this.options = options != null ? options : {};
27 this.unbind = __bind(this.unbind, this); 27 this.unbind = __bind(this.unbind, this);
28 28
29 this.bind = __bind(this.bind, this);
30
29 this.publish = __bind(this.publish, this); 31 this.publish = __bind(this.publish, this);
30 32
31 this.bind = __bind(this.bind, this); 33 this.sync = __bind(this.sync, this);
32 34
33 this.set = __bind(this.set, this); 35 this.set = __bind(this.set, this);
34 36
35 this.formattedValue = __bind(this.formattedValue, this); 37 this.formattedValue = __bind(this.formattedValue, this);
36 38
39 this.isBidirectional = __bind(this.isBidirectional, this);
40
37 this.routine = (function() { 41 this.routine = (function() {
38 switch (this.options.special) { 42 switch (this.options.special) {
39 case "event": 43 case "event":
...@@ -49,7 +53,10 @@ ...@@ -49,7 +53,10 @@
49 this.formatters = this.options.formatters || []; 53 this.formatters = this.options.formatters || [];
50 } 54 }
51 55
52 Binding.prototype.bidirectionals = ['value', 'checked', 'unchecked']; 56 Binding.prototype.isBidirectional = function() {
57 var _ref;
58 return (_ref = this.type) === 'value' || _ref === 'checked' || _ref === 'unchecked';
59 };
53 60
54 Binding.prototype.formattedValue = function(value) { 61 Binding.prototype.formattedValue = function(value) {
55 var args, formatter, id, _i, _len, _ref, _ref1, _ref2; 62 var args, formatter, id, _i, _len, _ref, _ref1, _ref2;
...@@ -75,52 +82,48 @@ ...@@ -75,52 +82,48 @@
75 } 82 }
76 }; 83 };
77 84
85 Binding.prototype.sync = function() {
86 return this.set(this.options.bypass ? this.model[this.keypath] : Rivets.config.adapter.read(this.model, this.keypath));
87 };
88
89 Binding.prototype.publish = function() {
90 return Rivets.config.adapter.publish(this.model, this.keypath, getInputValue(this.el));
91 };
92
78 Binding.prototype.bind = function() { 93 Binding.prototype.bind = function() {
79 var callback, keypath, _i, _len, _ref, _ref1, _ref2, 94 var keypath, _i, _len, _ref, _ref1;
80 _this = this;
81 if (this.options.bypass) { 95 if (this.options.bypass) {
82 this.set(this.model[this.keypath]); 96 this.sync();
83 } else { 97 } else {
84 Rivets.config.adapter.subscribe(this.model, this.keypath, this.set); 98 Rivets.config.adapter.subscribe(this.model, this.keypath, this.sync);
85 if (Rivets.config.preloadData) { 99 if (Rivets.config.preloadData) {
86 this.set(Rivets.config.adapter.read(this.model, this.keypath)); 100 this.sync();
87 } 101 }
88 } 102 }
89 if ((_ref = this.options.dependencies) != null ? _ref.length : void 0) { 103 if ((_ref = this.options.dependencies) != null ? _ref.length : void 0) {
90 this.dependencyCallbacks = {};
91 _ref1 = this.options.dependencies; 104 _ref1 = this.options.dependencies;
92 for (_i = 0, _len = _ref1.length; _i < _len; _i++) { 105 for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
93 keypath = _ref1[_i]; 106 keypath = _ref1[_i];
94 callback = this.dependencyCallbacks[keypath] = function(value) { 107 Rivets.config.adapter.subscribe(this.model, keypath, this.sync);
95 return _this.set(_this.options.bypass ? _this.model[_this.keypath] : Rivets.config.adapter.read(_this.model, _this.keypath));
96 };
97 Rivets.config.adapter.subscribe(this.model, keypath, callback);
98 } 108 }
99 } 109 }
100 if (_ref2 = this.type, __indexOf.call(this.bidirectionals, _ref2) >= 0) { 110 if (this.isBidirectional()) {
101 return bindEvent(this.el, 'change', this.publish); 111 return bindEvent(this.el, 'change', this.publish);
102 } 112 }
103 }; 113 };
104 114
105 Binding.prototype.publish = function(e) {
106 var el;
107 el = e.target || e.srcElement;
108 return Rivets.config.adapter.publish(this.model, this.keypath, getInputValue(el));
109 };
110
111 Binding.prototype.unbind = function() { 115 Binding.prototype.unbind = function() {
112 var callback, keypath, _i, _len, _ref, _ref1, _ref2; 116 var keypath, _i, _len, _ref, _ref1;
113 if (!this.options.bypass) { 117 if (!this.options.bypass) {
114 Rivets.config.adapter.unsubscribe(this.model, this.keypath, this.set); 118 Rivets.config.adapter.unsubscribe(this.model, this.keypath, this.sync);
115 if ((_ref = this.options.dependencies) != null ? _ref.length : void 0) { 119 if ((_ref = this.options.dependencies) != null ? _ref.length : void 0) {
116 _ref1 = this.options.dependencies; 120 _ref1 = this.options.dependencies;
117 for (_i = 0, _len = _ref1.length; _i < _len; _i++) { 121 for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
118 keypath = _ref1[_i]; 122 keypath = _ref1[_i];
119 callback = this.dependencyCallbacks[keypath]; 123 Rivets.config.adapter.unsubscribe(this.model, keypath, this.sync);
120 Rivets.config.adapter.unsubscribe(this.model, keypath, callback);
121 } 124 }
122 } 125 }
123 if (_ref2 = this.type, __indexOf.call(this.bidirectionals, _ref2) >= 0) { 126 if (this.isBidirectional()) {
124 return this.el.removeEventListener('change', this.publish); 127 return this.el.removeEventListener('change', this.publish);
125 } 128 }
126 } 129 }
...@@ -135,10 +138,16 @@ ...@@ -135,10 +138,16 @@
135 function View(els, models) { 138 function View(els, models) {
136 this.els = els; 139 this.els = els;
137 this.models = models; 140 this.models = models;
141 this.publish = __bind(this.publish, this);
142
143 this.sync = __bind(this.sync, this);
144
138 this.unbind = __bind(this.unbind, this); 145 this.unbind = __bind(this.unbind, this);
139 146
140 this.bind = __bind(this.bind, this); 147 this.bind = __bind(this.bind, this);
141 148
149 this.select = __bind(this.select, this);
150
142 this.build = __bind(this.build, this); 151 this.build = __bind(this.build, this);
143 152
144 this.bindingRegExp = __bind(this.bindingRegExp, this); 153 this.bindingRegExp = __bind(this.bindingRegExp, this);
...@@ -264,6 +273,19 @@ ...@@ -264,6 +273,19 @@
264 } 273 }
265 }; 274 };
266 275
276 View.prototype.select = function(fn) {
277 var binding, _i, _len, _ref, _results;
278 _ref = this.bindings;
279 _results = [];
280 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
281 binding = _ref[_i];
282 if (fn(binding)) {
283 _results.push(binding);
284 }
285 }
286 return _results;
287 };
288
267 View.prototype.bind = function() { 289 View.prototype.bind = function() {
268 var binding, _i, _len, _ref, _results; 290 var binding, _i, _len, _ref, _results;
269 _ref = this.bindings; 291 _ref = this.bindings;
...@@ -286,6 +308,30 @@ ...@@ -286,6 +308,30 @@
286 return _results; 308 return _results;
287 }; 309 };
288 310
311 View.prototype.sync = function() {
312 var binding, _i, _len, _ref, _results;
313 _ref = this.bindings;
314 _results = [];
315 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
316 binding = _ref[_i];
317 _results.push(binding.sync());
318 }
319 return _results;
320 };
321
322 View.prototype.publish = function() {
323 var binding, _i, _len, _ref, _results;
324 _ref = this.select(function(b) {
325 return b.isBidirectional();
326 });
327 _results = [];
328 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
329 binding = _ref[_i];
330 _results.push(binding.publish());
331 }
332 return _results;
333 };
334
289 return View; 335 return View;
290 336
291 })(); 337 })();
......
1 // rivets.js 1 // rivets.js
2 // version: 0.3.5 2 // version: 0.3.6
3 // author: Michael Richards 3 // author: Michael Richards
4 // license: MIT 4 // license: MIT
5 (function(){var a,b,c,d,e,f,g,h,i,j=function(a,b){return function(){return a.apply(b,arguments)}},k=[].slice,l=[].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 h(c,f,h,i,k){this.el=c,this.type=f,this.model=h,this.keypath=i,this.options=k!=null?k:{},this.unbind=j(this.unbind,this),this.publish=j(this.publish,this),this.bind=j(this.bind,this),this.set=j(this.set,this),this.formattedValue=j(this.formattedValue,this),this.routine=function(){switch(this.options.special){case"event":return e(this.type);case"class":return d(this.type);case"iteration":return g(this.type);default:return a.routines[this.type]||b(this.type)}}.call(this),this.formatters=this.options.formatters||[]}return h.prototype.bidirectionals=["value","checked","unchecked"],h.prototype.formattedValue=function(b){var c,d,e,f,g,h,i,j;h=this.formatters;for(f=0,g=h.length;f<g;f++)d=h[f],c=d.split(/\s+/),e=c.shift(),b=this.model[e]instanceof Function?(i=this.model)[e].apply(i,[b].concat(k.call(c))):a.formatters[e]?(j=a.formatters)[e].apply(j,[b].concat(k.call(c))):void 0;return b},h.prototype.set=function(a){return a=a instanceof Function&&this.options.special!=="event"?this.formattedValue(a.call(this.model)):this.formattedValue(a),this.options.special==="event"?(this.routine(this.el,a,this.currentListener),this.currentListener=a):this.options.special==="iteration"?this.routine(this.el,a,this):this.routine(this.el,a)},h.prototype.bind=function(){var b,d,e,f,g,h,i,j=this;this.options.bypass?this.set(this.model[this.keypath]):(a.config.adapter.subscribe(this.model,this.keypath,this.set),a.config.preloadData&&this.set(a.config.adapter.read(this.model,this.keypath)));if((g=this.options.dependencies)!=null?g.length:void 0){this.dependencyCallbacks={},h=this.options.dependencies;for(e=0,f=h.length;e<f;e++)d=h[e],b=this.dependencyCallbacks[d]=function(b){return j.set(j.options.bypass?j.model[j.keypath]:a.config.adapter.read(j.model,j.keypath))},a.config.adapter.subscribe(this.model,d,b)}if(i=this.type,l.call(this.bidirectionals,i)>=0)return c(this.el,"change",this.publish)},h.prototype.publish=function(b){var c;return c=b.target||b.srcElement,a.config.adapter.publish(this.model,this.keypath,f(c))},h.prototype.unbind=function(){var b,c,d,e,f,g,h;if(!this.options.bypass){a.config.adapter.unsubscribe(this.model,this.keypath,this.set);if((f=this.options.dependencies)!=null?f.length:void 0){g=this.options.dependencies;for(d=0,e=g.length;d<e;d++)c=g[d],b=this.dependencyCallbacks[c],a.config.adapter.unsubscribe(this.model,c,b)}if(h=this.type,l.call(this.bidirectionals,h)>=0)return this.el.removeEventListener("change",this.publish)}},h}(),a.View=function(){function b(a,b){this.els=a,this.models=b,this.unbind=j(this.unbind,this),this.bind=j(this.bind,this),this.build=j(this.build,this),this.bindingRegExp=j(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,h,i,j,k,m,n,o,p,q,r=this;this.bindings=[],j=[],g=null,b=this.bindingRegExp(),e=/^on-/,c=/^class-/,f=/^each-/,i=function(d){var h,i,k,m,n,o,p,q,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J;if(l.call(j,d)<0){H=d.attributes;for(z=0,D=H.length;z<D;z++){i=H[z];if(b.test(i.name)){y=i.name.replace(b,"");if(f.test(y)&&!r.models[y.replace(f,"")]){I=d.getElementsByTagName("*");for(A=0,E=I.length;A<E;A++)s=I[A],j.push(s);g=[i]}}}J=g||d.attributes;for(B=0,F=J.length;B<F;B++){i=J[B];if(b.test(i.name)){t={},y=i.name.replace(b,""),w=function(){var a,b,c,d;c=i.value.split("|"),d=[];for(a=0,b=c.length;a<b;a++)v=c[a],d.push(v.trim());return d}(),m=function(){var a,b,c,d;c=w.shift().split("<"),d=[];for(a=0,b=c.length;a<b;a++)n=c[a],d.push(n.trim());return d}(),u=m.shift(),x=u.split(/\.|:/),t.formatters=w,q=r.models[x.shift()],t.bypass=u.indexOf(":")!==-1,p=x.join();if(q){if(o=m.shift())t.dependencies=o.split(/\s+/);e.test(y)&&(y=y.replace(e,""),t.special="event"),c.test(y)&&(y=y.replace(c,""),t.special="class"),f.test(y)&&(y=y.replace(f,""),t.special="iteration"),k=new a.Binding(d,y,q,p,t),k.view=r,r.bindings.push(k)}}if(g){for(C=0,G=g.length;C<G;C++)h=g[C],d.removeAttribute(h.name);g=null}}}},p=this.els;for(k=0,n=p.length;k<n;k++){d=p[k],i(d),q=d.getElementsByTagName("*");for(m=0,o=q.length;m<o;m++)h=q[m],i(h)}},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}(),c=function(a,b,c){return window.jQuery!=null?(a=jQuery(a),a.on!=null?a.on(b,c):a.bind(b,c)):window.addEventListener!=null?a.addEventListener(b,c,!1):(b="on"+b,a.attachEvent(b,c))},i=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))},f=function(a){switch(a.type){case"checkbox":return a.checked;default:return a.value}},e=function(a){return function(b,d,e){d&&c(b,a,d);if(e)return i(b,a,e)}},d=function(a){return function(b,c){var d,e;d=" "+b.className+" ",e=d.indexOf(" "+a+" ")!==-1;if(!c===e)return b.className=c?""+b.className+" "+a:d.replace(" "+a+" "," ").trim()}},g=function(a){return function(b,c,d){var e,f,g,i,j,k,l,m,n,o,p,q,r,s;if(d.iterated!=null){q=d.iterated;for(m=0,o=q.length;m<o;m++)i=q[m],i.view.unbind(),i.el.parentNode.removeChild(i.el)}else d.marker=document.createComment(" rivets: each-"+a+" "),b.parentNode.insertBefore(d.marker,b),b.parentNode.removeChild(b);d.iterated=[],s=[];for(n=0,p=c.length;n<p;n++){f=c[n],e={},r=d.view.models;for(k in r)j=r[k],e[k]=j;e[a]=f,g=b.cloneNode(!0),l=d.iterated[d.iterated.length-1]||d.marker,d.marker.parentNode.insertBefore(g,l.nextSibling),s.push(d.iterated.push({el:g,view:h.bind(g,e)}))}return s}},b=function(a){return function(b,c){return c?b.setAttribute(a,c):b.removeAttribute(a)}},a.routines={enabled:function(a,b){return a.disabled=!b},disabled:function(a,b){return a.disabled=!!b},checked:function(a,b){return a.type==="radio"?a.checked=a.value===b:a.checked=!!b},unchecked: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:function(a,b){return a.value=b!=null?b:""},text:function(a,b){return a.innerText!=null?a.innerText=b!=null?b:"":a.textContent=b!=null?b:""}},a.config={preloadData:!0},a.formatters={},h={routines:a.routines,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=h:this.rivets=h}).call(this);
...\ No newline at end of file ...\ No newline at end of file
5 (function(){var a,b,c,d,e,f,g,h,i,j=function(a,b){return function(){return a.apply(b,arguments)}},k=[].slice,l=[].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 h(c,f,h,i,k){this.el=c,this.type=f,this.model=h,this.keypath=i,this.options=k!=null?k:{},this.unbind=j(this.unbind,this),this.bind=j(this.bind,this),this.publish=j(this.publish,this),this.sync=j(this.sync,this),this.set=j(this.set,this),this.formattedValue=j(this.formattedValue,this),this.isBidirectional=j(this.isBidirectional,this),this.routine=function(){switch(this.options.special){case"event":return e(this.type);case"class":return d(this.type);case"iteration":return g(this.type);default:return a.routines[this.type]||b(this.type)}}.call(this),this.formatters=this.options.formatters||[]}return h.prototype.isBidirectional=function(){var a;return(a=this.type)==="value"||a==="checked"||a==="unchecked"},h.prototype.formattedValue=function(b){var c,d,e,f,g,h,i,j;h=this.formatters;for(f=0,g=h.length;f<g;f++)d=h[f],c=d.split(/\s+/),e=c.shift(),b=this.model[e]instanceof Function?(i=this.model)[e].apply(i,[b].concat(k.call(c))):a.formatters[e]?(j=a.formatters)[e].apply(j,[b].concat(k.call(c))):void 0;return b},h.prototype.set=function(a){return a=a instanceof Function&&this.options.special!=="event"?this.formattedValue(a.call(this.model)):this.formattedValue(a),this.options.special==="event"?(this.routine(this.el,a,this.currentListener),this.currentListener=a):this.options.special==="iteration"?this.routine(this.el,a,this):this.routine(this.el,a)},h.prototype.sync=function(){return this.set(this.options.bypass?this.model[this.keypath]:a.config.adapter.read(this.model,this.keypath))},h.prototype.publish=function(){return a.config.adapter.publish(this.model,this.keypath,f(this.el))},h.prototype.bind=function(){var b,d,e,f,g;this.options.bypass?this.sync():(a.config.adapter.subscribe(this.model,this.keypath,this.sync),a.config.preloadData&&this.sync());if((f=this.options.dependencies)!=null?f.length:void 0){g=this.options.dependencies;for(d=0,e=g.length;d<e;d++)b=g[d],a.config.adapter.subscribe(this.model,b,this.sync)}if(this.isBidirectional())return c(this.el,"change",this.publish)},h.prototype.unbind=function(){var b,c,d,e,f;if(!this.options.bypass){a.config.adapter.unsubscribe(this.model,this.keypath,this.sync);if((e=this.options.dependencies)!=null?e.length:void 0){f=this.options.dependencies;for(c=0,d=f.length;c<d;c++)b=f[c],a.config.adapter.unsubscribe(this.model,b,this.sync)}if(this.isBidirectional())return this.el.removeEventListener("change",this.publish)}},h}(),a.View=function(){function b(a,b){this.els=a,this.models=b,this.publish=j(this.publish,this),this.sync=j(this.sync,this),this.unbind=j(this.unbind,this),this.bind=j(this.bind,this),this.select=j(this.select,this),this.build=j(this.build,this),this.bindingRegExp=j(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,h,i,j,k,m,n,o,p,q,r=this;this.bindings=[],j=[],g=null,b=this.bindingRegExp(),e=/^on-/,c=/^class-/,f=/^each-/,i=function(d){var h,i,k,m,n,o,p,q,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J;if(l.call(j,d)<0){H=d.attributes;for(z=0,D=H.length;z<D;z++){i=H[z];if(b.test(i.name)){y=i.name.replace(b,"");if(f.test(y)&&!r.models[y.replace(f,"")]){I=d.getElementsByTagName("*");for(A=0,E=I.length;A<E;A++)s=I[A],j.push(s);g=[i]}}}J=g||d.attributes;for(B=0,F=J.length;B<F;B++){i=J[B];if(b.test(i.name)){t={},y=i.name.replace(b,""),w=function(){var a,b,c,d;c=i.value.split("|"),d=[];for(a=0,b=c.length;a<b;a++)v=c[a],d.push(v.trim());return d}(),m=function(){var a,b,c,d;c=w.shift().split("<"),d=[];for(a=0,b=c.length;a<b;a++)n=c[a],d.push(n.trim());return d}(),u=m.shift(),x=u.split(/\.|:/),t.formatters=w,q=r.models[x.shift()],t.bypass=u.indexOf(":")!==-1,p=x.join();if(q){if(o=m.shift())t.dependencies=o.split(/\s+/);e.test(y)&&(y=y.replace(e,""),t.special="event"),c.test(y)&&(y=y.replace(c,""),t.special="class"),f.test(y)&&(y=y.replace(f,""),t.special="iteration"),k=new a.Binding(d,y,q,p,t),k.view=r,r.bindings.push(k)}}if(g){for(C=0,G=g.length;C<G;C++)h=g[C],d.removeAttribute(h.name);g=null}}}},p=this.els;for(k=0,n=p.length;k<n;k++){d=p[k],i(d),q=d.getElementsByTagName("*");for(m=0,o=q.length;m<o;m++)h=q[m],i(h)}},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.isBidirectional()}),e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a.publish());return e},b}(),c=function(a,b,c){return window.jQuery!=null?(a=jQuery(a),a.on!=null?a.on(b,c):a.bind(b,c)):window.addEventListener!=null?a.addEventListener(b,c,!1):(b="on"+b,a.attachEvent(b,c))},i=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))},f=function(a){switch(a.type){case"checkbox":return a.checked;default:return a.value}},e=function(a){return function(b,d,e){d&&c(b,a,d);if(e)return i(b,a,e)}},d=function(a){return function(b,c){var d,e;d=" "+b.className+" ",e=d.indexOf(" "+a+" ")!==-1;if(!c===e)return b.className=c?""+b.className+" "+a:d.replace(" "+a+" "," ").trim()}},g=function(a){return function(b,c,d){var e,f,g,i,j,k,l,m,n,o,p,q,r,s;if(d.iterated!=null){q=d.iterated;for(m=0,o=q.length;m<o;m++)i=q[m],i.view.unbind(),i.el.parentNode.removeChild(i.el)}else d.marker=document.createComment(" rivets: each-"+a+" "),b.parentNode.insertBefore(d.marker,b),b.parentNode.removeChild(b);d.iterated=[],s=[];for(n=0,p=c.length;n<p;n++){f=c[n],e={},r=d.view.models;for(k in r)j=r[k],e[k]=j;e[a]=f,g=b.cloneNode(!0),l=d.iterated[d.iterated.length-1]||d.marker,d.marker.parentNode.insertBefore(g,l.nextSibling),s.push(d.iterated.push({el:g,view:h.bind(g,e)}))}return s}},b=function(a){return function(b,c){return c?b.setAttribute(a,c):b.removeAttribute(a)}},a.routines={enabled:function(a,b){return a.disabled=!b},disabled:function(a,b){return a.disabled=!!b},checked:function(a,b){return a.type==="radio"?a.checked=a.value===b:a.checked=!!b},unchecked: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:function(a,b){return a.value=b!=null?b:""},text:function(a,b){return a.innerText!=null?a.innerText=b!=null?b:"":a.textContent=b!=null?b:""}},a.config={preloadData:!0},a.formatters={},h={routines:a.routines,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=h:this.rivets=h}).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.3.5", 4 "version" : "0.3.6",
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",
......
1 # rivets.js 1 # rivets.js
2 # version : 0.3.5 2 # version : 0.3.6
3 # author : Michael Richards 3 # author : Michael Richards
4 # license : MIT 4 # license : MIT
5 5
......