Build 0.4.9.
Showing
5 changed files
with
21 additions
and
16 deletions
... | @@ -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.8", | 5 | "version": "0.4.9", |
6 | "keywords": ["data binding", "templating"], | 6 | "keywords": ["data binding", "templating"], |
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.8 | 2 | // version: 0.4.9 |
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; | 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 | formatter = this.model[id] instanceof Function ? this.model[id] : Rivets.formatters[id]; | 70 | formatter = this.model[id] instanceof Function ? this.model[id] : ((_ref1 = this.options) != null ? (_ref2 = _ref1.bindingOptions) != null ? (_ref3 = _ref2.formatters) != null ? _ref3[id] : void 0 : void 0 : void 0) instanceof Function ? this.options.bindingOptions.formatters[id] : Rivets.formatters[id]; |
71 | if ((formatter != null ? formatter.read : void 0) instanceof Function) { | 71 | if ((formatter != null ? formatter.read : void 0) instanceof Function) { |
72 | value = formatter.read.apply(formatter, [value].concat(__slice.call(args))); | 72 | value = formatter.read.apply(formatter, [value].concat(__slice.call(args))); |
73 | } else if (formatter instanceof Function) { | 73 | } else if (formatter instanceof Function) { |
... | @@ -167,9 +167,10 @@ | ... | @@ -167,9 +167,10 @@ |
167 | 167 | ||
168 | Rivets.View = (function() { | 168 | Rivets.View = (function() { |
169 | 169 | ||
170 | function View(els, models) { | 170 | function View(els, models, options) { |
171 | this.els = els; | 171 | this.els = els; |
172 | this.models = models; | 172 | this.models = models; |
173 | this.options = options; | ||
173 | this.publish = __bind(this.publish, this); | 174 | this.publish = __bind(this.publish, this); |
174 | 175 | ||
175 | this.sync = __bind(this.sync, this); | 176 | this.sync = __bind(this.sync, this); |
... | @@ -242,6 +243,9 @@ | ... | @@ -242,6 +243,9 @@ |
242 | attribute = _ref3[_k]; | 243 | attribute = _ref3[_k]; |
243 | if (bindingRegExp.test(attribute.name)) { | 244 | if (bindingRegExp.test(attribute.name)) { |
244 | options = {}; | 245 | options = {}; |
246 | if ((_this.options != null) && typeof _this.options === 'object') { | ||
247 | options.bindingOptions = _this.options; | ||
248 | } | ||
245 | type = attribute.name.replace(bindingRegExp, ''); | 249 | type = attribute.name.replace(bindingRegExp, ''); |
246 | pipes = (function() { | 250 | pipes = (function() { |
247 | var _l, _len3, _ref4, _results; | 251 | var _l, _len3, _ref4, _results; |
... | @@ -533,7 +537,7 @@ | ... | @@ -533,7 +537,7 @@ |
533 | "each-*": { | 537 | "each-*": { |
534 | block: true, | 538 | block: true, |
535 | bind: function(el, collection) { | 539 | bind: function(el, collection) { |
536 | return el.removeAttribute(['data', rivets.config.prefix, this.type].join('-').replace('--', '-')); | 540 | return el.removeAttribute(['data', Rivets.config.prefix, this.type].join('-').replace('--', '-')); |
537 | }, | 541 | }, |
538 | routine: function(el, collection) { | 542 | routine: function(el, collection) { |
539 | var data, e, item, itemEl, m, n, previous, view, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _results; | 543 | var data, e, item, itemEl, m, n, previous, view, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _results; |
... | @@ -566,13 +570,11 @@ | ... | @@ -566,13 +570,11 @@ |
566 | } | 570 | } |
567 | data[this.args[0]] = item; | 571 | data[this.args[0]] = item; |
568 | itemEl = el.cloneNode(true); | 572 | itemEl = el.cloneNode(true); |
569 | if (this.iterated.length > 0) { | 573 | previous = this.iterated.length ? this.iterated[this.iterated.length - 1].els[0] : this.marker; |
570 | previous = this.iterated[this.iterated.length - 1].els[0]; | ||
571 | } else { | ||
572 | previous = this.marker; | ||
573 | } | ||
574 | this.marker.parentNode.insertBefore(itemEl, (_ref3 = previous.nextSibling) != null ? _ref3 : null); | 574 | this.marker.parentNode.insertBefore(itemEl, (_ref3 = previous.nextSibling) != null ? _ref3 : null); |
575 | _results.push(this.iterated.push(rivets.bind(itemEl, data))); | 575 | view = new Rivets.View(itemEl, data); |
576 | view.bind(); | ||
577 | _results.push(this.iterated.push(view)); | ||
576 | } | 578 | } |
577 | return _results; | 579 | return _results; |
578 | } | 580 | } |
... | @@ -614,12 +616,15 @@ | ... | @@ -614,12 +616,15 @@ |
614 | Rivets.config[property] = value; | 616 | Rivets.config[property] = value; |
615 | } | 617 | } |
616 | }; | 618 | }; |
617 | return exports.bind = function(el, models) { | 619 | return exports.bind = function(el, models, options) { |
618 | var view; | 620 | var view; |
619 | if (models == null) { | 621 | if (models == null) { |
620 | models = {}; | 622 | models = {}; |
621 | } | 623 | } |
622 | view = new Rivets.View(el, models); | 624 | if (options == null) { |
625 | options = {}; | ||
626 | } | ||
627 | view = new Rivets.View(el, models, options); | ||
623 | view.bind(); | 628 | view.bind(); |
624 | return view; | 629 | return view; |
625 | }; | 630 | }; | ... | ... |
This diff is collapsed.
Click to expand it.
1 | { | 1 | { |
2 | "name" : "rivets", | 2 | "name" : "rivets", |
3 | "description" : "Declarative data binding facility.", | 3 | "description" : "Declarative data binding facility.", |
4 | "version" : "0.4.8", | 4 | "version" : "0.4.9", |
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", | ... | ... |
-
Please register or sign in to post a comment