924b7ba1 by Michael Richards

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

1 parent e0ecf8db
{
"name": "rivets",
"repo": "mikeric/rivets",
"description": "Declarative data binding facility.",
"version": "0.4.2",
"keywords": ["data binding", "template"],
"scripts": ["lib/rivets.js"],
"main": "lib/rivets.js",
"license": "MIT"
}
// rivets.js
// version: 0.4.1
// version: 0.4.2
// author: Michael Richards
// license: MIT
(function() {
......@@ -61,13 +61,13 @@
}
Binding.prototype.formattedValue = function(value) {
var args, formatter, id, _i, _len, _ref, _ref1, _ref2;
var args, formatter, id, _i, _len, _ref, _ref1, _ref2, _ref3;
_ref = this.formatters;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
formatter = _ref[_i];
args = formatter.split(/\s+/);
id = args.shift();
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;
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;
}
return value;
};
......@@ -83,7 +83,23 @@
};
Binding.prototype.publish = function() {
return Rivets.config.adapter.publish(this.model, this.keypath, getInputValue(this.el));
var args, formatter, i, id, value, _ref;
value = getInputValue(this.el);
if (this.formatters) {
i = this.formatters.length - 1;
while (i > -1) {
formatter = this.formatters[i];
args = formatter.split(/\s+/);
id = args.shift();
if (Rivets.formatters[id] && Rivets.formatters[id].publish) {
value = (_ref = Rivets.formatters[id]).publish.apply(_ref, [value].concat(__slice.call(args)));
}
i--;
}
}
if (value) {
return Rivets.config.adapter.publish(this.model, this.keypath, value);
}
};
Binding.prototype.bind = function() {
......
{
"name" : "rivets",
"description" : "Declarative data binding facility.",
"version" : "0.4.1",
"version" : "0.4.2",
"author" : "Michael Richards",
"url" : "http://rivetsjs.com",
"main" : "./lib/rivets.js",
......
# rivets.js
# version : 0.4.1
# version : 0.4.2
# author : Michael Richards
# license : MIT
......