Build 0.3.1.
Showing
4 changed files
with
18 additions
and
13 deletions
1 | // rivets.js | 1 | // rivets.js |
2 | // version: 0.3.0 | 2 | // version: 0.3.1 |
3 | // author: Michael Richards | 3 | // author: Michael Richards |
4 | // license: MIT | 4 | // license: MIT |
5 | (function() { | 5 | (function() { |
... | @@ -51,7 +51,7 @@ | ... | @@ -51,7 +51,7 @@ |
51 | formatter = _ref[_i]; | 51 | formatter = _ref[_i]; |
52 | args = formatter.split(/\s+/); | 52 | args = formatter.split(/\s+/); |
53 | id = args.shift(); | 53 | id = args.shift(); |
54 | value = this.model[id] instanceof Function ? (_ref1 = this.model)[id].apply(_ref1, [value].concat(__slice.call(args))) : Rivets.config.formatters[id] ? (_ref2 = Rivets.config.formatters)[id].apply(_ref2, [value].concat(__slice.call(args))) : void 0; | 54 | value = this.model[id] instanceof Function ? (_ref1 = this.model)[id].apply(_ref1, [value].concat(__slice.call(args))) : Rivets.formatters[id] ? (_ref2 = Rivets.formatters)[id].apply(_ref2, [value].concat(__slice.call(args))) : void 0; |
55 | } | 55 | } |
56 | return value; | 56 | return value; |
57 | }; | 57 | }; |
... | @@ -158,7 +158,7 @@ | ... | @@ -158,7 +158,7 @@ |
158 | bindingRegExp = this.bindingRegExp(); | 158 | bindingRegExp = this.bindingRegExp(); |
159 | eventRegExp = /^on-/; | 159 | eventRegExp = /^on-/; |
160 | parseNode = function(node) { | 160 | parseNode = function(node) { |
161 | var attribute, context, ctx, dependencies, keypath, model, options, path, pipe, pipes, type, _i, _len, _ref, _results; | 161 | var attribute, context, ctx, dependencies, keypath, model, options, path, pipe, pipes, splitPath, type, _i, _len, _ref, _results; |
162 | _ref = node.attributes; | 162 | _ref = node.attributes; |
163 | _results = []; | 163 | _results = []; |
164 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { | 164 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { |
... | @@ -186,11 +186,12 @@ | ... | @@ -186,11 +186,12 @@ |
186 | } | 186 | } |
187 | return _results1; | 187 | return _results1; |
188 | })(); | 188 | })(); |
189 | path = context.shift().split(/(\.|:)/); | 189 | path = context.shift(); |
190 | splitPath = path.split(/\.|:/); | ||
190 | options.formatters = pipes; | 191 | options.formatters = pipes; |
191 | model = _this.models[path.shift()]; | 192 | model = _this.models[splitPath.shift()]; |
192 | options.bypass = path.shift() === ':'; | 193 | options.bypass = path.indexOf(":") !== -1; |
193 | keypath = path.join(); | 194 | keypath = splitPath.join(); |
194 | if (dependencies = context.shift()) { | 195 | if (dependencies = context.shift()) { |
195 | options.dependencies = dependencies.split(/\s+/); | 196 | options.dependencies = dependencies.split(/\s+/); |
196 | } | 197 | } |
... | @@ -252,16 +253,18 @@ | ... | @@ -252,16 +253,18 @@ |
252 | 253 | ||
253 | bindEvent = function(el, event, fn) { | 254 | bindEvent = function(el, event, fn) { |
254 | if (window.addEventListener) { | 255 | if (window.addEventListener) { |
255 | return el.addEventListener(event, fn); | 256 | return el.addEventListener(event, fn, false); |
256 | } else { | 257 | } else { |
258 | event = "on" + event; | ||
257 | return el.attachEvent(event, fn); | 259 | return el.attachEvent(event, fn); |
258 | } | 260 | } |
259 | }; | 261 | }; |
260 | 262 | ||
261 | unbindEvent = function(el, event, fn) { | 263 | unbindEvent = function(el, event, fn) { |
262 | if (window.removeEventListener) { | 264 | if (window.removeEventListener) { |
263 | return el.removeEventListener(event, fn); | 265 | return el.removeEventListener(event, fn, false); |
264 | } else { | 266 | } else { |
267 | event = "on" + event; | ||
265 | return el.detachEvent(event, fn); | 268 | return el.detachEvent(event, fn); |
266 | } | 269 | } |
267 | }; | 270 | }; |
... | @@ -339,12 +342,14 @@ | ... | @@ -339,12 +342,14 @@ |
339 | }; | 342 | }; |
340 | 343 | ||
341 | Rivets.config = { | 344 | Rivets.config = { |
342 | preloadData: true, | 345 | preloadData: true |
343 | formatters: {} | ||
344 | }; | 346 | }; |
345 | 347 | ||
348 | Rivets.formatters = {}; | ||
349 | |||
346 | rivets = { | 350 | rivets = { |
347 | routines: Rivets.routines, | 351 | routines: Rivets.routines, |
352 | formatters: Rivets.formatters, | ||
348 | config: Rivets.config, | 353 | config: Rivets.config, |
349 | configure: function(options) { | 354 | configure: function(options) { |
350 | var property, value, _results; | 355 | var property, value, _results; | ... | ... |
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.0", | 4 | "version" : "0.3.1", |
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