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
68e23851
authored
2012-08-06 16:42:46 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Build 0.3.1.
1 parent
feb9426d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
15 deletions
lib/rivets.js
lib/rivets.min.js
package.json
src/rivets.coffee
lib/rivets.js
View file @
68e2385
// rivets.js
// version: 0.3.
0
// version: 0.3.
1
// author: Michael Richards
// license: MIT
(
function
()
{
...
...
@@ -51,7 +51,7 @@
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
.
config
.
formatters
[
id
]
?
(
_ref2
=
Rivets
.
config
.
formatters
)[
id
].
apply
(
_ref2
,
[
value
].
concat
(
__slice
.
call
(
args
)))
:
void
0
;
value
=
this
.
model
[
id
]
instanceof
Function
?
(
_ref1
=
this
.
model
)[
id
].
apply
(
_ref1
,
[
value
].
concat
(
__slice
.
call
(
args
)))
:
Rivets
.
formatters
[
id
]
?
(
_ref2
=
Rivets
.
formatters
)[
id
].
apply
(
_ref2
,
[
value
].
concat
(
__slice
.
call
(
args
)))
:
void
0
;
}
return
value
;
};
...
...
@@ -158,7 +158,7 @@
bindingRegExp
=
this
.
bindingRegExp
();
eventRegExp
=
/^on-/
;
parseNode
=
function
(
node
)
{
var
attribute
,
context
,
ctx
,
dependencies
,
keypath
,
model
,
options
,
path
,
pipe
,
pipes
,
type
,
_i
,
_len
,
_ref
,
_results
;
var
attribute
,
context
,
ctx
,
dependencies
,
keypath
,
model
,
options
,
path
,
pipe
,
pipes
,
splitPath
,
type
,
_i
,
_len
,
_ref
,
_results
;
_ref
=
node
.
attributes
;
_results
=
[];
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
...
...
@@ -186,11 +186,12 @@
}
return
_results1
;
})();
path
=
context
.
shift
().
split
(
/
(\.
|:
)
/
);
path
=
context
.
shift
();
splitPath
=
path
.
split
(
/
\.
|:/
);
options
.
formatters
=
pipes
;
model
=
_this
.
models
[
p
ath
.
shift
()];
options
.
bypass
=
path
.
shift
()
===
':'
;
keypath
=
p
ath
.
join
();
model
=
_this
.
models
[
splitP
ath
.
shift
()];
options
.
bypass
=
path
.
indexOf
(
":"
)
!==
-
1
;
keypath
=
splitP
ath
.
join
();
if
(
dependencies
=
context
.
shift
())
{
options
.
dependencies
=
dependencies
.
split
(
/
\s
+/
);
}
...
...
@@ -252,16 +253,18 @@
bindEvent
=
function
(
el
,
event
,
fn
)
{
if
(
window
.
addEventListener
)
{
return
el
.
addEventListener
(
event
,
fn
);
return
el
.
addEventListener
(
event
,
fn
,
false
);
}
else
{
event
=
"on"
+
event
;
return
el
.
attachEvent
(
event
,
fn
);
}
};
unbindEvent
=
function
(
el
,
event
,
fn
)
{
if
(
window
.
removeEventListener
)
{
return
el
.
removeEventListener
(
event
,
fn
);
return
el
.
removeEventListener
(
event
,
fn
,
false
);
}
else
{
event
=
"on"
+
event
;
return
el
.
detachEvent
(
event
,
fn
);
}
};
...
...
@@ -339,12 +342,14 @@
};
Rivets
.
config
=
{
preloadData
:
true
,
formatters
:
{}
preloadData
:
true
};
Rivets
.
formatters
=
{};
rivets
=
{
routines
:
Rivets
.
routines
,
formatters
:
Rivets
.
formatters
,
config
:
Rivets
.
config
,
configure
:
function
(
options
)
{
var
property
,
value
,
_results
;
...
...
lib/rivets.min.js
View file @
68e2385
// rivets.js
// version: 0.3.
0
// version: 0.3.
1
// author: Michael Richards
// license: MIT
(
function
(){
var
a
,
b
,
c
,
d
,
e
,
f
,
g
,
h
=
function
(
a
,
b
){
return
function
(){
return
a
.
apply
(
b
,
arguments
)}},
i
=
[].
slice
,
j
=
[].
indexOf
||
function
(
a
){
for
(
var
b
=
0
,
c
=
this
.
length
;
b
<
c
;
b
++
)
if
(
b
in
this
&&
this
[
b
]
===
a
)
return
b
;
return
-
1
};
a
=
{},
String
.
prototype
.
trim
||
(
String
.
prototype
.
trim
=
function
(){
return
this
.
replace
(
/^
\s
+|
\s
+$/g
,
""
)}),
a
.
Binding
=
function
(){
function
f
(
c
,
e
,
f
,
g
,
i
){
this
.
el
=
c
,
this
.
type
=
e
,
this
.
model
=
f
,
this
.
keypath
=
g
,
this
.
options
=
i
!=
null
?
i
:{},
this
.
unbind
=
h
(
this
.
unbind
,
this
),
this
.
publish
=
h
(
this
.
publish
,
this
),
this
.
bind
=
h
(
this
.
bind
,
this
),
this
.
set
=
h
(
this
.
set
,
this
),
this
.
formattedValue
=
h
(
this
.
formattedValue
,
this
),
this
.
options
.
special
===
"event"
?
this
.
routine
=
d
(
this
.
type
):
this
.
routine
=
a
.
routines
[
this
.
type
]
||
b
(
this
.
type
),
this
.
formatters
=
this
.
options
.
formatters
||
[]}
return
f
.
prototype
.
bidirectionals
=
[
"value"
,
"checked"
,
"unchecked"
],
f
.
prototype
.
formattedValue
=
function
(
b
){
var
c
,
d
,
e
,
f
,
g
,
h
,
j
,
k
;
h
=
this
.
formatters
;
for
(
f
=
0
,
g
=
h
.
length
;
f
<
g
;
f
++
)
d
=
h
[
f
],
c
=
d
.
split
(
/
\s
+/
),
e
=
c
.
shift
(),
b
=
this
.
model
[
e
]
instanceof
Function
?(
j
=
this
.
model
)[
e
].
apply
(
j
,[
b
].
concat
(
i
.
call
(
c
))):
a
.
config
.
formatters
[
e
]?(
k
=
a
.
config
.
formatters
)[
e
].
apply
(
k
,[
b
].
concat
(
i
.
call
(
c
))):
void
0
;
return
b
},
f
.
prototype
.
set
=
function
(
a
){
return
a
=
this
.
formattedValue
(
a
),
this
.
options
.
special
===
"event"
?(
this
.
routine
(
this
.
el
,
a
,
this
.
currentListener
),
this
.
currentListener
=
a
):(
a
instanceof
Function
&&
(
a
=
a
()),
this
.
routine
(
this
.
el
,
a
))},
f
.
prototype
.
bind
=
function
(){
var
b
,
d
,
e
,
f
,
g
,
h
,
i
,
k
=
this
;
this
.
options
.
bypass
?
this
.
set
(
this
.
model
[
this
.
keypath
]):(
a
.
config
.
adapter
.
subscribe
(
this
.
model
,
this
.
keypath
,
this
.
set
),
a
.
config
.
preloadData
&&
this
.
set
(
a
.
config
.
adapter
.
read
(
this
.
model
,
this
.
keypath
)));
if
((
g
=
this
.
options
.
dependencies
)
!=
null
?
g
.
length
:
void
0
){
this
.
dependencyCallbacks
=
{},
h
=
this
.
options
.
dependencies
;
for
(
e
=
0
,
f
=
h
.
length
;
e
<
f
;
e
++
)
d
=
h
[
e
],
b
=
this
.
dependencyCallbacks
[
d
]
=
function
(
b
){
return
k
.
set
(
k
.
options
.
bypass
?
k
.
model
[
k
.
keypath
]:
a
.
config
.
adapter
.
read
(
k
.
model
,
k
.
keypath
))},
a
.
config
.
adapter
.
subscribe
(
this
.
model
,
d
,
b
)}
if
(
i
=
this
.
type
,
j
.
call
(
this
.
bidirectionals
,
i
)
>=
0
)
return
c
(
this
.
el
,
"change"
,
this
.
publish
)},
f
.
prototype
.
publish
=
function
(
b
){
var
c
;
return
c
=
b
.
target
||
b
.
srcElement
,
a
.
config
.
adapter
.
publish
(
this
.
model
,
this
.
keypath
,
e
(
c
))},
f
.
prototype
.
unbind
=
function
(){
var
b
,
c
,
d
,
e
,
f
,
g
,
h
;
a
.
config
.
adapter
.
unsubscribe
(
this
.
model
,
this
.
keypath
,
this
.
set
);
if
((
f
=
this
.
options
.
dependencies
)
!=
null
?
f
.
length
:
void
0
){
g
=
this
.
options
.
dependencies
;
for
(
d
=
0
,
e
=
g
.
length
;
d
<
e
;
d
++
)
c
=
g
[
d
],
b
=
this
.
dependencyCallbacks
[
c
],
a
.
config
.
adapter
.
unsubscribe
(
this
.
model
,
c
,
b
)}
if
(
h
=
this
.
type
,
j
.
call
(
this
.
bidirectionals
,
h
)
>=
0
)
return
this
.
el
.
removeEventListener
(
"change"
,
this
.
publish
)},
f
}(),
a
.
View
=
function
(){
function
b
(
a
,
b
){
this
.
els
=
a
,
this
.
models
=
b
,
this
.
unbind
=
h
(
this
.
unbind
,
this
),
this
.
bind
=
h
(
this
.
bind
,
this
),
this
.
build
=
h
(
this
.
build
,
this
),
this
.
bindingRegExp
=
h
(
this
.
bindingRegExp
,
this
),
this
.
els
.
jquery
||
this
.
els
instanceof
Array
||
(
this
.
els
=
[
this
.
els
]),
this
.
build
()}
return
b
.
prototype
.
bindingRegExp
=
function
(){
var
b
;
return
b
=
a
.
config
.
prefix
,
b
?
new
RegExp
(
"^data-"
+
b
+
"-"
):
/^data-/
},
b
.
prototype
.
build
=
function
(){
var
b
,
c
,
d
,
e
,
f
,
g
,
h
,
i
,
j
,
k
=
this
;
this
.
bindings
=
[],
b
=
this
.
bindingRegExp
(),
d
=
/^on-/
,
f
=
function
(
c
){
var
e
,
f
,
g
,
h
,
i
,
j
,
l
,
m
,
n
,
o
,
p
,
q
,
r
,
s
,
t
;
s
=
c
.
attributes
,
t
=
[];
for
(
q
=
0
,
r
=
s
.
length
;
q
<
r
;
q
++
){
e
=
s
[
q
];
if
(
b
.
test
(
e
.
name
)){
l
=
{},
p
=
e
.
name
.
replace
(
b
,
""
),
o
=
function
(){
var
a
,
b
,
c
,
d
;
c
=
e
.
value
.
split
(
"|"
),
d
=
[];
for
(
a
=
0
,
b
=
c
.
length
;
a
<
b
;
a
++
)
n
=
c
[
a
],
d
.
push
(
n
.
trim
());
return
d
}(),
f
=
function
(){
var
a
,
b
,
c
,
d
;
c
=
o
.
shift
().
split
(
">"
),
d
=
[];
for
(
a
=
0
,
b
=
c
.
length
;
a
<
b
;
a
++
)
g
=
c
[
a
],
d
.
push
(
g
.
trim
());
return
d
}(),
m
=
f
.
shift
().
split
(
/
(\.
|:
)
/
),
l
.
formatters
=
o
,
j
=
k
.
models
[
m
.
shift
()],
l
.
bypass
=
m
.
shift
()
===
":"
,
i
=
m
.
join
();
if
(
h
=
f
.
shift
())
l
.
dependencies
=
h
.
split
(
/
\s
+/
);
d
.
test
(
p
)
&&
(
p
=
p
.
replace
(
d
,
""
),
l
.
special
=
"event"
),
t
.
push
(
k
.
bindings
.
push
(
new
a
.
Binding
(
c
,
p
,
j
,
i
,
l
)))}
else
t
.
push
(
void
0
)}
return
t
},
i
=
this
.
els
,
j
=
[];
for
(
g
=
0
,
h
=
i
.
length
;
g
<
h
;
g
++
)
c
=
i
[
g
],
f
(
c
),
j
.
push
(
function
(){
var
a
,
b
,
d
,
g
;
d
=
c
.
getElementsByTagName
(
"*"
),
g
=
[];
for
(
a
=
0
,
b
=
d
.
length
;
a
<
b
;
a
++
)
e
=
d
[
a
],
g
.
push
(
f
(
e
));
return
g
}());
return
j
},
b
.
prototype
.
bind
=
function
(){
var
a
,
b
,
c
,
d
,
e
;
d
=
this
.
bindings
,
e
=
[];
for
(
b
=
0
,
c
=
d
.
length
;
b
<
c
;
b
++
)
a
=
d
[
b
],
e
.
push
(
a
.
bind
());
return
e
},
b
.
prototype
.
unbind
=
function
(){
var
a
,
b
,
c
,
d
,
e
;
d
=
this
.
bindings
,
e
=
[];
for
(
b
=
0
,
c
=
d
.
length
;
b
<
c
;
b
++
)
a
=
d
[
b
],
e
.
push
(
a
.
unbind
());
return
e
},
b
}(),
c
=
function
(
a
,
b
,
c
){
return
window
.
addEventListener
?
a
.
addEventListener
(
b
,
c
):
a
.
attachEvent
(
b
,
c
)},
g
=
function
(
a
,
b
,
c
){
return
window
.
removeEventListener
?
a
.
removeEventListener
(
b
,
c
):
a
.
detachEvent
(
b
,
c
)},
e
=
function
(
a
){
switch
(
a
.
type
){
case
"checkbox"
:
return
a
.
checked
;
default
:
return
a
.
value
}},
d
=
function
(
a
){
return
function
(
b
,
d
,
e
){
d
&&
c
(
b
,
a
,
d
);
if
(
e
)
return
g
(
b
,
a
,
e
)}},
b
=
function
(
a
){
return
function
(
b
,
c
){
return
c
?
b
.
setAttribute
(
a
,
c
):
b
.
removeAttribute
(
a
)}},
a
.
routines
=
{
enabled
:
function
(
a
,
b
){
return
a
.
disabled
=!
b
},
disabled
:
function
(
a
,
b
){
return
a
.
disabled
=!!
b
},
checked
:
function
(
a
,
b
){
return
a
.
type
===
"radio"
?
a
.
checked
=
a
.
value
===
b
:
a
.
checked
=!!
b
},
unchecked
:
function
(
a
,
b
){
return
a
.
type
===
"radio"
?
a
.
checked
=
a
.
value
!==
b
:
a
.
checked
=!
b
},
show
:
function
(
a
,
b
){
return
a
.
style
.
display
=
b
?
""
:
"none"
},
hide
:
function
(
a
,
b
){
return
a
.
style
.
display
=
b
?
"none"
:
""
},
html
:
function
(
a
,
b
){
return
a
.
innerHTML
=
b
!=
null
?
b
:
""
},
value
:
function
(
a
,
b
){
return
a
.
value
=
b
!=
null
?
b
:
""
},
text
:
function
(
a
,
b
){
return
a
.
innerText
!=
null
?
a
.
innerText
=
b
!=
null
?
b
:
""
:
a
.
textContent
=
b
!=
null
?
b
:
""
}},
a
.
config
=
{
preloadData
:
!
0
,
formatters
:{}},
f
=
{
routines
:
a
.
routines
,
config
:
a
.
config
,
configure
:
function
(
b
){
var
c
,
d
,
e
;
b
==
null
&&
(
b
=
{}),
e
=
[];
for
(
c
in
b
)
d
=
b
[
c
],
e
.
push
(
a
.
config
[
c
]
=
d
);
return
e
},
bind
:
function
(
b
,
c
){
var
d
;
return
c
==
null
&&
(
c
=
{}),
d
=
new
a
.
View
(
b
,
c
),
d
.
bind
(),
d
}},
typeof
module
!=
"undefined"
&&
module
!==
null
?
module
.
exports
=
f
:
this
.
rivets
=
f
}).
call
(
this
);
\ No newline at end of file
(
function
(){
var
a
,
b
,
c
,
d
,
e
,
f
,
g
,
h
=
function
(
a
,
b
){
return
function
(){
return
a
.
apply
(
b
,
arguments
)}},
i
=
[].
slice
,
j
=
[].
indexOf
||
function
(
a
){
for
(
var
b
=
0
,
c
=
this
.
length
;
b
<
c
;
b
++
)
if
(
b
in
this
&&
this
[
b
]
===
a
)
return
b
;
return
-
1
};
a
=
{},
String
.
prototype
.
trim
||
(
String
.
prototype
.
trim
=
function
(){
return
this
.
replace
(
/^
\s
+|
\s
+$/g
,
""
)}),
a
.
Binding
=
function
(){
function
f
(
c
,
e
,
f
,
g
,
i
){
this
.
el
=
c
,
this
.
type
=
e
,
this
.
model
=
f
,
this
.
keypath
=
g
,
this
.
options
=
i
!=
null
?
i
:{},
this
.
unbind
=
h
(
this
.
unbind
,
this
),
this
.
publish
=
h
(
this
.
publish
,
this
),
this
.
bind
=
h
(
this
.
bind
,
this
),
this
.
set
=
h
(
this
.
set
,
this
),
this
.
formattedValue
=
h
(
this
.
formattedValue
,
this
),
this
.
options
.
special
===
"event"
?
this
.
routine
=
d
(
this
.
type
):
this
.
routine
=
a
.
routines
[
this
.
type
]
||
b
(
this
.
type
),
this
.
formatters
=
this
.
options
.
formatters
||
[]}
return
f
.
prototype
.
bidirectionals
=
[
"value"
,
"checked"
,
"unchecked"
],
f
.
prototype
.
formattedValue
=
function
(
b
){
var
c
,
d
,
e
,
f
,
g
,
h
,
j
,
k
;
h
=
this
.
formatters
;
for
(
f
=
0
,
g
=
h
.
length
;
f
<
g
;
f
++
)
d
=
h
[
f
],
c
=
d
.
split
(
/
\s
+/
),
e
=
c
.
shift
(),
b
=
this
.
model
[
e
]
instanceof
Function
?(
j
=
this
.
model
)[
e
].
apply
(
j
,[
b
].
concat
(
i
.
call
(
c
))):
a
.
formatters
[
e
]?(
k
=
a
.
formatters
)[
e
].
apply
(
k
,[
b
].
concat
(
i
.
call
(
c
))):
void
0
;
return
b
},
f
.
prototype
.
set
=
function
(
a
){
return
a
=
this
.
formattedValue
(
a
),
this
.
options
.
special
===
"event"
?(
this
.
routine
(
this
.
el
,
a
,
this
.
currentListener
),
this
.
currentListener
=
a
):(
a
instanceof
Function
&&
(
a
=
a
()),
this
.
routine
(
this
.
el
,
a
))},
f
.
prototype
.
bind
=
function
(){
var
b
,
d
,
e
,
f
,
g
,
h
,
i
,
k
=
this
;
this
.
options
.
bypass
?
this
.
set
(
this
.
model
[
this
.
keypath
]):(
a
.
config
.
adapter
.
subscribe
(
this
.
model
,
this
.
keypath
,
this
.
set
),
a
.
config
.
preloadData
&&
this
.
set
(
a
.
config
.
adapter
.
read
(
this
.
model
,
this
.
keypath
)));
if
((
g
=
this
.
options
.
dependencies
)
!=
null
?
g
.
length
:
void
0
){
this
.
dependencyCallbacks
=
{},
h
=
this
.
options
.
dependencies
;
for
(
e
=
0
,
f
=
h
.
length
;
e
<
f
;
e
++
)
d
=
h
[
e
],
b
=
this
.
dependencyCallbacks
[
d
]
=
function
(
b
){
return
k
.
set
(
k
.
options
.
bypass
?
k
.
model
[
k
.
keypath
]:
a
.
config
.
adapter
.
read
(
k
.
model
,
k
.
keypath
))},
a
.
config
.
adapter
.
subscribe
(
this
.
model
,
d
,
b
)}
if
(
i
=
this
.
type
,
j
.
call
(
this
.
bidirectionals
,
i
)
>=
0
)
return
c
(
this
.
el
,
"change"
,
this
.
publish
)},
f
.
prototype
.
publish
=
function
(
b
){
var
c
;
return
c
=
b
.
target
||
b
.
srcElement
,
a
.
config
.
adapter
.
publish
(
this
.
model
,
this
.
keypath
,
e
(
c
))},
f
.
prototype
.
unbind
=
function
(){
var
b
,
c
,
d
,
e
,
f
,
g
,
h
;
a
.
config
.
adapter
.
unsubscribe
(
this
.
model
,
this
.
keypath
,
this
.
set
);
if
((
f
=
this
.
options
.
dependencies
)
!=
null
?
f
.
length
:
void
0
){
g
=
this
.
options
.
dependencies
;
for
(
d
=
0
,
e
=
g
.
length
;
d
<
e
;
d
++
)
c
=
g
[
d
],
b
=
this
.
dependencyCallbacks
[
c
],
a
.
config
.
adapter
.
unsubscribe
(
this
.
model
,
c
,
b
)}
if
(
h
=
this
.
type
,
j
.
call
(
this
.
bidirectionals
,
h
)
>=
0
)
return
this
.
el
.
removeEventListener
(
"change"
,
this
.
publish
)},
f
}(),
a
.
View
=
function
(){
function
b
(
a
,
b
){
this
.
els
=
a
,
this
.
models
=
b
,
this
.
unbind
=
h
(
this
.
unbind
,
this
),
this
.
bind
=
h
(
this
.
bind
,
this
),
this
.
build
=
h
(
this
.
build
,
this
),
this
.
bindingRegExp
=
h
(
this
.
bindingRegExp
,
this
),
this
.
els
.
jquery
||
this
.
els
instanceof
Array
||
(
this
.
els
=
[
this
.
els
]),
this
.
build
()}
return
b
.
prototype
.
bindingRegExp
=
function
(){
var
b
;
return
b
=
a
.
config
.
prefix
,
b
?
new
RegExp
(
"^data-"
+
b
+
"-"
):
/^data-/
},
b
.
prototype
.
build
=
function
(){
var
b
,
c
,
d
,
e
,
f
,
g
,
h
,
i
,
j
,
k
=
this
;
this
.
bindings
=
[],
b
=
this
.
bindingRegExp
(),
d
=
/^on-/
,
f
=
function
(
c
){
var
e
,
f
,
g
,
h
,
i
,
j
,
l
,
m
,
n
,
o
,
p
,
q
,
r
,
s
,
t
,
u
;
t
=
c
.
attributes
,
u
=
[];
for
(
r
=
0
,
s
=
t
.
length
;
r
<
s
;
r
++
){
e
=
t
[
r
];
if
(
b
.
test
(
e
.
name
)){
l
=
{},
q
=
e
.
name
.
replace
(
b
,
""
),
o
=
function
(){
var
a
,
b
,
c
,
d
;
c
=
e
.
value
.
split
(
"|"
),
d
=
[];
for
(
a
=
0
,
b
=
c
.
length
;
a
<
b
;
a
++
)
n
=
c
[
a
],
d
.
push
(
n
.
trim
());
return
d
}(),
f
=
function
(){
var
a
,
b
,
c
,
d
;
c
=
o
.
shift
().
split
(
">"
),
d
=
[];
for
(
a
=
0
,
b
=
c
.
length
;
a
<
b
;
a
++
)
g
=
c
[
a
],
d
.
push
(
g
.
trim
());
return
d
}(),
m
=
f
.
shift
(),
p
=
m
.
split
(
/
\.
|:/
),
l
.
formatters
=
o
,
j
=
k
.
models
[
p
.
shift
()],
l
.
bypass
=
m
.
indexOf
(
":"
)
!==-
1
,
i
=
p
.
join
();
if
(
h
=
f
.
shift
())
l
.
dependencies
=
h
.
split
(
/
\s
+/
);
d
.
test
(
q
)
&&
(
q
=
q
.
replace
(
d
,
""
),
l
.
special
=
"event"
),
u
.
push
(
k
.
bindings
.
push
(
new
a
.
Binding
(
c
,
q
,
j
,
i
,
l
)))}
else
u
.
push
(
void
0
)}
return
u
},
i
=
this
.
els
,
j
=
[];
for
(
g
=
0
,
h
=
i
.
length
;
g
<
h
;
g
++
)
c
=
i
[
g
],
f
(
c
),
j
.
push
(
function
(){
var
a
,
b
,
d
,
g
;
d
=
c
.
getElementsByTagName
(
"*"
),
g
=
[];
for
(
a
=
0
,
b
=
d
.
length
;
a
<
b
;
a
++
)
e
=
d
[
a
],
g
.
push
(
f
(
e
));
return
g
}());
return
j
},
b
.
prototype
.
bind
=
function
(){
var
a
,
b
,
c
,
d
,
e
;
d
=
this
.
bindings
,
e
=
[];
for
(
b
=
0
,
c
=
d
.
length
;
b
<
c
;
b
++
)
a
=
d
[
b
],
e
.
push
(
a
.
bind
());
return
e
},
b
.
prototype
.
unbind
=
function
(){
var
a
,
b
,
c
,
d
,
e
;
d
=
this
.
bindings
,
e
=
[];
for
(
b
=
0
,
c
=
d
.
length
;
b
<
c
;
b
++
)
a
=
d
[
b
],
e
.
push
(
a
.
unbind
());
return
e
},
b
}(),
c
=
function
(
a
,
b
,
c
){
return
window
.
addEventListener
?
a
.
addEventListener
(
b
,
c
,
!
1
):(
b
=
"on"
+
b
,
a
.
attachEvent
(
b
,
c
))},
g
=
function
(
a
,
b
,
c
){
return
window
.
removeEventListener
?
a
.
removeEventListener
(
b
,
c
,
!
1
):(
b
=
"on"
+
b
,
a
.
detachEvent
(
b
,
c
))},
e
=
function
(
a
){
switch
(
a
.
type
){
case
"checkbox"
:
return
a
.
checked
;
default
:
return
a
.
value
}},
d
=
function
(
a
){
return
function
(
b
,
d
,
e
){
d
&&
c
(
b
,
a
,
d
);
if
(
e
)
return
g
(
b
,
a
,
e
)}},
b
=
function
(
a
){
return
function
(
b
,
c
){
return
c
?
b
.
setAttribute
(
a
,
c
):
b
.
removeAttribute
(
a
)}},
a
.
routines
=
{
enabled
:
function
(
a
,
b
){
return
a
.
disabled
=!
b
},
disabled
:
function
(
a
,
b
){
return
a
.
disabled
=!!
b
},
checked
:
function
(
a
,
b
){
return
a
.
type
===
"radio"
?
a
.
checked
=
a
.
value
===
b
:
a
.
checked
=!!
b
},
unchecked
:
function
(
a
,
b
){
return
a
.
type
===
"radio"
?
a
.
checked
=
a
.
value
!==
b
:
a
.
checked
=!
b
},
show
:
function
(
a
,
b
){
return
a
.
style
.
display
=
b
?
""
:
"none"
},
hide
:
function
(
a
,
b
){
return
a
.
style
.
display
=
b
?
"none"
:
""
},
html
:
function
(
a
,
b
){
return
a
.
innerHTML
=
b
!=
null
?
b
:
""
},
value
:
function
(
a
,
b
){
return
a
.
value
=
b
!=
null
?
b
:
""
},
text
:
function
(
a
,
b
){
return
a
.
innerText
!=
null
?
a
.
innerText
=
b
!=
null
?
b
:
""
:
a
.
textContent
=
b
!=
null
?
b
:
""
}},
a
.
config
=
{
preloadData
:
!
0
},
a
.
formatters
=
{},
f
=
{
routines
:
a
.
routines
,
formatters
:
a
.
formatters
,
config
:
a
.
config
,
configure
:
function
(
b
){
var
c
,
d
,
e
;
b
==
null
&&
(
b
=
{}),
e
=
[];
for
(
c
in
b
)
d
=
b
[
c
],
e
.
push
(
a
.
config
[
c
]
=
d
);
return
e
},
bind
:
function
(
b
,
c
){
var
d
;
return
c
==
null
&&
(
c
=
{}),
d
=
new
a
.
View
(
b
,
c
),
d
.
bind
(),
d
}},
typeof
module
!=
"undefined"
&&
module
!==
null
?
module
.
exports
=
f
:
this
.
rivets
=
f
}).
call
(
this
);
\ No newline at end of file
...
...
package.json
View file @
68e2385
{
"name"
:
"rivets"
,
"description"
:
"Declarative data binding facility."
,
"version"
:
"0.3.
0
"
,
"version"
:
"0.3.
1
"
,
"author"
:
"Michael Richards"
,
"url"
:
"http://rivetsjs.com"
,
"main"
:
"./lib/rivets.js"
,
...
...
src/rivets.coffee
View file @
68e2385
# rivets.js
# version : 0.3.
0
# version : 0.3.
1
# author : Michael Richards
# license : MIT
...
...
Please
register
or
sign in
to post a comment