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
d924282f
authored
2013-05-20 17:33:01 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Build 0.5.3.
1 parent
c4620bf8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
41 deletions
component.json
dist/rivets.js
dist/rivets.min.js
package.json
src/rivets.coffee
component.json
View file @
d924282
...
...
@@ -2,7 +2,7 @@
"name"
:
"rivets"
,
"repo"
:
"mikeric/rivets"
,
"description"
:
"Declarative data binding facility."
,
"version"
:
"0.5.
2
"
,
"version"
:
"0.5.
3
"
,
"keywords"
:
[
"data binding"
,
"templating"
],
"scripts"
:
[
"dist/rivets.js"
],
"main"
:
"dist/rivets.js"
,
...
...
dist/rivets.js
View file @
d924282
// Rivets.js
// version: 0.5.
2
// version: 0.5.
3
// author: Michael Richards
// license: MIT
(
function
()
{
...
...
@@ -595,10 +595,17 @@
},
"each-*"
:
{
block
:
true
,
bind
:
function
(
el
,
collection
)
{
return
el
.
removeAttribute
([
'data'
,
this
.
view
.
config
.
prefix
,
this
.
type
].
join
(
'-'
).
replace
(
'--'
,
'-'
));
bind
:
function
(
el
)
{
var
attr
;
attr
=
[
'data'
,
this
.
view
.
config
.
prefix
,
this
.
type
].
join
(
'-'
).
replace
(
'--'
,
'-'
);
this
.
marker
=
document
.
createComment
(
" rivets: "
+
this
.
type
+
" "
);
this
.
iterated
=
[];
el
.
removeAttribute
(
attr
);
el
.
parentNode
.
insertBefore
(
this
.
marker
,
el
);
return
el
.
parentNode
.
removeChild
(
el
);
},
unbind
:
function
(
el
,
collection
)
{
unbind
:
function
(
el
)
{
var
view
,
_i
,
_len
,
_ref
,
_results
;
if
(
this
.
iterated
!=
null
)
{
...
...
@@ -612,58 +619,52 @@
}
},
routine
:
function
(
el
,
collection
)
{
var
data
,
e
,
item
,
itemEl
,
k
,
m
,
n
,
options
,
previous
,
v
,
view
,
_i
,
_j
,
_k
,
_len
,
_len1
,
_len2
,
_ref
,
_ref1
,
_ref2
,
_ref3
,
_ref4
,
_results
;
var
data
,
i
,
index
,
k
,
key
,
model
,
modelName
,
options
,
previous
,
template
,
v
,
view
,
_i
,
_j
,
_len
,
_len1
,
_ref
,
_ref1
,
_ref2
,
_results
;
if
(
this
.
iterated
!=
null
)
{
_ref
=
this
.
iterated
;
modelName
=
this
.
args
[
0
];
collection
=
collection
||
[];
if
(
this
.
iterated
.
length
>
collection
.
length
)
{
_ref
=
Array
(
this
.
iterated
.
length
-
collection
.
length
);
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
view
=
_ref
[
_i
];
i
=
_ref
[
_i
];
view
=
this
.
iterated
.
pop
();
view
.
unbind
();
_ref1
=
view
.
els
;
for
(
_j
=
0
,
_len1
=
_ref1
.
length
;
_j
<
_len1
;
_j
++
)
{
e
=
_ref1
[
_j
];
e
.
parentNode
.
removeChild
(
e
);
}
this
.
marker
.
parentNode
.
removeChild
(
view
.
els
[
0
]);
}
}
else
{
this
.
marker
=
document
.
createComment
(
" rivets: "
+
this
.
type
+
" "
);
el
.
parentNode
.
insertBefore
(
this
.
marker
,
el
);
el
.
parentNode
.
removeChild
(
el
);
}
this
.
iterated
=
[];
if
(
collection
)
{
_results
=
[];
for
(
_k
=
0
,
_len2
=
collection
.
length
;
_k
<
_len2
;
_k
++
)
{
item
=
collection
[
_k
];
for
(
index
=
_j
=
0
,
_len1
=
collection
.
length
;
_j
<
_len1
;
index
=
++
_j
)
{
model
=
collection
[
index
];
data
=
{};
_ref2
=
this
.
view
.
models
;
for
(
n
in
_ref2
)
{
m
=
_ref2
[
n
];
data
[
n
]
=
m
;
data
[
modelName
]
=
model
;
if
(
this
.
iterated
[
index
]
==
null
)
{
_ref1
=
this
.
view
.
models
;
for
(
key
in
_ref1
)
{
model
=
_ref1
[
key
];
data
[
key
]
=
model
;
}
data
[
this
.
args
[
0
]]
=
item
;
itemEl
=
el
.
cloneNode
(
true
);
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
);
options
=
{
binders
:
this
.
view
.
options
.
binders
,
formatters
:
this
.
view
.
options
.
bind
ers
,
formatters
:
this
.
view
.
options
.
formatt
ers
,
config
:
{}
};
if
(
this
.
view
.
options
.
config
)
{
_ref4
=
this
.
view
.
options
.
config
;
for
(
k
in
_ref4
)
{
v
=
_ref4
[
k
];
_ref2
=
this
.
view
.
options
.
config
;
for
(
k
in
_ref2
)
{
v
=
_ref2
[
k
];
options
.
config
[
k
]
=
v
;
}
}
options
.
config
.
preloadData
=
true
;
view
=
new
Rivets
.
View
(
itemEl
,
data
,
options
);
view
.
bind
();
_results
.
push
(
this
.
iterated
.
push
(
view
));
template
=
el
.
cloneNode
(
true
);
this
.
iterated
.
push
(
rivets
.
bind
(
template
,
data
,
options
));
_results
.
push
(
this
.
marker
.
parentNode
.
insertBefore
(
template
,
previous
.
nextSibling
));
}
else
if
(
this
.
iterated
[
index
].
models
[
modelName
]
!==
model
)
{
_results
.
push
(
this
.
iterated
[
index
].
update
(
data
));
}
else
{
_results
.
push
(
void
0
);
}
return
_results
;
}
return
_results
;
}
},
"class-*"
:
function
(
el
,
value
)
{
...
...
dist/rivets.min.js
View file @
d924282
This diff is collapsed.
Click to expand it.
package.json
View file @
d924282
{
"name"
:
"rivets"
,
"description"
:
"Declarative data binding facility."
,
"version"
:
"0.5.
2
"
,
"version"
:
"0.5.
3
"
,
"author"
:
"Michael Richards"
,
"url"
:
"http://rivetsjs.com"
,
"main"
:
"./dist/rivets.js"
,
...
...
src/rivets.coffee
View file @
d924282
# Rivets.js
# =========
# > version: 0.5.
2
# > version: 0.5.
3
# > author: Michael Richards
# > license: MIT
# >
...
...
Please
register
or
sign in
to post a comment