More dieting; another 205 bytes.
Showing
1 changed file
with
7 additions
and
8 deletions
... | @@ -17,17 +17,16 @@ class Rivets.Binding | ... | @@ -17,17 +17,16 @@ class Rivets.Binding |
17 | constructor: (@el, @type, @model, @keypath, options) -> | 17 | constructor: (@el, @type, @model, @keypath, options) -> |
18 | @options = (options ||= {}) | 18 | @options = (options ||= {}) |
19 | unless binder = Rivets.binders[type] | 19 | unless binder = Rivets.binders[type] |
20 | binder = Rivets.binders['*'] | ||
20 | for identifier, value of Rivets.binders | 21 | for identifier, value of Rivets.binders |
21 | if identifier isnt '*' and identifier.indexOf('*') isnt -1 | 22 | if identifier isnt '*' and identifier.indexOf('*') isnt -1 |
22 | regexp = new RegExp "^#{identifier.replace('*', '.+')}$" | 23 | regexp = new RegExp "^#{identifier.replace('*', '(.+)')}$" |
23 | if regexp.test type | 24 | if regexp.test type |
24 | binder = value | 25 | binder = value |
25 | args = new RegExp("^#{identifier.replace('*', '(.+)')}$").exec type | 26 | args = regexp.exec type |
26 | args.shift() | 27 | args.shift() |
27 | @args = args | 28 | @args = args |
28 | 29 | ||
29 | binder or= Rivets.binders['*'] | ||
30 | |||
31 | if binder instanceof Function | 30 | if binder instanceof Function |
32 | binder = {routine: binder} | 31 | binder = {routine: binder} |
33 | 32 | ||
... | @@ -259,19 +258,19 @@ class Rivets.View | ... | @@ -259,19 +258,19 @@ class Rivets.View |
259 | 258 | ||
260 | # Binds all of the current bindings for this view. | 259 | # Binds all of the current bindings for this view. |
261 | bind: => | 260 | bind: => |
262 | binding.bind() for binding in @bindings | 261 | @bindings.map (binding) -> binding.bind() |
263 | 262 | ||
264 | # Unbinds all of the current bindings for this view. | 263 | # Unbinds all of the current bindings for this view. |
265 | unbind: => | 264 | unbind: => |
266 | binding.unbind() for binding in @bindings | 265 | @bindings.map (binding) -> binding.unbind() |
267 | 266 | ||
268 | # Syncs up the view with the model by running the routines on all bindings. | 267 | # Syncs up the view with the model by running the routines on all bindings. |
269 | sync: => | 268 | sync: => |
270 | binding.sync() for binding in @bindings | 269 | @bindings.map (binding) -> binding.sync() |
271 | 270 | ||
272 | # Publishes the input values from the view back to the model (reverse sync). | 271 | # Publishes the input values from the view back to the model (reverse sync). |
273 | publish: => | 272 | publish: => |
274 | binding.publish() for binding in @select (b) -> b.binder.publishes | 273 | (@select (b) -> b.binder.publishes).map (binding) -> binding.publish() |
275 | 274 | ||
276 | # Cross-browser event binding. | 275 | # Cross-browser event binding. |
277 | bindEvent = (el, event, handler, context, bindContext) -> | 276 | bindEvent = (el, event, handler, context, bindContext) -> | ... | ... |
-
Please register or sign in to post a comment