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
d9c1dbac
authored
2013-04-20 16:14:06 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Build 0.4.9.
1 parent
23246382
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
16 deletions
component.json
lib/rivets.js
lib/rivets.min.js
package.json
src/rivets.coffee
component.json
View file @
d9c1dba
...
...
@@ -2,7 +2,7 @@
"name"
:
"rivets"
,
"repo"
:
"mikeric/rivets"
,
"description"
:
"Declarative data binding facility."
,
"version"
:
"0.4.
8
"
,
"version"
:
"0.4.
9
"
,
"keywords"
:
[
"data binding"
,
"templating"
],
"scripts"
:
[
"lib/rivets.js"
],
"main"
:
"lib/rivets.js"
,
...
...
lib/rivets.js
View file @
d9c1dba
// rivets.js
// version: 0.4.
8
// version: 0.4.
9
// author: Michael Richards
// license: MIT
(
function
()
{
...
...
@@ -61,13 +61,13 @@
}
Binding
.
prototype
.
formattedValue
=
function
(
value
)
{
var
args
,
formatter
,
id
,
_i
,
_len
,
_ref
;
var
args
,
formatter
,
id
,
_i
,
_len
,
_ref
,
_ref1
,
_ref2
,
_ref3
;
_ref
=
this
.
formatters
;
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
formatter
=
_ref
[
_i
];
args
=
formatter
.
split
(
/
\s
+/
);
id
=
args
.
shift
();
formatter
=
this
.
model
[
id
]
instanceof
Function
?
this
.
model
[
id
]
:
Rivets
.
formatters
[
id
];
formatter
=
this
.
model
[
id
]
instanceof
Function
?
this
.
model
[
id
]
:
((
_ref1
=
this
.
options
)
!=
null
?
(
_ref2
=
_ref1
.
bindingOptions
)
!=
null
?
(
_ref3
=
_ref2
.
formatters
)
!=
null
?
_ref3
[
id
]
:
void
0
:
void
0
:
void
0
)
instanceof
Function
?
this
.
options
.
bindingOptions
.
formatters
[
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
)
{
...
...
@@ -167,9 +167,10 @@
Rivets
.
View
=
(
function
()
{
function
View
(
els
,
models
)
{
function
View
(
els
,
models
,
options
)
{
this
.
els
=
els
;
this
.
models
=
models
;
this
.
options
=
options
;
this
.
publish
=
__bind
(
this
.
publish
,
this
);
this
.
sync
=
__bind
(
this
.
sync
,
this
);
...
...
@@ -242,6 +243,9 @@
attribute
=
_ref3
[
_k
];
if
(
bindingRegExp
.
test
(
attribute
.
name
))
{
options
=
{};
if
((
_this
.
options
!=
null
)
&&
typeof
_this
.
options
===
'object'
)
{
options
.
bindingOptions
=
_this
.
options
;
}
type
=
attribute
.
name
.
replace
(
bindingRegExp
,
''
);
pipes
=
(
function
()
{
var
_l
,
_len3
,
_ref4
,
_results
;
...
...
@@ -533,7 +537,7 @@
"each-*"
:
{
block
:
true
,
bind
:
function
(
el
,
collection
)
{
return
el
.
removeAttribute
([
'data'
,
r
ivets
.
config
.
prefix
,
this
.
type
].
join
(
'-'
).
replace
(
'--'
,
'-'
));
return
el
.
removeAttribute
([
'data'
,
R
ivets
.
config
.
prefix
,
this
.
type
].
join
(
'-'
).
replace
(
'--'
,
'-'
));
},
routine
:
function
(
el
,
collection
)
{
var
data
,
e
,
item
,
itemEl
,
m
,
n
,
previous
,
view
,
_i
,
_j
,
_k
,
_len
,
_len1
,
_len2
,
_ref
,
_ref1
,
_ref2
,
_ref3
,
_results
;
...
...
@@ -566,13 +570,11 @@
}
data
[
this
.
args
[
0
]]
=
item
;
itemEl
=
el
.
cloneNode
(
true
);
if
(
this
.
iterated
.
length
>
0
)
{
previous
=
this
.
iterated
[
this
.
iterated
.
length
-
1
].
els
[
0
];
}
else
{
previous
=
this
.
marker
;
}
previous
=
this
.
iterated
.
length
?
this
.
iterated
[
this
.
iterated
.
length
-
1
].
els
[
0
]
:
this
.
marker
;
this
.
marker
.
parentNode
.
insertBefore
(
itemEl
,
(
_ref3
=
previous
.
nextSibling
)
!=
null
?
_ref3
:
null
);
_results
.
push
(
this
.
iterated
.
push
(
rivets
.
bind
(
itemEl
,
data
)));
view
=
new
Rivets
.
View
(
itemEl
,
data
);
view
.
bind
();
_results
.
push
(
this
.
iterated
.
push
(
view
));
}
return
_results
;
}
...
...
@@ -614,12 +616,15 @@
Rivets
.
config
[
property
]
=
value
;
}
};
return
exports
.
bind
=
function
(
el
,
models
)
{
return
exports
.
bind
=
function
(
el
,
models
,
options
)
{
var
view
;
if
(
models
==
null
)
{
models
=
{};
}
view
=
new
Rivets
.
View
(
el
,
models
);
if
(
options
==
null
)
{
options
=
{};
}
view
=
new
Rivets
.
View
(
el
,
models
,
options
);
view
.
bind
();
return
view
;
};
...
...
lib/rivets.min.js
View file @
d9c1dba
This diff is collapsed.
Click to expand it.
package.json
View file @
d9c1dba
{
"name"
:
"rivets"
,
"description"
:
"Declarative data binding facility."
,
"version"
:
"0.4.
8
"
,
"version"
:
"0.4.
9
"
,
"author"
:
"Michael Richards"
,
"url"
:
"http://rivetsjs.com"
,
"main"
:
"./lib/rivets.js"
,
...
...
src/rivets.coffee
View file @
d9c1dba
# rivets.js
# version : 0.4.
8
# version : 0.4.
9
# author : Michael Richards
# license : MIT
...
...
Please
register
or
sign in
to post a comment