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
e0044f13
authored
2012-08-11 17:28:08 +0200
by
Nicklas Ansman Giertz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Avoid unnecessary return values
1 parent
67c5564b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
32 deletions
lib/rivets.js
lib/rivets.min.js
src/rivets.coffee
lib/rivets.js
View file @
e0044f1
...
...
@@ -161,7 +161,7 @@
};
View
.
prototype
.
build
=
function
()
{
var
bindingRegExp
,
el
,
eventRegExp
,
iterationRegExp
,
iterator
,
node
,
parseNode
,
skipNodes
,
_i
,
_
len
,
_ref
,
_results
,
var
bindingRegExp
,
el
,
eventRegExp
,
iterationRegExp
,
iterator
,
node
,
parseNode
,
skipNodes
,
_i
,
_
j
,
_len
,
_len1
,
_ref
,
_ref1
,
_this
=
this
;
this
.
bindings
=
[];
skipNodes
=
[];
...
...
@@ -170,7 +170,7 @@
eventRegExp
=
/^on-/
;
iterationRegExp
=
/^each-/
;
parseNode
=
function
(
node
)
{
var
a
,
attribute
,
binding
,
context
,
ctx
,
dependencies
,
keypath
,
model
,
n
,
options
,
path
,
pipe
,
pipes
,
splitPath
,
type
,
_i
,
_j
,
_k
,
_l
,
_len
,
_len1
,
_len2
,
_len3
,
_ref
,
_ref1
,
_ref2
,
_results
;
var
a
,
attribute
,
binding
,
context
,
ctx
,
dependencies
,
keypath
,
model
,
n
,
options
,
path
,
pipe
,
pipes
,
splitPath
,
type
,
_i
,
_j
,
_k
,
_l
,
_len
,
_len1
,
_len2
,
_len3
,
_ref
,
_ref1
,
_ref2
;
if
(
__indexOf
.
call
(
skipNodes
,
node
)
<
0
)
{
_ref
=
node
.
attributes
;
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
...
...
@@ -190,31 +190,30 @@
}
}
_ref2
=
iterator
||
node
.
attributes
;
_results
=
[];
for
(
_k
=
0
,
_len2
=
_ref2
.
length
;
_k
<
_len2
;
_k
++
)
{
attribute
=
_ref2
[
_k
];
if
(
bindingRegExp
.
test
(
attribute
.
name
))
{
options
=
{};
type
=
attribute
.
name
.
replace
(
bindingRegExp
,
''
);
pipes
=
(
function
()
{
var
_l
,
_len3
,
_ref3
,
_results
1
;
var
_l
,
_len3
,
_ref3
,
_results
;
_ref3
=
attribute
.
value
.
split
(
'|'
);
_results
1
=
[];
_results
=
[];
for
(
_l
=
0
,
_len3
=
_ref3
.
length
;
_l
<
_len3
;
_l
++
)
{
pipe
=
_ref3
[
_l
];
_results
1
.
push
(
pipe
.
trim
());
_results
.
push
(
pipe
.
trim
());
}
return
_results
1
;
return
_results
;
})();
context
=
(
function
()
{
var
_l
,
_len3
,
_ref3
,
_results
1
;
var
_l
,
_len3
,
_ref3
,
_results
;
_ref3
=
pipes
.
shift
().
split
(
'>'
);
_results
1
=
[];
_results
=
[];
for
(
_l
=
0
,
_len3
=
_ref3
.
length
;
_l
<
_len3
;
_l
++
)
{
ctx
=
_ref3
[
_l
];
_results
1
.
push
(
ctx
.
trim
());
_results
.
push
(
ctx
.
trim
());
}
return
_results
1
;
return
_results
;
})();
path
=
context
.
shift
();
splitPath
=
path
.
split
(
/
\.
|:/
);
...
...
@@ -244,31 +243,21 @@
a
=
iterator
[
_l
];
node
.
removeAttribute
(
a
.
name
);
}
_results
.
push
(
iterator
=
null
);
}
else
{
_results
.
push
(
void
0
);
iterator
=
null
;
}
}
return
_results
;
}
};
_ref
=
this
.
els
;
_results
=
[];
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
el
=
_ref
[
_i
];
parseNode
(
el
);
_results
.
push
((
function
()
{
var
_j
,
_len1
,
_ref1
,
_results1
;
_ref1
=
el
.
getElementsByTagName
(
'*'
);
_results1
=
[];
for
(
_j
=
0
,
_len1
=
_ref1
.
length
;
_j
<
_len1
;
_j
++
)
{
node
=
_ref1
[
_j
];
_results1
.
push
(
parseNode
(
node
));
}
return
_results1
;
})());
_ref1
=
el
.
getElementsByTagName
(
'*'
);
for
(
_j
=
0
,
_len1
=
_ref1
.
length
;
_j
<
_len1
;
_j
++
)
{
node
=
_ref1
[
_j
];
parseNode
(
node
);
}
}
return
_results
;
};
View
.
prototype
.
bind
=
function
()
{
...
...
@@ -436,16 +425,14 @@
formatters
:
Rivets
.
formatters
,
config
:
Rivets
.
config
,
configure
:
function
(
options
)
{
var
property
,
value
,
_results
;
var
property
,
value
;
if
(
options
==
null
)
{
options
=
{};
}
_results
=
[];
for
(
property
in
options
)
{
value
=
options
[
property
];
_results
.
push
(
Rivets
.
config
[
property
]
=
value
)
;
Rivets
.
config
[
property
]
=
value
;
}
return
_results
;
},
bind
:
function
(
el
,
models
)
{
var
view
;
...
...
lib/rivets.min.js
View file @
e0044f1
This diff is collapsed.
Click to expand it.
src/rivets.coffee
View file @
e0044f1
...
...
@@ -165,10 +165,12 @@ class Rivets.View
if
iterator
node
.
removeAttribute
(
a
.
name
)
for
a
in
iterator
iterator
=
null
return
for
el
in
@
els
parseNode
el
parseNode
node
for
node
in
el
.
getElementsByTagName
'*'
return
# Binds all of the current bindings for this view.
bind
:
=>
...
...
@@ -218,7 +220,7 @@ iterationBinding = (name) -> (el, collection, binding) ->
binding
.
marker
=
document
.
createComment
" rivets: each-
#{
name
}
"
el
.
parentNode
.
insertBefore
binding
.
marker
,
el
el
.
parentNode
.
removeChild
el
binding
.
iterated
=
[]
for
item
in
collection
...
...
@@ -291,6 +293,7 @@ rivets =
configure
:
(
options
=
{})
->
for
property
,
value
of
options
Rivets
.
config
[
property
]
=
value
return
# Binds a set of model objects to a parent DOM element. Returns a Rivets.View
# instance.
...
...
Please
register
or
sign in
to post a comment