Build 0.3.5.
Showing
4 changed files
with
20 additions
and
9 deletions
1 | // rivets.js | 1 | // rivets.js |
2 | // version: 0.3.4 | 2 | // version: 0.3.5 |
3 | // author: Michael Richards | 3 | // author: Michael Richards |
4 | // license: MIT | 4 | // license: MIT |
5 | (function() { | 5 | (function() { |
... | @@ -64,16 +64,13 @@ | ... | @@ -64,16 +64,13 @@ |
64 | }; | 64 | }; |
65 | 65 | ||
66 | Binding.prototype.set = function(value) { | 66 | Binding.prototype.set = function(value) { |
67 | value = this.formattedValue(value); | 67 | value = value instanceof Function && this.options.special !== "event" ? this.formattedValue(value.call(this.model)) : this.formattedValue(value); |
68 | if (this.options.special === "event") { | 68 | if (this.options.special === "event") { |
69 | this.routine(this.el, value, this.currentListener); | 69 | this.routine(this.el, value, this.currentListener); |
70 | return this.currentListener = value; | 70 | return this.currentListener = value; |
71 | } else if (this.options.special === "iteration") { | 71 | } else if (this.options.special === "iteration") { |
72 | return this.routine(this.el, value, this); | 72 | return this.routine(this.el, value, this); |
73 | } else { | 73 | } else { |
74 | if (value instanceof Function) { | ||
75 | value = value.call(this.model); | ||
76 | } | ||
77 | return this.routine(this.el, value); | 74 | return this.routine(this.el, value); |
78 | } | 75 | } |
79 | }; | 76 | }; |
... | @@ -294,7 +291,14 @@ | ... | @@ -294,7 +291,14 @@ |
294 | })(); | 291 | })(); |
295 | 292 | ||
296 | bindEvent = function(el, event, fn) { | 293 | bindEvent = function(el, event, fn) { |
297 | if (window.addEventListener) { | 294 | if (window.jQuery != null) { |
295 | el = jQuery(el); | ||
296 | if (el.on != null) { | ||
297 | return el.on(event, fn); | ||
298 | } else { | ||
299 | return el.bind(event, fn); | ||
300 | } | ||
301 | } else if (window.addEventListener != null) { | ||
298 | return el.addEventListener(event, fn, false); | 302 | return el.addEventListener(event, fn, false); |
299 | } else { | 303 | } else { |
300 | event = "on" + event; | 304 | event = "on" + event; |
... | @@ -303,7 +307,14 @@ | ... | @@ -303,7 +307,14 @@ |
303 | }; | 307 | }; |
304 | 308 | ||
305 | unbindEvent = function(el, event, fn) { | 309 | unbindEvent = function(el, event, fn) { |
306 | if (window.removeEventListener) { | 310 | if (window.jQuery != null) { |
311 | el = jQuery(el); | ||
312 | if (el.off != null) { | ||
313 | return el.off(event, fn); | ||
314 | } else { | ||
315 | return el.unbind(event, fn); | ||
316 | } | ||
317 | } else if (window.removeEventListener) { | ||
307 | return el.removeEventListener(event, fn, false); | 318 | return el.removeEventListener(event, fn, false); |
308 | } else { | 319 | } else { |
309 | event = "on" + event; | 320 | event = "on" + event; | ... | ... |
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.3.4", | 4 | "version" : "0.3.5", |
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