abeca6f2 by Michael Richards

Build 0.4.3.

1 parent ad0df3fb
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 "name": "rivets", 2 "name": "rivets",
3 "repo": "mikeric/rivets", 3 "repo": "mikeric/rivets",
4 "description": "Declarative data binding facility.", 4 "description": "Declarative data binding facility.",
5 "version": "0.4.2", 5 "version": "0.4.3",
6 "keywords": ["data binding", "template"], 6 "keywords": ["data binding", "template"],
7 "scripts": ["lib/rivets.js"], 7 "scripts": ["lib/rivets.js"],
8 "main": "lib/rivets.js", 8 "main": "lib/rivets.js",
......
1 // rivets.js 1 // rivets.js
2 // version: 0.4.2 2 // version: 0.4.3
3 // author: Michael Richards 3 // author: Michael Richards
4 // license: MIT 4 // license: MIT
5 (function() { 5 (function() {
...@@ -61,13 +61,18 @@ ...@@ -61,13 +61,18 @@
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, _ref3; 64 var args, formatter, id, _i, _len, _ref;
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] ? 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; 70 formatter = this.model[id] instanceof Function ? this.model[id] : Rivets.formatters[id];
71 if ((formatter != null ? formatter.read : void 0) instanceof Function) {
72 value = formatter.read.apply(formatter, [value].concat(__slice.call(args)));
73 } else if (formatter instanceof Function) {
74 value = formatter.apply(null, [value].concat(__slice.call(args)));
75 }
71 } 76 }
72 return value; 77 return value;
73 }; 78 };
...@@ -83,23 +88,18 @@ ...@@ -83,23 +88,18 @@
83 }; 88 };
84 89
85 Binding.prototype.publish = function() { 90 Binding.prototype.publish = function() {
86 var args, formatter, i, id, value, _ref; 91 var args, formatter, id, value, _i, _len, _ref, _ref1, _ref2;
87 value = getInputValue(this.el); 92 value = getInputValue(this.el);
88 if (this.formatters) { 93 _ref = this.formatters.slice(0).reverse();
89 i = this.formatters.length - 1; 94 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
90 while (i > -1) { 95 formatter = _ref[_i];
91 formatter = this.formatters[i]; 96 args = formatter.split(/\s+/);
92 args = formatter.split(/\s+/); 97 id = args.shift();
93 id = args.shift(); 98 if ((_ref1 = Rivets.formatters[id]) != null ? _ref1.publish : void 0) {
94 if (Rivets.formatters[id] && Rivets.formatters[id].publish) { 99 value = (_ref2 = Rivets.formatters[id]).publish.apply(_ref2, [value].concat(__slice.call(args)));
95 value = (_ref = Rivets.formatters[id]).publish.apply(_ref, [value].concat(__slice.call(args)));
96 }
97 i--;
98 } 100 }
99 } 101 }
100 if (value) { 102 return Rivets.config.adapter.publish(this.model, this.keypath, value);
101 return Rivets.config.adapter.publish(this.model, this.keypath, value);
102 }
103 }; 103 };
104 104
105 Binding.prototype.bind = function() { 105 Binding.prototype.bind = function() {
...@@ -193,12 +193,12 @@ ...@@ -193,12 +193,12 @@
193 }; 193 };
194 194
195 View.prototype.build = function() { 195 View.prototype.build = function() {
196 var bindingRegExp, el, node, parseNode, skipNodes, _i, _j, _len, _len1, _ref, _ref1, 196 var bindingRegExp, el, node, parse, skipNodes, _i, _j, _len, _len1, _ref, _ref1,
197 _this = this; 197 _this = this;
198 this.bindings = []; 198 this.bindings = [];
199 skipNodes = []; 199 skipNodes = [];
200 bindingRegExp = this.bindingRegExp(); 200 bindingRegExp = this.bindingRegExp();
201 parseNode = function(node) { 201 parse = function(node) {
202 var attribute, attributes, binder, binding, context, ctx, dependencies, identifier, keypath, model, n, options, path, pipe, pipes, regexp, splitPath, type, value, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3; 202 var attribute, attributes, binder, binding, context, ctx, dependencies, identifier, keypath, model, n, options, path, pipe, pipes, regexp, splitPath, type, value, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3;
203 if (__indexOf.call(skipNodes, node) < 0) { 203 if (__indexOf.call(skipNodes, node) < 0) {
204 _ref = node.attributes; 204 _ref = node.attributes;
...@@ -284,11 +284,13 @@ ...@@ -284,11 +284,13 @@
284 _ref = this.els; 284 _ref = this.els;
285 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 285 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
286 el = _ref[_i]; 286 el = _ref[_i];
287 parseNode(el); 287 parse(el);
288 _ref1 = el.getElementsByTagName('*'); 288 _ref1 = el.getElementsByTagName('*');
289 for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { 289 for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
290 node = _ref1[_j]; 290 node = _ref1[_j];
291 parseNode(node); 291 if (node.attributes != null) {
292 parse(node);
293 }
292 } 294 }
293 } 295 }
294 }; 296 };
......
1 { 1 {
2 "name" : "rivets", 2 "name" : "rivets",
3 "description" : "Declarative data binding facility.", 3 "description" : "Declarative data binding facility.",
4 "version" : "0.4.2", 4 "version" : "0.4.3",
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.2 2 # version : 0.4.3
3 # author : Michael Richards 3 # author : Michael Richards
4 # license : MIT 4 # license : MIT
5 5
......