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
dc4abbc4
authored
2012-05-05 18:25:50 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
s/interface/adapter (interface is a reserved keyword in coffeescript 1.3.1).
1 parent
b1b0aa9a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
14 deletions
lib/rivets.js
src/rivets.coffee
lib/rivets.js
View file @
dc4abbc
// Generated by CoffeeScript 1.3.1
(
function
()
{
window
.
rivets
=
(
function
()
{
var
attr
,
bindableAttributes
,
bindings
,
getInputValue
,
registerBinding
,
setAttribute
,
_fn
,
_i
,
_len
;
registerBinding
=
function
(
el
,
interface
,
type
,
context
,
keypath
)
{
registerBinding
=
function
(
el
,
adapter
,
type
,
context
,
keypath
)
{
var
inputValue
;
bindings
[
type
](
el
,
interface
.
read
(
context
,
keypath
));
interface
.
subscribe
(
context
,
keypath
,
function
(
value
)
{
bindings
[
type
](
el
,
adapter
.
read
(
context
,
keypath
));
adapter
.
subscribe
(
context
,
keypath
,
function
(
value
)
{
return
bindings
[
type
](
el
,
value
);
});
if
(
inputValue
=
getInputValue
(
el
))
{
return
interface
.
publish
(
context
,
keypath
,
inputValue
);
return
adapter
.
publish
(
context
,
keypath
,
inputValue
);
}
};
setAttribute
=
function
(
el
,
attr
,
value
,
mirrored
)
{
if
(
mirrored
==
null
)
mirrored
=
false
;
if
(
mirrored
==
null
)
{
mirrored
=
false
;
}
if
(
value
)
{
return
$
(
el
).
attr
(
attr
,
mirrored
?
attr
:
value
);
}
else
{
...
...
@@ -81,8 +85,10 @@
_fn
(
attr
);
}
return
{
bind
:
function
(
el
,
interface
,
contexts
)
{
if
(
contexts
==
null
)
contexts
=
{};
bind
:
function
(
el
,
adapter
,
contexts
)
{
if
(
contexts
==
null
)
{
contexts
=
{};
}
return
$
(
el
).
add
(
$
(
'*'
,
el
)).
each
(
function
()
{
var
nodeMap
,
target
,
_j
,
_ref
,
_results
;
target
=
this
;
...
...
@@ -101,7 +107,7 @@
path
=
node
.
value
.
split
(
'.'
);
context
=
path
.
shift
();
keypath
=
path
.
join
(
'.'
);
return
registerBinding
(
$
(
target
),
interface
,
type
,
contexts
[
context
],
keypath
);
return
registerBinding
(
$
(
target
),
adapter
,
type
,
contexts
[
context
],
keypath
);
}
}
});
...
...
@@ -110,3 +116,5 @@
}
};
})();
}).
call
(
this
);
...
...
src/rivets.coffee
View file @
dc4abbc
...
...
@@ -4,14 +4,14 @@
# license : MIT
window
.
rivets
=
do
->
registerBinding
=
(
el
,
interface
,
type
,
context
,
keypath
)
->
bindings
[
type
]
el
,
interface
.
read
(
context
,
keypath
)
registerBinding
=
(
el
,
adapter
,
type
,
context
,
keypath
)
->
bindings
[
type
]
el
,
adapter
.
read
(
context
,
keypath
)
interface
.
subscribe
context
,
keypath
,
(
value
)
->
adapter
.
subscribe
context
,
keypath
,
(
value
)
->
bindings
[
type
]
el
,
value
if
inputValue
=
getInputValue
el
interface
.
publish
context
,
keypath
,
inputValue
adapter
.
publish
context
,
keypath
,
inputValue
setAttribute
=
(
el
,
attr
,
value
,
mirrored
=
false
)
->
if
value
...
...
@@ -53,7 +53,7 @@ window.rivets = do ->
bindings
[
attr
]
=
(
el
,
value
)
->
setAttribute
el
,
attr
,
value
bind
:
(
el
,
interface
,
contexts
=
{})
->
bind
:
(
el
,
adapter
,
contexts
=
{})
->
$
(
el
).
add
(
$
(
'*'
,
el
)).
each
->
target
=
this
nodeMap
=
target
.
attributes
...
...
@@ -69,4 +69,4 @@ window.rivets = do ->
path
=
node
.
value
.
split
'.'
context
=
path
.
shift
()
keypath
=
path
.
join
'.'
registerBinding
$
(
target
),
interface
,
type
,
contexts
[
context
],
keypath
registerBinding
$
(
target
),
adapter
,
type
,
contexts
[
context
],
keypath
...
...
Please
register
or
sign in
to post a comment