Build 0.5.1.
Showing
5 changed files
with
28 additions
and
28 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.0", | 5 | "version": "0.5.1", |
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.0 | 2 | // version: 0.5.1 |
3 | // author: Michael Richards | 3 | // author: Michael Richards |
4 | // license: MIT | 4 | // license: MIT |
5 | (function() { | 5 | (function() { |
6 | var Rivets, bindEvent, factory, getInputValue, unbindEvent, | 6 | var Rivets, |
7 | __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, | 7 | __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, |
8 | __slice = [].slice, | 8 | __slice = [].slice, |
9 | __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | 9 | __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; |
... | @@ -58,14 +58,14 @@ | ... | @@ -58,14 +58,14 @@ |
58 | } | 58 | } |
59 | 59 | ||
60 | Binding.prototype.formattedValue = function(value) { | 60 | Binding.prototype.formattedValue = function(value) { |
61 | var args, formatter, id, _i, _len, _ref, _ref1, _ref2, _ref3; | 61 | var args, formatter, id, _i, _len, _ref; |
62 | 62 | ||
63 | _ref = this.formatters; | 63 | _ref = this.formatters; |
64 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { | 64 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { |
65 | formatter = _ref[_i]; | 65 | formatter = _ref[_i]; |
66 | args = formatter.split(/\s+/); | 66 | args = formatter.split(/\s+/); |
67 | id = args.shift(); | 67 | id = args.shift(); |
68 | 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] : this.view.formatters[id]; | 68 | formatter = this.model[id] instanceof Function ? this.model[id] : this.view.formatters[id]; |
69 | if ((formatter != null ? formatter.read : void 0) instanceof Function) { | 69 | if ((formatter != null ? formatter.read : void 0) instanceof Function) { |
70 | value = formatter.read.apply(formatter, [value].concat(__slice.call(args))); | 70 | value = formatter.read.apply(formatter, [value].concat(__slice.call(args))); |
71 | } else if (formatter instanceof Function) { | 71 | } else if (formatter instanceof Function) { |
... | @@ -89,7 +89,7 @@ | ... | @@ -89,7 +89,7 @@ |
89 | Binding.prototype.publish = function() { | 89 | Binding.prototype.publish = function() { |
90 | var args, formatter, id, value, _i, _len, _ref, _ref1, _ref2; | 90 | var args, formatter, id, value, _i, _len, _ref, _ref1, _ref2; |
91 | 91 | ||
92 | value = getInputValue(this.el); | 92 | value = Rivets.Util.getInputValue(this.el); |
93 | _ref = this.formatters.slice(0).reverse(); | 93 | _ref = this.formatters.slice(0).reverse(); |
94 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { | 94 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { |
95 | formatter = _ref[_i]; | 95 | formatter = _ref[_i]; |
... | @@ -424,7 +424,8 @@ | ... | @@ -424,7 +424,8 @@ |
424 | 424 | ||
425 | })(); | 425 | })(); |
426 | 426 | ||
427 | bindEvent = function(el, event, handler, context) { | 427 | Rivets.Util = { |
428 | bindEvent: function(el, event, handler, context) { | ||
428 | var fn; | 429 | var fn; |
429 | 430 | ||
430 | fn = function(e) { | 431 | fn = function(e) { |
... | @@ -444,9 +445,8 @@ | ... | @@ -444,9 +445,8 @@ |
444 | el.attachEvent(event, fn); | 445 | el.attachEvent(event, fn); |
445 | } | 446 | } |
446 | return fn; | 447 | return fn; |
447 | }; | 448 | }, |
448 | 449 | unbindEvent: function(el, event, fn) { | |
449 | unbindEvent = function(el, event, fn) { | ||
450 | if (window.jQuery != null) { | 450 | if (window.jQuery != null) { |
451 | el = jQuery(el); | 451 | el = jQuery(el); |
452 | if (el.off != null) { | 452 | if (el.off != null) { |
... | @@ -460,9 +460,8 @@ | ... | @@ -460,9 +460,8 @@ |
460 | event = 'on' + event; | 460 | event = 'on' + event; |
461 | return el.detachEvent(event, fn); | 461 | return el.detachEvent(event, fn); |
462 | } | 462 | } |
463 | }; | 463 | }, |
464 | 464 | getInputValue: function(el) { | |
465 | getInputValue = function(el) { | ||
466 | var o, _i, _len, _results; | 465 | var o, _i, _len, _results; |
467 | 466 | ||
468 | if (window.jQuery != null) { | 467 | if (window.jQuery != null) { |
... | @@ -491,6 +490,7 @@ | ... | @@ -491,6 +490,7 @@ |
491 | return el.value; | 490 | return el.value; |
492 | } | 491 | } |
493 | } | 492 | } |
493 | } | ||
494 | }; | 494 | }; |
495 | 495 | ||
496 | Rivets.binders = { | 496 | Rivets.binders = { |
... | @@ -503,10 +503,10 @@ | ... | @@ -503,10 +503,10 @@ |
503 | checked: { | 503 | checked: { |
504 | publishes: true, | 504 | publishes: true, |
505 | bind: function(el) { | 505 | bind: function(el) { |
506 | return this.currentListener = bindEvent(el, 'change', this.publish); | 506 | return this.currentListener = Rivets.Util.bindEvent(el, 'change', this.publish); |
507 | }, | 507 | }, |
508 | unbind: function(el) { | 508 | unbind: function(el) { |
509 | return unbindEvent(el, 'change', this.currentListener); | 509 | return Rivets.Util.unbindEvent(el, 'change', this.currentListener); |
510 | }, | 510 | }, |
511 | routine: function(el, value) { | 511 | routine: function(el, value) { |
512 | var _ref; | 512 | var _ref; |
... | @@ -521,10 +521,10 @@ | ... | @@ -521,10 +521,10 @@ |
521 | unchecked: { | 521 | unchecked: { |
522 | publishes: true, | 522 | publishes: true, |
523 | bind: function(el) { | 523 | bind: function(el) { |
524 | return this.currentListener = bindEvent(el, 'change', this.publish); | 524 | return this.currentListener = Rivets.Util.bindEvent(el, 'change', this.publish); |
525 | }, | 525 | }, |
526 | unbind: function(el) { | 526 | unbind: function(el) { |
527 | return unbindEvent(el, 'change', this.currentListener); | 527 | return Rivets.Util.unbindEvent(el, 'change', this.currentListener); |
528 | }, | 528 | }, |
529 | routine: function(el, value) { | 529 | routine: function(el, value) { |
530 | var _ref; | 530 | var _ref; |
... | @@ -548,10 +548,10 @@ | ... | @@ -548,10 +548,10 @@ |
548 | value: { | 548 | value: { |
549 | publishes: true, | 549 | publishes: true, |
550 | bind: function(el) { | 550 | bind: function(el) { |
551 | return this.currentListener = bindEvent(el, 'change', this.publish); | 551 | return this.currentListener = Rivets.Util.bindEvent(el, 'change', this.publish); |
552 | }, | 552 | }, |
553 | unbind: function(el) { | 553 | unbind: function(el) { |
554 | return unbindEvent(el, 'change', this.currentListener); | 554 | return Rivets.Util.unbindEvent(el, 'change', this.currentListener); |
555 | }, | 555 | }, |
556 | routine: function(el, value) { | 556 | routine: function(el, value) { |
557 | var o, _i, _len, _ref, _ref1, _ref2, _results; | 557 | var o, _i, _len, _ref, _ref1, _ref2, _results; |
... | @@ -588,9 +588,9 @@ | ... | @@ -588,9 +588,9 @@ |
588 | "function": true, | 588 | "function": true, |
589 | routine: function(el, value) { | 589 | routine: function(el, value) { |
590 | if (this.currentListener) { | 590 | if (this.currentListener) { |
591 | unbindEvent(el, this.args[0], this.currentListener); | 591 | Rivets.Util.unbindEvent(el, this.args[0], this.currentListener); |
592 | } | 592 | } |
593 | return this.currentListener = bindEvent(el, this.args[0], value, this.model); | 593 | return this.currentListener = Rivets.Util.bindEvent(el, this.args[0], value, this.model); |
594 | } | 594 | } |
595 | }, | 595 | }, |
596 | "each-*": { | 596 | "each-*": { |
... | @@ -676,7 +676,7 @@ | ... | @@ -676,7 +676,7 @@ |
676 | 676 | ||
677 | Rivets.formatters = {}; | 677 | Rivets.formatters = {}; |
678 | 678 | ||
679 | factory = function(exports) { | 679 | Rivets.factory = function(exports) { |
680 | exports.binders = Rivets.binders; | 680 | exports.binders = Rivets.binders; |
681 | exports.formatters = Rivets.formatters; | 681 | exports.formatters = Rivets.formatters; |
682 | exports.config = Rivets.config; | 682 | exports.config = Rivets.config; |
... | @@ -707,14 +707,14 @@ | ... | @@ -707,14 +707,14 @@ |
707 | }; | 707 | }; |
708 | 708 | ||
709 | if (typeof exports === 'object') { | 709 | if (typeof exports === 'object') { |
710 | factory(exports); | 710 | Rivets.factory(exports); |
711 | } else if (typeof define === 'function' && define.amd) { | 711 | } else if (typeof define === 'function' && define.amd) { |
712 | define(['exports'], function(exports) { | 712 | define(['exports'], function(exports) { |
713 | factory(this.rivets = exports); | 713 | Rivets.factory(this.rivets = exports); |
714 | return exports; | 714 | return exports; |
715 | }); | 715 | }); |
716 | } else { | 716 | } else { |
717 | factory(this.rivets = {}); | 717 | Rivets.factory(this.rivets = {}); |
718 | } | 718 | } |
719 | 719 | ||
720 | }).call(this); | 720 | }).call(this); | ... | ... |
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.0", | 4 | "version": "0.5.1", |
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