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
713507c2
authored
2012-07-07 20:16:15 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Compile changes from #12 and #15.
1 parent
1fda314c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
11 deletions
lib/rivets.js
lib/rivets.js
View file @
713507c
...
...
@@ -14,6 +14,10 @@
this
.
model
=
model
;
this
.
keypath
=
keypath
;
this
.
formatters
=
formatters
!=
null
?
formatters
:
[];
this
.
unbind
=
__bind
(
this
.
unbind
,
this
);
this
.
publish
=
__bind
(
this
.
publish
,
this
);
this
.
bind
=
__bind
(
this
.
bind
,
this
);
this
.
set
=
__bind
(
this
.
set
,
this
);
...
...
@@ -32,20 +36,27 @@
};
Binding
.
prototype
.
bind
=
function
()
{
var
_ref
,
_this
=
this
;
Rivets
.
config
.
adapter
.
subscribe
(
this
.
model
,
this
.
keypath
,
function
(
value
)
{
return
_this
.
set
(
value
);
});
var
_ref
;
Rivets
.
config
.
adapter
.
subscribe
(
this
.
model
,
this
.
keypath
,
this
.
set
);
if
(
Rivets
.
config
.
preloadData
)
{
this
.
set
(
Rivets
.
config
.
adapter
.
read
(
this
.
model
,
this
.
keypath
));
}
if
(
_ref
=
this
.
type
,
__indexOf
.
call
(
bidirectionals
,
_ref
)
>=
0
)
{
return
this
.
el
.
addEventListener
(
'change'
,
function
(
e
)
{
return
this
.
el
.
addEventListener
(
'change'
,
this
.
publish
);
}
};
Binding
.
prototype
.
publish
=
function
(
e
)
{
var
el
;
el
=
e
.
target
||
e
.
srcElement
;
return
Rivets
.
config
.
adapter
.
publish
(
_this
.
model
,
_this
.
keypath
,
getInputValue
(
el
));
});
return
Rivets
.
config
.
adapter
.
publish
(
this
.
model
,
this
.
keypath
,
getInputValue
(
el
));
};
Binding
.
prototype
.
unbind
=
function
()
{
var
_ref
;
Rivets
.
config
.
adapter
.
unsubscribe
(
this
.
model
,
this
.
keypath
,
this
.
set
);
if
(
_ref
=
this
.
type
,
__indexOf
.
call
(
bidirectionals
,
_ref
)
>=
0
)
{
return
this
.
el
.
removeEventListener
(
'change'
,
this
.
publish
);
}
};
...
...
@@ -78,8 +89,9 @@
};
View
.
prototype
.
build
=
function
()
{
var
attribute
,
keypath
,
model
,
node
,
path
,
pipes
,
type
,
_i
,
_len
,
_ref
,
_results
;
var
attribute
,
bindingRegExp
,
keypath
,
model
,
node
,
path
,
pipes
,
type
,
_i
,
_len
,
_ref
,
_results
;
this
.
bindings
=
[];
bindingRegExp
=
this
.
bindingRegExp
();
_ref
=
this
.
el
.
getElementsByTagName
(
'*'
);
_results
=
[];
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
...
...
@@ -90,8 +102,8 @@
_results1
=
[];
for
(
_j
=
0
,
_len1
=
_ref1
.
length
;
_j
<
_len1
;
_j
++
)
{
attribute
=
_ref1
[
_j
];
if
(
this
.
bindingRegExp
()
.
test
(
attribute
.
name
))
{
type
=
attribute
.
name
.
replace
(
this
.
bindingRegExp
()
,
''
);
if
(
bindingRegExp
.
test
(
attribute
.
name
))
{
type
=
attribute
.
name
.
replace
(
bindingRegExp
,
''
);
pipes
=
attribute
.
value
.
split
(
'|'
).
map
(
function
(
pipe
)
{
return
pipe
.
trim
();
});
...
...
Please
register
or
sign in
to post a comment