713507c2 by Michael Richards

Compile changes from #12 and #15.

1 parent 1fda314c
......@@ -14,6 +14,10 @@
this.model = model;
this.keypath = keypath;
this.formatters = formatters != null ? formatters : [];
this.unbind = __bind(this.unbind, this);
this.publish = __bind(this.publish, this);
this.bind = __bind(this.bind, this);
this.set = __bind(this.set, this);
......@@ -32,20 +36,27 @@
};
Binding.prototype.bind = function() {
var _ref,
_this = this;
Rivets.config.adapter.subscribe(this.model, this.keypath, function(value) {
return _this.set(value);
});
var _ref;
Rivets.config.adapter.subscribe(this.model, this.keypath, this.set);
if (Rivets.config.preloadData) {
this.set(Rivets.config.adapter.read(this.model, this.keypath));
}
if (_ref = this.type, __indexOf.call(bidirectionals, _ref) >= 0) {
return this.el.addEventListener('change', function(e) {
return this.el.addEventListener('change', this.publish);
}
};
Binding.prototype.publish = function(e) {
var el;
el = e.target || e.srcElement;
return Rivets.config.adapter.publish(_this.model, _this.keypath, getInputValue(el));
});
return Rivets.config.adapter.publish(this.model, this.keypath, getInputValue(el));
};
Binding.prototype.unbind = function() {
var _ref;
Rivets.config.adapter.unsubscribe(this.model, this.keypath, this.set);
if (_ref = this.type, __indexOf.call(bidirectionals, _ref) >= 0) {
return this.el.removeEventListener('change', this.publish);
}
};
......@@ -78,8 +89,9 @@
};
View.prototype.build = function() {
var attribute, keypath, model, node, path, pipes, type, _i, _len, _ref, _results;
var attribute, bindingRegExp, keypath, model, node, path, pipes, type, _i, _len, _ref, _results;
this.bindings = [];
bindingRegExp = this.bindingRegExp();
_ref = this.el.getElementsByTagName('*');
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
......@@ -90,8 +102,8 @@
_results1 = [];
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
attribute = _ref1[_j];
if (this.bindingRegExp().test(attribute.name)) {
type = attribute.name.replace(this.bindingRegExp(), '');
if (bindingRegExp.test(attribute.name)) {
type = attribute.name.replace(bindingRegExp, '');
pipes = attribute.value.split('|').map(function(pipe) {
return pipe.trim();
});
......