Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
rivets
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
6683d668
authored
2013-03-26 18:05:28 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
More dieting; another 205 bytes.
1 parent
2ade95c4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
8 deletions
src/rivets.coffee
src/rivets.coffee
View file @
6683d66
...
...
@@ -17,17 +17,16 @@ class Rivets.Binding
constructor
:
(
@
el
,
@
type
,
@
model
,
@
keypath
,
options
)
->
@
options
=
(
options
||=
{})
unless
binder
=
Rivets
.
binders
[
type
]
binder
=
Rivets
.
binders
[
'*'
]
for
identifier
,
value
of
Rivets
.
binders
if
identifier
isnt
'*'
and
identifier
.
indexOf
(
'*'
)
isnt
-
1
regexp
=
new
RegExp
"^
#{
identifier
.
replace
(
'*'
,
'
.+
'
)
}
$"
regexp
=
new
RegExp
"^
#{
identifier
.
replace
(
'*'
,
'
(.+)
'
)
}
$"
if
regexp
.
test
type
binder
=
value
args
=
new
RegExp
(
"^
#{
identifier
.
replace
(
'*'
,
'(.+)'
)
}
$"
)
.
exec
type
args
=
regexp
.
exec
type
args
.
shift
()
@
args
=
args
binder
or=
Rivets
.
binders
[
'*'
]
if
binder
instanceof
Function
binder
=
{
routine
:
binder
}
...
...
@@ -259,19 +258,19 @@ class Rivets.View
# Binds all of the current bindings for this view.
bind
:
=>
binding
.
bind
()
for
binding
in
@
bindings
@
bindings
.
map
(
binding
)
->
binding
.
bind
()
# Unbinds all of the current bindings for this view.
unbind
:
=>
binding
.
unbind
()
for
binding
in
@
bindings
@
bindings
.
map
(
binding
)
->
binding
.
unbind
()
# Syncs up the view with the model by running the routines on all bindings.
sync
:
=>
binding
.
sync
()
for
binding
in
@
bindings
@
bindings
.
map
(
binding
)
->
binding
.
sync
()
# Publishes the input values from the view back to the model (reverse sync).
publish
:
=>
binding
.
publish
()
for
binding
in
@
select
(
b
)
->
b
.
binder
.
publishes
(
@
select
(
b
)
->
b
.
binder
.
publishes
).
map
(
binding
)
->
binding
.
publish
()
# Cross-browser event binding.
bindEvent
=
(
el
,
event
,
handler
,
context
,
bindContext
)
->
...
...
Please
register
or
sign in
to post a comment