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
abeca6f2
authored
2012-11-17 12:49:32 -0800
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Build 0.4.3.
1 parent
ad0df3fb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
24 deletions
component.json
lib/rivets.js
lib/rivets.min.js
package.json
src/rivets.coffee
component.json
View file @
abeca6f
...
...
@@ -2,7 +2,7 @@
"name"
:
"rivets"
,
"repo"
:
"mikeric/rivets"
,
"description"
:
"Declarative data binding facility."
,
"version"
:
"0.4.
2
"
,
"version"
:
"0.4.
3
"
,
"keywords"
:
[
"data binding"
,
"template"
],
"scripts"
:
[
"lib/rivets.js"
],
"main"
:
"lib/rivets.js"
,
...
...
lib/rivets.js
View file @
abeca6f
// rivets.js
// version: 0.4.
2
// version: 0.4.
3
// author: Michael Richards
// license: MIT
(
function
()
{
...
...
@@ -61,13 +61,18 @@
}
Binding
.
prototype
.
formattedValue
=
function
(
value
)
{
var
args
,
formatter
,
id
,
_i
,
_len
,
_ref
,
_ref1
,
_ref2
,
_ref3
;
var
args
,
formatter
,
id
,
_i
,
_len
,
_ref
;
_ref
=
this
.
formatters
;
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
formatter
=
_ref
[
_i
];
args
=
formatter
.
split
(
/
\s
+/
);
id
=
args
.
shift
();
value
=
this
.
model
[
id
]
instanceof
Function
?
(
_ref1
=
this
.
model
)[
id
].
apply
(
_ref1
,
[
value
].
concat
(
__slice
.
call
(
args
)))
:
Rivets
.
formatters
[
id
]
?
Rivets
.
formatters
[
id
].
read
instanceof
Function
?
(
_ref2
=
Rivets
.
formatters
[
id
]).
read
.
apply
(
_ref2
,
[
value
].
concat
(
__slice
.
call
(
args
)))
:
Rivets
.
formatters
[
id
]
instanceof
Function
?
(
_ref3
=
Rivets
.
formatters
)[
id
].
apply
(
_ref3
,
[
value
].
concat
(
__slice
.
call
(
args
)))
:
value
:
value
;
formatter
=
this
.
model
[
id
]
instanceof
Function
?
this
.
model
[
id
]
:
Rivets
.
formatters
[
id
];
if
((
formatter
!=
null
?
formatter
.
read
:
void
0
)
instanceof
Function
)
{
value
=
formatter
.
read
.
apply
(
formatter
,
[
value
].
concat
(
__slice
.
call
(
args
)));
}
else
if
(
formatter
instanceof
Function
)
{
value
=
formatter
.
apply
(
null
,
[
value
].
concat
(
__slice
.
call
(
args
)));
}
}
return
value
;
};
...
...
@@ -83,23 +88,18 @@
};
Binding
.
prototype
.
publish
=
function
()
{
var
args
,
formatter
,
i
,
id
,
value
,
_ref
;
var
args
,
formatter
,
i
d
,
value
,
_i
,
_len
,
_ref
,
_ref1
,
_ref2
;
value
=
getInputValue
(
this
.
el
);
if
(
this
.
formatters
)
{
i
=
this
.
formatters
.
length
-
1
;
while
(
i
>
-
1
)
{
formatter
=
this
.
formatters
[
i
];
args
=
formatter
.
split
(
/
\s
+/
);
id
=
args
.
shift
();
if
(
Rivets
.
formatters
[
id
]
&&
Rivets
.
formatters
[
id
].
publish
)
{
value
=
(
_ref
=
Rivets
.
formatters
[
id
]).
publish
.
apply
(
_ref
,
[
value
].
concat
(
__slice
.
call
(
args
)));
}
i
--
;
_ref
=
this
.
formatters
.
slice
(
0
).
reverse
();
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
formatter
=
_ref
[
_i
];
args
=
formatter
.
split
(
/
\s
+/
);
id
=
args
.
shift
();
if
((
_ref1
=
Rivets
.
formatters
[
id
])
!=
null
?
_ref1
.
publish
:
void
0
)
{
value
=
(
_ref2
=
Rivets
.
formatters
[
id
]).
publish
.
apply
(
_ref2
,
[
value
].
concat
(
__slice
.
call
(
args
)));
}
}
if
(
value
)
{
return
Rivets
.
config
.
adapter
.
publish
(
this
.
model
,
this
.
keypath
,
value
);
}
return
Rivets
.
config
.
adapter
.
publish
(
this
.
model
,
this
.
keypath
,
value
);
};
Binding
.
prototype
.
bind
=
function
()
{
...
...
@@ -193,12 +193,12 @@
};
View
.
prototype
.
build
=
function
()
{
var
bindingRegExp
,
el
,
node
,
parse
Node
,
skipNodes
,
_i
,
_j
,
_len
,
_len1
,
_ref
,
_ref1
,
var
bindingRegExp
,
el
,
node
,
parse
,
skipNodes
,
_i
,
_j
,
_len
,
_len1
,
_ref
,
_ref1
,
_this
=
this
;
this
.
bindings
=
[];
skipNodes
=
[];
bindingRegExp
=
this
.
bindingRegExp
();
parse
Node
=
function
(
node
)
{
parse
=
function
(
node
)
{
var
attribute
,
attributes
,
binder
,
binding
,
context
,
ctx
,
dependencies
,
identifier
,
keypath
,
model
,
n
,
options
,
path
,
pipe
,
pipes
,
regexp
,
splitPath
,
type
,
value
,
_i
,
_j
,
_k
,
_len
,
_len1
,
_len2
,
_ref
,
_ref1
,
_ref2
,
_ref3
;
if
(
__indexOf
.
call
(
skipNodes
,
node
)
<
0
)
{
_ref
=
node
.
attributes
;
...
...
@@ -284,11 +284,13 @@
_ref
=
this
.
els
;
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
el
=
_ref
[
_i
];
parse
Node
(
el
);
parse
(
el
);
_ref1
=
el
.
getElementsByTagName
(
'*'
);
for
(
_j
=
0
,
_len1
=
_ref1
.
length
;
_j
<
_len1
;
_j
++
)
{
node
=
_ref1
[
_j
];
parseNode
(
node
);
if
(
node
.
attributes
!=
null
)
{
parse
(
node
);
}
}
}
};
...
...
lib/rivets.min.js
View file @
abeca6f
This diff is collapsed.
Click to expand it.
package.json
View file @
abeca6f
{
"name"
:
"rivets"
,
"description"
:
"Declarative data binding facility."
,
"version"
:
"0.4.
2
"
,
"version"
:
"0.4.
3
"
,
"author"
:
"Michael Richards"
,
"url"
:
"http://rivetsjs.com"
,
"main"
:
"./lib/rivets.js"
,
...
...
src/rivets.coffee
View file @
abeca6f
# rivets.js
# version : 0.4.
2
# version : 0.4.
3
# author : Michael Richards
# license : MIT
...
...
Please
register
or
sign in
to post a comment