Build 0.5.6.
Showing
5 changed files
with
61 additions
and
4 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.5.5", | 5 | "version": "0.5.6", |
6 | "keywords": ["data binding", "templating"], | 6 | "keywords": ["data binding", "templating"], |
7 | "scripts": ["dist/rivets.js"], | 7 | "scripts": ["dist/rivets.js"], |
8 | "main": "dist/rivets.js", | 8 | "main": "dist/rivets.js", | ... | ... |
1 | // Rivets.js | 1 | // Rivets.js |
2 | // version: 0.5.5 | 2 | // version: 0.5.6 |
3 | // author: Michael Richards | 3 | // author: Michael Richards |
4 | // license: MIT | 4 | // license: MIT |
5 | (function() { | 5 | (function() { |
... | @@ -588,6 +588,63 @@ | ... | @@ -588,6 +588,63 @@ |
588 | return el.textContent = value != null ? value : ''; | 588 | return el.textContent = value != null ? value : ''; |
589 | } | 589 | } |
590 | }, | 590 | }, |
591 | "if": { | ||
592 | block: true, | ||
593 | bind: function(el) { | ||
594 | var attr, declaration; | ||
595 | |||
596 | if (this.marker == null) { | ||
597 | attr = ['data', this.view.config.prefix, this.type].join('-').replace('--', '-'); | ||
598 | declaration = el.getAttribute(attr); | ||
599 | this.marker = document.createComment(" rivets: " + this.type + " " + declaration + " "); | ||
600 | el.removeAttribute(attr); | ||
601 | el.parentNode.insertBefore(this.marker, el); | ||
602 | return el.parentNode.removeChild(el); | ||
603 | } | ||
604 | }, | ||
605 | unbind: function() { | ||
606 | var _ref; | ||
607 | |||
608 | return (_ref = this.nested) != null ? _ref.unbind() : void 0; | ||
609 | }, | ||
610 | routine: function(el, value) { | ||
611 | var key, model, models, options, _ref; | ||
612 | |||
613 | if (value === (this.nested == null)) { | ||
614 | if (value) { | ||
615 | models = {}; | ||
616 | _ref = this.view.models; | ||
617 | for (key in _ref) { | ||
618 | model = _ref[key]; | ||
619 | models[key] = model; | ||
620 | } | ||
621 | options = { | ||
622 | binders: this.view.options.binders, | ||
623 | formatters: this.view.options.formatters, | ||
624 | config: this.view.options.config | ||
625 | }; | ||
626 | (this.nested = new Rivets.View(el, models, options)).bind(); | ||
627 | return this.marker.parentNode.insertBefore(el, this.marker.nextSibling); | ||
628 | } else { | ||
629 | el.parentNode.removeChild(el); | ||
630 | this.nested.unbind(); | ||
631 | return delete this.nested; | ||
632 | } | ||
633 | } | ||
634 | } | ||
635 | }, | ||
636 | unless: { | ||
637 | block: true, | ||
638 | bind: function(el) { | ||
639 | return rivets.binders["if"].bind.call(this, el); | ||
640 | }, | ||
641 | unbind: function() { | ||
642 | return rivets.binders["if"].unbind.call(this); | ||
643 | }, | ||
644 | routine: function(el, value) { | ||
645 | return rivets.binders["if"].routine.call(this, el, !value); | ||
646 | } | ||
647 | }, | ||
591 | "on-*": { | 648 | "on-*": { |
592 | "function": true, | 649 | "function": true, |
593 | unbind: function(el) { | 650 | unbind: function(el) { | ... | ... |
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.5.5", | 4 | "version": "0.5.6", |
5 | "author": "Michael Richards", | 5 | "author": "Michael Richards", |
6 | "url": "http://rivetsjs.com", | 6 | "url": "http://rivetsjs.com", |
7 | "main": "./dist/rivets.js", | 7 | "main": "./dist/rivets.js", | ... | ... |
-
Please register or sign in to post a comment