924b7ba1 by Michael Richards

Build 0.4.2 and include a component.json for better package manager support.

1 parent e0ecf8db
1 {
2 "name": "rivets",
3 "repo": "mikeric/rivets",
4 "description": "Declarative data binding facility.",
5 "version": "0.4.2",
6 "keywords": ["data binding", "template"],
7 "scripts": ["lib/rivets.js"],
8 "main": "lib/rivets.js",
9 "license": "MIT"
10 }
1 // rivets.js 1 // rivets.js
2 // version: 0.4.1 2 // version: 0.4.2
3 // author: Michael Richards 3 // author: Michael Richards
4 // license: MIT 4 // license: MIT
5 (function() { 5 (function() {
...@@ -61,13 +61,13 @@ ...@@ -61,13 +61,13 @@
61 } 61 }
62 62
63 Binding.prototype.formattedValue = function(value) { 63 Binding.prototype.formattedValue = function(value) {
64 var args, formatter, id, _i, _len, _ref, _ref1, _ref2; 64 var args, formatter, id, _i, _len, _ref, _ref1, _ref2, _ref3;
65 _ref = this.formatters; 65 _ref = this.formatters;
66 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 66 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
67 formatter = _ref[_i]; 67 formatter = _ref[_i];
68 args = formatter.split(/\s+/); 68 args = formatter.split(/\s+/);
69 id = args.shift(); 69 id = args.shift();
70 value = this.model[id] instanceof Function ? (_ref1 = this.model)[id].apply(_ref1, [value].concat(__slice.call(args))) : Rivets.formatters[id] ? (_ref2 = Rivets.formatters)[id].apply(_ref2, [value].concat(__slice.call(args))) : void 0; 70 value = this.model[id] instanceof Function ? (_ref1 = this.model)[id].apply(_ref1, [value].concat(__slice.call(args))) : Rivets.formatters[id] ? Rivets.formatters[id].read instanceof Function ? (_ref2 = Rivets.formatters[id]).read.apply(_ref2, [value].concat(__slice.call(args))) : Rivets.formatters[id] instanceof Function ? (_ref3 = Rivets.formatters)[id].apply(_ref3, [value].concat(__slice.call(args))) : value : value;
71 } 71 }
72 return value; 72 return value;
73 }; 73 };
...@@ -83,7 +83,23 @@ ...@@ -83,7 +83,23 @@
83 }; 83 };
84 84
85 Binding.prototype.publish = function() { 85 Binding.prototype.publish = function() {
86 return Rivets.config.adapter.publish(this.model, this.keypath, getInputValue(this.el)); 86 var args, formatter, i, id, value, _ref;
87 value = getInputValue(this.el);
88 if (this.formatters) {
89 i = this.formatters.length - 1;
90 while (i > -1) {
91 formatter = this.formatters[i];
92 args = formatter.split(/\s+/);
93 id = args.shift();
94 if (Rivets.formatters[id] && Rivets.formatters[id].publish) {
95 value = (_ref = Rivets.formatters[id]).publish.apply(_ref, [value].concat(__slice.call(args)));
96 }
97 i--;
98 }
99 }
100 if (value) {
101 return Rivets.config.adapter.publish(this.model, this.keypath, value);
102 }
87 }; 103 };
88 104
89 Binding.prototype.bind = function() { 105 Binding.prototype.bind = function() {
......
1 { 1 {
2 "name" : "rivets", 2 "name" : "rivets",
3 "description" : "Declarative data binding facility.", 3 "description" : "Declarative data binding facility.",
4 "version" : "0.4.1", 4 "version" : "0.4.2",
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.4.1 2 # version : 0.4.2
3 # author : Michael Richards 3 # author : Michael Richards
4 # license : MIT 4 # license : MIT
5 5
......