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
421bf22b
authored
2013-05-08 22:29:44 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Build 0.5.1.
1 parent
b42c7d98
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
31 deletions
component.json
dist/rivets.js
dist/rivets.min.js
package.json
src/rivets.coffee
component.json
View file @
421bf22
...
...
@@ -2,7 +2,7 @@
"name"
:
"rivets"
,
"repo"
:
"mikeric/rivets"
,
"description"
:
"Declarative data binding facility."
,
"version"
:
"0.5.
0
"
,
"version"
:
"0.5.
1
"
,
"keywords"
:
[
"data binding"
,
"templating"
],
"scripts"
:
[
"dist/rivets.js"
],
"main"
:
"dist/rivets.js"
,
...
...
dist/rivets.js
View file @
421bf22
//
r
ivets.js
// version: 0.5.
0
//
R
ivets.js
// version: 0.5.
1
// author: Michael Richards
// license: MIT
(
function
()
{
var
Rivets
,
bindEvent
,
factory
,
getInputValue
,
unbindEvent
,
var
Rivets
,
__bind
=
function
(
fn
,
me
){
return
function
(){
return
fn
.
apply
(
me
,
arguments
);
};
},
__slice
=
[].
slice
,
__indexOf
=
[].
indexOf
||
function
(
item
)
{
for
(
var
i
=
0
,
l
=
this
.
length
;
i
<
l
;
i
++
)
{
if
(
i
in
this
&&
this
[
i
]
===
item
)
return
i
;
}
return
-
1
;
};
...
...
@@ -58,14 +58,14 @@
}
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
();
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
]
:
this
.
view
.
formatters
[
id
];
formatter
=
this
.
model
[
id
]
instanceof
Function
?
this
.
model
[
id
]
:
this
.
view
.
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
)
{
...
...
@@ -89,7 +89,7 @@
Binding
.
prototype
.
publish
=
function
()
{
var
args
,
formatter
,
id
,
value
,
_i
,
_len
,
_ref
,
_ref1
,
_ref2
;
value
=
getInputValue
(
this
.
el
);
value
=
Rivets
.
Util
.
getInputValue
(
this
.
el
);
_ref
=
this
.
formatters
.
slice
(
0
).
reverse
();
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
formatter
=
_ref
[
_i
];
...
...
@@ -424,7 +424,8 @@
})();
bindEvent
=
function
(
el
,
event
,
handler
,
context
)
{
Rivets
.
Util
=
{
bindEvent
:
function
(
el
,
event
,
handler
,
context
)
{
var
fn
;
fn
=
function
(
e
)
{
...
...
@@ -444,9 +445,8 @@
el
.
attachEvent
(
event
,
fn
);
}
return
fn
;
};
unbindEvent
=
function
(
el
,
event
,
fn
)
{
},
unbindEvent
:
function
(
el
,
event
,
fn
)
{
if
(
window
.
jQuery
!=
null
)
{
el
=
jQuery
(
el
);
if
(
el
.
off
!=
null
)
{
...
...
@@ -460,9 +460,8 @@
event
=
'on'
+
event
;
return
el
.
detachEvent
(
event
,
fn
);
}
};
getInputValue
=
function
(
el
)
{
},
getInputValue
:
function
(
el
)
{
var
o
,
_i
,
_len
,
_results
;
if
(
window
.
jQuery
!=
null
)
{
...
...
@@ -491,6 +490,7 @@
return
el
.
value
;
}
}
}
};
Rivets
.
binders
=
{
...
...
@@ -503,10 +503,10 @@
checked
:
{
publishes
:
true
,
bind
:
function
(
el
)
{
return
this
.
currentListener
=
bindEvent
(
el
,
'change'
,
this
.
publish
);
return
this
.
currentListener
=
Rivets
.
Util
.
bindEvent
(
el
,
'change'
,
this
.
publish
);
},
unbind
:
function
(
el
)
{
return
unbindEvent
(
el
,
'change'
,
this
.
currentListener
);
return
Rivets
.
Util
.
unbindEvent
(
el
,
'change'
,
this
.
currentListener
);
},
routine
:
function
(
el
,
value
)
{
var
_ref
;
...
...
@@ -521,10 +521,10 @@
unchecked
:
{
publishes
:
true
,
bind
:
function
(
el
)
{
return
this
.
currentListener
=
bindEvent
(
el
,
'change'
,
this
.
publish
);
return
this
.
currentListener
=
Rivets
.
Util
.
bindEvent
(
el
,
'change'
,
this
.
publish
);
},
unbind
:
function
(
el
)
{
return
unbindEvent
(
el
,
'change'
,
this
.
currentListener
);
return
Rivets
.
Util
.
unbindEvent
(
el
,
'change'
,
this
.
currentListener
);
},
routine
:
function
(
el
,
value
)
{
var
_ref
;
...
...
@@ -548,10 +548,10 @@
value
:
{
publishes
:
true
,
bind
:
function
(
el
)
{
return
this
.
currentListener
=
bindEvent
(
el
,
'change'
,
this
.
publish
);
return
this
.
currentListener
=
Rivets
.
Util
.
bindEvent
(
el
,
'change'
,
this
.
publish
);
},
unbind
:
function
(
el
)
{
return
unbindEvent
(
el
,
'change'
,
this
.
currentListener
);
return
Rivets
.
Util
.
unbindEvent
(
el
,
'change'
,
this
.
currentListener
);
},
routine
:
function
(
el
,
value
)
{
var
o
,
_i
,
_len
,
_ref
,
_ref1
,
_ref2
,
_results
;
...
...
@@ -588,9 +588,9 @@
"function"
:
true
,
routine
:
function
(
el
,
value
)
{
if
(
this
.
currentListener
)
{
unbindEvent
(
el
,
this
.
args
[
0
],
this
.
currentListener
);
Rivets
.
Util
.
unbindEvent
(
el
,
this
.
args
[
0
],
this
.
currentListener
);
}
return
this
.
currentListener
=
bindEvent
(
el
,
this
.
args
[
0
],
value
,
this
.
model
);
return
this
.
currentListener
=
Rivets
.
Util
.
bindEvent
(
el
,
this
.
args
[
0
],
value
,
this
.
model
);
}
},
"each-*"
:
{
...
...
@@ -676,7 +676,7 @@
Rivets
.
formatters
=
{};
factory
=
function
(
exports
)
{
Rivets
.
factory
=
function
(
exports
)
{
exports
.
binders
=
Rivets
.
binders
;
exports
.
formatters
=
Rivets
.
formatters
;
exports
.
config
=
Rivets
.
config
;
...
...
@@ -707,14 +707,14 @@
};
if
(
typeof
exports
===
'object'
)
{
factory
(
exports
);
Rivets
.
factory
(
exports
);
}
else
if
(
typeof
define
===
'function'
&&
define
.
amd
)
{
define
([
'exports'
],
function
(
exports
)
{
factory
(
this
.
rivets
=
exports
);
Rivets
.
factory
(
this
.
rivets
=
exports
);
return
exports
;
});
}
else
{
factory
(
this
.
rivets
=
{});
Rivets
.
factory
(
this
.
rivets
=
{});
}
}).
call
(
this
);
...
...
dist/rivets.min.js
View file @
421bf22
//
r
ivets.js
// version: 0.5.
0
//
R
ivets.js
// version: 0.5.
1
// author: Michael Richards
// license: MIT
(
function
(){
var
t
,
i
,
e
,
n
,
s
,
r
=
function
(
t
,
i
){
return
function
(){
return
t
.
apply
(
i
,
arguments
)}},
h
=
[].
slice
,
o
=
[].
indexOf
||
function
(
t
){
for
(
var
i
=
0
,
e
=
this
.
length
;
e
>
i
;
i
++
)
if
(
i
in
this
&&
this
[
i
]
===
t
)
return
i
;
return
-
1
};
t
=
{},
String
.
prototype
.
trim
||
(
String
.
prototype
.
trim
=
function
(){
return
this
.
replace
(
/^
\s
+|
\s
+$/g
,
""
)}),
t
.
Binding
=
function
(){
function
t
(
t
,
i
,
e
,
n
,
s
,
h
){
var
o
,
u
,
l
,
a
;
if
(
this
.
view
=
t
,
this
.
el
=
i
,
this
.
type
=
e
,
this
.
key
=
n
,
this
.
keypath
=
s
,
this
.
options
=
null
!=
h
?
h
:{},
this
.
update
=
r
(
this
.
update
,
this
),
this
.
unbind
=
r
(
this
.
unbind
,
this
),
this
.
bind
=
r
(
this
.
bind
,
this
),
this
.
publish
=
r
(
this
.
publish
,
this
),
this
.
sync
=
r
(
this
.
sync
,
this
),
this
.
set
=
r
(
this
.
set
,
this
),
this
.
formattedValue
=
r
(
this
.
formattedValue
,
this
),
!
(
this
.
binder
=
this
.
view
.
binders
[
e
])){
a
=
this
.
view
.
binders
;
for
(
o
in
a
)
l
=
a
[
o
],
"*"
!==
o
&&-
1
!==
o
.
indexOf
(
"*"
)
&&
(
u
=
RegExp
(
"^"
+
o
.
replace
(
"*"
,
".+"
)
+
"$"
),
u
.
test
(
e
)
&&
(
this
.
binder
=
l
,
this
.
args
=
RegExp
(
"^"
+
o
.
replace
(
"*"
,
"(.+)"
)
+
"$"
).
exec
(
e
),
this
.
args
.
shift
()))}
this
.
binder
||
(
this
.
binder
=
this
.
view
.
binders
[
"*"
]),
this
.
binder
instanceof
Function
&&
(
this
.
binder
=
{
routine
:
this
.
binder
}),
this
.
formatters
=
this
.
options
.
formatters
||
[],
this
.
model
=
this
.
view
.
models
[
this
.
key
]}
return
t
.
prototype
.
formattedValue
=
function
(
t
){
var
i
,
e
,
n
,
s
,
r
,
o
,
u
,
l
,
a
;
for
(
o
=
this
.
formatters
,
s
=
0
,
r
=
o
.
length
;
r
>
s
;
s
++
)
e
=
o
[
s
],
i
=
e
.
split
(
/
\s
+/
),
n
=
i
.
shift
(),
e
=
this
.
model
[
n
]
instanceof
Function
?
this
.
model
[
n
]:(
null
!=
(
u
=
this
.
options
)?
null
!=
(
l
=
u
.
bindingOptions
)?
null
!=
(
a
=
l
.
formatters
)?
a
[
n
]:
void
0
:
void
0
:
void
0
)
instanceof
Function
?
this
.
options
.
bindingOptions
.
formatters
[
n
]:
this
.
view
.
formatters
[
n
],(
null
!=
e
?
e
.
read
:
void
0
)
instanceof
Function
?
t
=
e
.
read
.
apply
(
e
,[
t
].
concat
(
h
.
call
(
i
))):
e
instanceof
Function
&&
(
t
=
e
.
apply
(
null
,[
t
].
concat
(
h
.
call
(
i
))));
return
t
},
t
.
prototype
.
set
=
function
(
t
){
var
i
;
return
t
=
t
instanceof
Function
&&!
this
.
binder
[
"function"
]?
this
.
formattedValue
(
t
.
call
(
this
.
model
)):
this
.
formattedValue
(
t
),
null
!=
(
i
=
this
.
binder
.
routine
)?
i
.
call
(
this
,
this
.
el
,
t
):
void
0
},
t
.
prototype
.
sync
=
function
(){
return
this
.
set
(
this
.
options
.
bypass
?
this
.
model
[
this
.
keypath
]:
this
.
view
.
config
.
adapter
.
read
(
this
.
model
,
this
.
keypath
))},
t
.
prototype
.
publish
=
function
(){
var
t
,
i
,
e
,
s
,
r
,
o
,
u
,
l
,
a
;
for
(
s
=
n
(
this
.
el
),
u
=
this
.
formatters
.
slice
(
0
).
reverse
(),
r
=
0
,
o
=
u
.
length
;
o
>
r
;
r
++
)
i
=
u
[
r
],
t
=
i
.
split
(
/
\s
+/
),
e
=
t
.
shift
(),(
null
!=
(
l
=
this
.
view
.
formatters
[
e
])?
l
.
publish
:
void
0
)
&&
(
s
=
(
a
=
this
.
view
.
formatters
[
e
]).
publish
.
apply
(
a
,[
s
].
concat
(
h
.
call
(
t
))));
return
this
.
view
.
config
.
adapter
.
publish
(
this
.
model
,
this
.
keypath
,
s
)},
t
.
prototype
.
bind
=
function
(){
var
t
,
i
,
e
,
n
,
s
,
r
,
h
,
o
,
u
;
if
(
null
!=
(
r
=
this
.
binder
.
bind
)
&&
r
.
call
(
this
,
this
.
el
),
this
.
options
.
bypass
?
this
.
sync
():(
this
.
view
.
config
.
adapter
.
subscribe
(
this
.
model
,
this
.
keypath
,
this
.
sync
),
this
.
view
.
config
.
preloadData
&&
this
.
sync
()),
null
!=
(
h
=
this
.
options
.
dependencies
)?
h
.
length
:
void
0
){
for
(
o
=
this
.
options
.
dependencies
,
u
=
[],
n
=
0
,
s
=
o
.
length
;
s
>
n
;
n
++
)
t
=
o
[
n
],
/^
\.
/
.
test
(
t
)?(
e
=
this
.
model
,
i
=
t
.
substr
(
1
)):(
t
=
t
.
split
(
"."
),
e
=
this
.
view
.
models
[
t
.
shift
()],
i
=
t
.
join
(
"."
)),
u
.
push
(
this
.
view
.
config
.
adapter
.
subscribe
(
e
,
i
,
this
.
sync
));
return
u
}},
t
.
prototype
.
unbind
=
function
(){
var
t
,
i
,
e
,
n
,
s
,
r
,
h
,
o
,
u
;
if
(
null
!=
(
r
=
this
.
binder
.
unbind
)
&&
r
.
call
(
this
,
this
.
el
),
this
.
options
.
bypass
||
this
.
view
.
config
.
adapter
.
unsubscribe
(
this
.
model
,
this
.
keypath
,
this
.
sync
),
null
!=
(
h
=
this
.
options
.
dependencies
)?
h
.
length
:
void
0
){
for
(
o
=
this
.
options
.
dependencies
,
u
=
[],
n
=
0
,
s
=
o
.
length
;
s
>
n
;
n
++
)
t
=
o
[
n
],
/^
\.
/
.
test
(
t
)?(
e
=
this
.
model
,
i
=
t
.
substr
(
1
)):(
t
=
t
.
split
(
"."
),
e
=
this
.
view
.
models
[
t
.
shift
()],
i
=
t
.
join
(
"."
)),
u
.
push
(
this
.
view
.
config
.
adapter
.
unsubscribe
(
e
,
i
,
this
.
sync
));
return
u
}},
t
.
prototype
.
update
=
function
(){
return
this
.
unbind
(),
this
.
model
=
this
.
view
.
models
[
this
.
key
],
this
.
bind
()},
t
}(),
t
.
View
=
function
(){
function
i
(
i
,
e
,
n
){
var
s
,
h
,
o
,
u
,
l
,
a
,
d
,
c
,
f
,
p
;
for
(
this
.
els
=
i
,
this
.
models
=
e
,
this
.
options
=
null
!=
n
?
n
:{},
this
.
update
=
r
(
this
.
update
,
this
),
this
.
publish
=
r
(
this
.
publish
,
this
),
this
.
sync
=
r
(
this
.
sync
,
this
),
this
.
unbind
=
r
(
this
.
unbind
,
this
),
this
.
bind
=
r
(
this
.
bind
,
this
),
this
.
select
=
r
(
this
.
select
,
this
),
this
.
build
=
r
(
this
.
build
,
this
),
this
.
bindingRegExp
=
r
(
this
.
bindingRegExp
,
this
),
this
.
els
.
jquery
||
this
.
els
instanceof
Array
||
(
this
.
els
=
[
this
.
els
]),
d
=
[
"config"
,
"binders"
,
"formatters"
],
l
=
0
,
a
=
d
.
length
;
a
>
l
;
l
++
){
if
(
h
=
d
[
l
],
this
[
h
]
=
{},
this
.
options
[
h
]){
c
=
this
.
options
[
h
];
for
(
s
in
c
)
o
=
c
[
s
],
this
[
h
][
s
]
=
o
}
f
=
t
[
h
];
for
(
s
in
f
)
o
=
f
[
s
],
null
==
(
p
=
(
u
=
this
[
h
])[
s
])
&&
(
u
[
s
]
=
o
)}
this
.
build
()}
return
i
.
prototype
.
bindingRegExp
=
function
(){
var
t
;
return
t
=
this
.
config
.
prefix
,
t
?
RegExp
(
"^data-"
+
t
+
"-"
):
/^data-/
},
i
.
prototype
.
build
=
function
(){
var
i
,
e
,
n
,
s
,
r
,
h
,
u
,
l
,
a
,
d
,
c
,
f
=
this
;
for
(
this
.
bindings
=
[],
r
=
[],
i
=
this
.
bindingRegExp
(),
s
=
function
(
e
){
var
n
,
s
,
h
,
u
,
l
,
a
,
d
,
c
,
p
,
b
,
v
,
g
,
y
,
m
,
w
,
x
,
k
,
E
,
j
,
L
,
N
,
Q
,
R
,
V
,
O
,
B
,
F
,
T
;
if
(
0
>
o
.
call
(
r
,
e
)){
for
(
O
=
e
.
attributes
,
j
=
0
,
Q
=
O
.
length
;
Q
>
j
;
j
++
)
if
(
n
=
O
[
j
],
i
.
test
(
n
.
name
)){
if
(
k
=
n
.
name
.
replace
(
i
,
""
),
!
(
h
=
f
.
binders
[
k
])){
B
=
f
.
binders
;
for
(
d
in
B
)
E
=
B
[
d
],
"*"
!==
d
&&-
1
!==
d
.
indexOf
(
"*"
)
&&
(
w
=
RegExp
(
"^"
+
d
.
replace
(
"*"
,
".+"
)
+
"$"
),
w
.
test
(
k
)
&&
(
h
=
E
))}
if
(
h
||
(
h
=
f
.
binders
[
"*"
]),
h
.
block
){
for
(
F
=
e
.
getElementsByTagName
(
"*"
),
L
=
0
,
R
=
F
.
length
;
R
>
L
;
L
++
)
b
=
F
[
L
],
r
.
push
(
b
);
s
=
[
n
]}}
for
(
T
=
s
||
e
.
attributes
,
N
=
0
,
V
=
T
.
length
;
V
>
N
;
N
++
)
n
=
T
[
N
],
i
.
test
(
n
.
name
)
&&
(
v
=
{},
k
=
n
.
name
.
replace
(
i
,
""
),
m
=
function
(){
var
t
,
i
,
e
,
s
;
for
(
e
=
n
.
value
.
split
(
"|"
),
s
=
[],
t
=
0
,
i
=
e
.
length
;
i
>
t
;
t
++
)
y
=
e
[
t
],
s
.
push
(
y
.
trim
());
return
s
}(),
u
=
function
(){
var
t
,
i
,
e
,
n
;
for
(
e
=
m
.
shift
().
split
(
"<"
),
n
=
[],
t
=
0
,
i
=
e
.
length
;
i
>
t
;
t
++
)
l
=
e
[
t
],
n
.
push
(
l
.
trim
());
return
n
}(),
g
=
u
.
shift
(),
x
=
g
.
split
(
/
\.
|:/
),
v
.
formatters
=
m
,
v
.
bypass
=-
1
!==
g
.
indexOf
(
":"
),
x
[
0
]?
c
=
x
.
shift
():(
c
=
null
,
x
.
shift
()),
p
=
x
.
join
(
"."
),
null
!=
f
.
models
[
c
]
&&
((
a
=
u
.
shift
())
&&
(
v
.
dependencies
=
a
.
split
(
/
\s
+/
)),
f
.
bindings
.
push
(
new
t
.
Binding
(
f
,
e
,
k
,
c
,
p
,
v
))));
s
&&
(
s
=
null
)}},
d
=
this
.
els
,
h
=
0
,
l
=
d
.
length
;
l
>
h
;
h
++
)
for
(
e
=
d
[
h
],
s
(
e
),
c
=
e
.
getElementsByTagName
(
"*"
),
u
=
0
,
a
=
c
.
length
;
a
>
u
;
u
++
)
n
=
c
[
u
],
null
!=
n
.
attributes
&&
s
(
n
)},
i
.
prototype
.
select
=
function
(
t
){
var
i
,
e
,
n
,
s
,
r
;
for
(
s
=
this
.
bindings
,
r
=
[],
e
=
0
,
n
=
s
.
length
;
n
>
e
;
e
++
)
i
=
s
[
e
],
t
(
i
)
&&
r
.
push
(
i
);
return
r
},
i
.
prototype
.
bind
=
function
(){
var
t
,
i
,
e
,
n
,
s
;
for
(
n
=
this
.
bindings
,
s
=
[],
i
=
0
,
e
=
n
.
length
;
e
>
i
;
i
++
)
t
=
n
[
i
],
s
.
push
(
t
.
bind
());
return
s
},
i
.
prototype
.
unbind
=
function
(){
var
t
,
i
,
e
,
n
,
s
;
for
(
n
=
this
.
bindings
,
s
=
[],
i
=
0
,
e
=
n
.
length
;
e
>
i
;
i
++
)
t
=
n
[
i
],
s
.
push
(
t
.
unbind
());
return
s
},
i
.
prototype
.
sync
=
function
(){
var
t
,
i
,
e
,
n
,
s
;
for
(
n
=
this
.
bindings
,
s
=
[],
i
=
0
,
e
=
n
.
length
;
e
>
i
;
i
++
)
t
=
n
[
i
],
s
.
push
(
t
.
sync
());
return
s
},
i
.
prototype
.
publish
=
function
(){
var
t
,
i
,
e
,
n
,
s
;
for
(
n
=
this
.
select
(
function
(
t
){
return
t
.
binder
.
publishes
}),
s
=
[],
i
=
0
,
e
=
n
.
length
;
e
>
i
;
i
++
)
t
=
n
[
i
],
s
.
push
(
t
.
publish
());
return
s
},
i
.
prototype
.
update
=
function
(
t
){
var
i
,
e
,
n
,
s
;
null
==
t
&&
(
t
=
{}),
s
=
[];
for
(
e
in
t
)
n
=
t
[
e
],
this
.
models
[
e
]
=
n
,
s
.
push
(
function
(){
var
t
,
n
,
s
,
r
;
for
(
s
=
this
.
select
(
function
(
t
){
return
t
.
key
===
e
}),
r
=
[],
t
=
0
,
n
=
s
.
length
;
n
>
t
;
t
++
)
i
=
s
[
t
],
r
.
push
(
i
.
update
());
return
r
}.
call
(
this
));
return
s
},
i
}(),
i
=
function
(
t
,
i
,
e
,
n
){
var
s
;
return
s
=
function
(
t
){
return
e
.
call
(
n
,
t
)},
null
!=
window
.
jQuery
?(
t
=
jQuery
(
t
),
null
!=
t
.
on
?
t
.
on
(
i
,
s
):
t
.
bind
(
i
,
s
)):
null
!=
window
.
addEventListener
?
t
.
addEventListener
(
i
,
s
,
!
1
):(
i
=
"on"
+
i
,
t
.
attachEvent
(
i
,
s
)),
s
},
s
=
function
(
t
,
i
,
e
){
return
null
!=
window
.
jQuery
?(
t
=
jQuery
(
t
),
null
!=
t
.
off
?
t
.
off
(
i
,
e
):
t
.
unbind
(
i
,
e
)):
window
.
removeEventListener
?
t
.
removeEventListener
(
i
,
e
,
!
1
):(
i
=
"on"
+
i
,
t
.
detachEvent
(
i
,
e
))},
n
=
function
(
t
){
var
i
,
e
,
n
,
s
;
if
(
null
!=
window
.
jQuery
)
switch
(
t
=
jQuery
(
t
),
t
[
0
].
type
){
case
"checkbox"
:
return
t
.
is
(
":checked"
);
default
:
return
t
.
val
()}
else
switch
(
t
.
type
){
case
"checkbox"
:
return
t
.
checked
;
case
"select-multiple"
:
for
(
s
=
[],
e
=
0
,
n
=
t
.
length
;
n
>
e
;
e
++
)
i
=
t
[
e
],
i
.
selected
&&
s
.
push
(
i
.
value
);
return
s
;
default
:
return
t
.
value
}},
t
.
binders
=
{
enabled
:
function
(
t
,
i
){
return
t
.
disabled
=!
i
},
disabled
:
function
(
t
,
i
){
return
t
.
disabled
=!!
i
},
checked
:{
publishes
:
!
0
,
bind
:
function
(
t
){
return
this
.
currentListener
=
i
(
t
,
"change"
,
this
.
publish
)},
unbind
:
function
(
t
){
return
s
(
t
,
"change"
,
this
.
currentListener
)},
routine
:
function
(
t
,
i
){
var
e
;
return
t
.
checked
=
"radio"
===
t
.
type
?(
null
!=
(
e
=
t
.
value
)?
""
+
e
:
void
0
)
===
(
null
!=
i
?
""
+
i
:
void
0
):
!!
i
}},
unchecked
:{
publishes
:
!
0
,
bind
:
function
(
t
){
return
this
.
currentListener
=
i
(
t
,
"change"
,
this
.
publish
)},
unbind
:
function
(
t
){
return
s
(
t
,
"change"
,
this
.
currentListener
)},
routine
:
function
(
t
,
i
){
var
e
;
return
t
.
checked
=
"radio"
===
t
.
type
?(
null
!=
(
e
=
t
.
value
)?
""
+
e
:
void
0
)
!==
(
null
!=
i
?
""
+
i
:
void
0
):
!
i
}},
show
:
function
(
t
,
i
){
return
t
.
style
.
display
=
i
?
""
:
"none"
},
hide
:
function
(
t
,
i
){
return
t
.
style
.
display
=
i
?
"none"
:
""
},
html
:
function
(
t
,
i
){
return
t
.
innerHTML
=
null
!=
i
?
i
:
""
},
value
:{
publishes
:
!
0
,
bind
:
function
(
t
){
return
this
.
currentListener
=
i
(
t
,
"change"
,
this
.
publish
)},
unbind
:
function
(
t
){
return
s
(
t
,
"change"
,
this
.
currentListener
)},
routine
:
function
(
t
,
i
){
var
e
,
n
,
s
,
r
,
h
,
u
,
l
;
if
(
null
!=
window
.
jQuery
){
if
(
t
=
jQuery
(
t
),(
null
!=
i
?
""
+
i
:
void
0
)
!==
(
null
!=
(
r
=
t
.
val
())?
""
+
r
:
void
0
))
return
t
.
val
(
null
!=
i
?
i
:
""
)}
else
if
(
"select-multiple"
===
t
.
type
){
if
(
null
!=
i
){
for
(
l
=
[],
n
=
0
,
s
=
t
.
length
;
s
>
n
;
n
++
)
e
=
t
[
n
],
l
.
push
(
e
.
selected
=
(
h
=
e
.
value
,
o
.
call
(
i
,
h
)
>=
0
));
return
l
}}
else
if
((
null
!=
i
?
""
+
i
:
void
0
)
!==
(
null
!=
(
u
=
t
.
value
)?
""
+
u
:
void
0
))
return
t
.
value
=
null
!=
i
?
i
:
""
}},
text
:
function
(
t
,
i
){
return
null
!=
t
.
innerText
?
t
.
innerText
=
null
!=
i
?
i
:
""
:
t
.
textContent
=
null
!=
i
?
i
:
""
},
"on-*"
:{
"function"
:
!
0
,
routine
:
function
(
t
,
e
){
return
this
.
currentListener
&&
s
(
t
,
this
.
args
[
0
],
this
.
currentListener
),
this
.
currentListener
=
i
(
t
,
this
.
args
[
0
],
e
,
this
.
model
)}},
"each-*"
:{
block
:
!
0
,
bind
:
function
(
t
){
return
t
.
removeAttribute
([
"data"
,
this
.
view
.
config
.
prefix
,
this
.
type
].
join
(
"-"
).
replace
(
"--"
,
"-"
))},
unbind
:
function
(){
var
t
,
i
,
e
,
n
,
s
;
if
(
null
!=
this
.
iterated
){
for
(
n
=
this
.
iterated
,
s
=
[],
i
=
0
,
e
=
n
.
length
;
e
>
i
;
i
++
)
t
=
n
[
i
],
s
.
push
(
t
.
unbind
());
return
s
}},
routine
:
function
(
i
,
e
){
var
n
,
s
,
r
,
h
,
o
,
u
,
l
,
a
,
d
,
c
,
f
,
p
,
b
,
v
,
g
,
y
,
m
,
w
,
x
;
if
(
null
!=
this
.
iterated
)
for
(
g
=
this
.
iterated
,
d
=
0
,
p
=
g
.
length
;
p
>
d
;
d
++
)
for
(
a
=
g
[
d
],
a
.
unbind
(),
y
=
a
.
els
,
c
=
0
,
b
=
y
.
length
;
b
>
c
;
c
++
)
s
=
y
[
c
],
s
.
parentNode
.
removeChild
(
s
);
else
this
.
marker
=
document
.
createComment
(
" rivets: "
+
this
.
type
+
" "
),
i
.
parentNode
.
insertBefore
(
this
.
marker
,
i
),
i
.
parentNode
.
removeChild
(
i
);
if
(
this
.
iterated
=
[],
e
){
for
(
x
=
[],
f
=
0
,
v
=
e
.
length
;
v
>
f
;
f
++
){
r
=
e
[
f
],
n
=
{},
m
=
this
.
view
.
models
;
for
(
u
in
m
)
o
=
m
[
u
],
n
[
u
]
=
o
;
n
[
this
.
args
[
0
]]
=
r
,
h
=
i
.
cloneNode
(
!
0
),
l
=
this
.
iterated
.
length
?
this
.
iterated
[
this
.
iterated
.
length
-
1
].
els
[
0
]:
this
.
marker
,
this
.
marker
.
parentNode
.
insertBefore
(
h
,
null
!=
(
w
=
l
.
nextSibling
)?
w
:
null
),
a
=
new
t
.
View
(
h
,
n
,
this
.
view
.
options
),
a
.
bind
(),
x
.
push
(
this
.
iterated
.
push
(
a
))}
return
x
}}},
"class-*"
:
function
(
t
,
i
){
var
e
;
return
e
=
" "
+
t
.
className
+
" "
,
!
i
==
(
-
1
!==
e
.
indexOf
(
" "
+
this
.
args
[
0
]
+
" "
))?
t
.
className
=
i
?
""
+
t
.
className
+
" "
+
this
.
args
[
0
]:
e
.
replace
(
" "
+
this
.
args
[
0
]
+
" "
,
" "
).
trim
():
void
0
},
"*"
:
function
(
t
,
i
){
return
i
?
t
.
setAttribute
(
this
.
type
,
i
):
t
.
removeAttribute
(
this
.
type
)}},
t
.
config
=
{
preloadData
:
!
0
},
t
.
formatters
=
{},
e
=
function
(
i
){
return
i
.
binders
=
t
.
binders
,
i
.
formatters
=
t
.
formatters
,
i
.
config
=
t
.
config
,
i
.
configure
=
function
(
i
){
var
e
,
n
;
null
==
i
&&
(
i
=
{});
for
(
e
in
i
)
n
=
i
[
e
],
t
.
config
[
e
]
=
n
},
i
.
bind
=
function
(
i
,
e
,
n
){
var
s
;
return
null
==
e
&&
(
e
=
{}),
null
==
n
&&
(
n
=
{}),
s
=
new
t
.
View
(
i
,
e
,
n
),
s
.
bind
(),
s
}},
"object"
==
typeof
exports
?
e
(
exports
):
"function"
==
typeof
define
&&
define
.
amd
?
define
([
"exports"
],
function
(
t
){
return
e
(
this
.
rivets
=
t
),
t
}):
e
(
this
.
rivets
=
{})}).
call
(
this
);
\ No newline at end of file
(
function
(){
var
t
,
i
=
function
(
t
,
i
){
return
function
(){
return
t
.
apply
(
i
,
arguments
)}},
e
=
[].
slice
,
n
=
[].
indexOf
||
function
(
t
){
for
(
var
i
=
0
,
e
=
this
.
length
;
e
>
i
;
i
++
)
if
(
i
in
this
&&
this
[
i
]
===
t
)
return
i
;
return
-
1
};
t
=
{},
String
.
prototype
.
trim
||
(
String
.
prototype
.
trim
=
function
(){
return
this
.
replace
(
/^
\s
+|
\s
+$/g
,
""
)}),
t
.
Binding
=
function
(){
function
n
(
t
,
e
,
n
,
s
,
r
,
h
){
var
u
,
o
,
l
,
a
;
if
(
this
.
view
=
t
,
this
.
el
=
e
,
this
.
type
=
n
,
this
.
key
=
s
,
this
.
keypath
=
r
,
this
.
options
=
null
!=
h
?
h
:{},
this
.
update
=
i
(
this
.
update
,
this
),
this
.
unbind
=
i
(
this
.
unbind
,
this
),
this
.
bind
=
i
(
this
.
bind
,
this
),
this
.
publish
=
i
(
this
.
publish
,
this
),
this
.
sync
=
i
(
this
.
sync
,
this
),
this
.
set
=
i
(
this
.
set
,
this
),
this
.
formattedValue
=
i
(
this
.
formattedValue
,
this
),
!
(
this
.
binder
=
this
.
view
.
binders
[
n
])){
a
=
this
.
view
.
binders
;
for
(
u
in
a
)
l
=
a
[
u
],
"*"
!==
u
&&-
1
!==
u
.
indexOf
(
"*"
)
&&
(
o
=
RegExp
(
"^"
+
u
.
replace
(
"*"
,
".+"
)
+
"$"
),
o
.
test
(
n
)
&&
(
this
.
binder
=
l
,
this
.
args
=
RegExp
(
"^"
+
u
.
replace
(
"*"
,
"(.+)"
)
+
"$"
).
exec
(
n
),
this
.
args
.
shift
()))}
this
.
binder
||
(
this
.
binder
=
this
.
view
.
binders
[
"*"
]),
this
.
binder
instanceof
Function
&&
(
this
.
binder
=
{
routine
:
this
.
binder
}),
this
.
formatters
=
this
.
options
.
formatters
||
[],
this
.
model
=
this
.
view
.
models
[
this
.
key
]}
return
n
.
prototype
.
formattedValue
=
function
(
t
){
var
i
,
n
,
s
,
r
,
h
,
u
;
for
(
u
=
this
.
formatters
,
r
=
0
,
h
=
u
.
length
;
h
>
r
;
r
++
)
n
=
u
[
r
],
i
=
n
.
split
(
/
\s
+/
),
s
=
i
.
shift
(),
n
=
this
.
model
[
s
]
instanceof
Function
?
this
.
model
[
s
]:
this
.
view
.
formatters
[
s
],(
null
!=
n
?
n
.
read
:
void
0
)
instanceof
Function
?
t
=
n
.
read
.
apply
(
n
,[
t
].
concat
(
e
.
call
(
i
))):
n
instanceof
Function
&&
(
t
=
n
.
apply
(
null
,[
t
].
concat
(
e
.
call
(
i
))));
return
t
},
n
.
prototype
.
set
=
function
(
t
){
var
i
;
return
t
=
t
instanceof
Function
&&!
this
.
binder
[
"function"
]?
this
.
formattedValue
(
t
.
call
(
this
.
model
)):
this
.
formattedValue
(
t
),
null
!=
(
i
=
this
.
binder
.
routine
)?
i
.
call
(
this
,
this
.
el
,
t
):
void
0
},
n
.
prototype
.
sync
=
function
(){
return
this
.
set
(
this
.
options
.
bypass
?
this
.
model
[
this
.
keypath
]:
this
.
view
.
config
.
adapter
.
read
(
this
.
model
,
this
.
keypath
))},
n
.
prototype
.
publish
=
function
(){
var
i
,
n
,
s
,
r
,
h
,
u
,
o
,
l
,
a
;
for
(
r
=
t
.
Util
.
getInputValue
(
this
.
el
),
o
=
this
.
formatters
.
slice
(
0
).
reverse
(),
h
=
0
,
u
=
o
.
length
;
u
>
h
;
h
++
)
n
=
o
[
h
],
i
=
n
.
split
(
/
\s
+/
),
s
=
i
.
shift
(),(
null
!=
(
l
=
this
.
view
.
formatters
[
s
])?
l
.
publish
:
void
0
)
&&
(
r
=
(
a
=
this
.
view
.
formatters
[
s
]).
publish
.
apply
(
a
,[
r
].
concat
(
e
.
call
(
i
))));
return
this
.
view
.
config
.
adapter
.
publish
(
this
.
model
,
this
.
keypath
,
r
)},
n
.
prototype
.
bind
=
function
(){
var
t
,
i
,
e
,
n
,
s
,
r
,
h
,
u
,
o
;
if
(
null
!=
(
r
=
this
.
binder
.
bind
)
&&
r
.
call
(
this
,
this
.
el
),
this
.
options
.
bypass
?
this
.
sync
():(
this
.
view
.
config
.
adapter
.
subscribe
(
this
.
model
,
this
.
keypath
,
this
.
sync
),
this
.
view
.
config
.
preloadData
&&
this
.
sync
()),
null
!=
(
h
=
this
.
options
.
dependencies
)?
h
.
length
:
void
0
){
for
(
u
=
this
.
options
.
dependencies
,
o
=
[],
n
=
0
,
s
=
u
.
length
;
s
>
n
;
n
++
)
t
=
u
[
n
],
/^
\.
/
.
test
(
t
)?(
e
=
this
.
model
,
i
=
t
.
substr
(
1
)):(
t
=
t
.
split
(
"."
),
e
=
this
.
view
.
models
[
t
.
shift
()],
i
=
t
.
join
(
"."
)),
o
.
push
(
this
.
view
.
config
.
adapter
.
subscribe
(
e
,
i
,
this
.
sync
));
return
o
}},
n
.
prototype
.
unbind
=
function
(){
var
t
,
i
,
e
,
n
,
s
,
r
,
h
,
u
,
o
;
if
(
null
!=
(
r
=
this
.
binder
.
unbind
)
&&
r
.
call
(
this
,
this
.
el
),
this
.
options
.
bypass
||
this
.
view
.
config
.
adapter
.
unsubscribe
(
this
.
model
,
this
.
keypath
,
this
.
sync
),
null
!=
(
h
=
this
.
options
.
dependencies
)?
h
.
length
:
void
0
){
for
(
u
=
this
.
options
.
dependencies
,
o
=
[],
n
=
0
,
s
=
u
.
length
;
s
>
n
;
n
++
)
t
=
u
[
n
],
/^
\.
/
.
test
(
t
)?(
e
=
this
.
model
,
i
=
t
.
substr
(
1
)):(
t
=
t
.
split
(
"."
),
e
=
this
.
view
.
models
[
t
.
shift
()],
i
=
t
.
join
(
"."
)),
o
.
push
(
this
.
view
.
config
.
adapter
.
unsubscribe
(
e
,
i
,
this
.
sync
));
return
o
}},
n
.
prototype
.
update
=
function
(){
return
this
.
unbind
(),
this
.
model
=
this
.
view
.
models
[
this
.
key
],
this
.
bind
()},
n
}(),
t
.
View
=
function
(){
function
e
(
e
,
n
,
s
){
var
r
,
h
,
u
,
o
,
l
,
a
,
d
,
c
,
f
,
p
;
for
(
this
.
els
=
e
,
this
.
models
=
n
,
this
.
options
=
null
!=
s
?
s
:{},
this
.
update
=
i
(
this
.
update
,
this
),
this
.
publish
=
i
(
this
.
publish
,
this
),
this
.
sync
=
i
(
this
.
sync
,
this
),
this
.
unbind
=
i
(
this
.
unbind
,
this
),
this
.
bind
=
i
(
this
.
bind
,
this
),
this
.
select
=
i
(
this
.
select
,
this
),
this
.
build
=
i
(
this
.
build
,
this
),
this
.
bindingRegExp
=
i
(
this
.
bindingRegExp
,
this
),
this
.
els
.
jquery
||
this
.
els
instanceof
Array
||
(
this
.
els
=
[
this
.
els
]),
d
=
[
"config"
,
"binders"
,
"formatters"
],
l
=
0
,
a
=
d
.
length
;
a
>
l
;
l
++
){
if
(
h
=
d
[
l
],
this
[
h
]
=
{},
this
.
options
[
h
]){
c
=
this
.
options
[
h
];
for
(
r
in
c
)
u
=
c
[
r
],
this
[
h
][
r
]
=
u
}
f
=
t
[
h
];
for
(
r
in
f
)
u
=
f
[
r
],
null
==
(
p
=
(
o
=
this
[
h
])[
r
])
&&
(
o
[
r
]
=
u
)}
this
.
build
()}
return
e
.
prototype
.
bindingRegExp
=
function
(){
var
t
;
return
t
=
this
.
config
.
prefix
,
t
?
RegExp
(
"^data-"
+
t
+
"-"
):
/^data-/
},
e
.
prototype
.
build
=
function
(){
var
i
,
e
,
s
,
r
,
h
,
u
,
o
,
l
,
a
,
d
,
c
,
f
=
this
;
for
(
this
.
bindings
=
[],
h
=
[],
i
=
this
.
bindingRegExp
(),
r
=
function
(
e
){
var
s
,
r
,
u
,
o
,
l
,
a
,
d
,
c
,
p
,
b
,
v
,
g
,
y
,
m
,
w
,
x
,
E
,
k
,
j
,
L
,
N
,
U
,
V
,
Q
,
R
,
B
,
F
,
O
;
if
(
0
>
n
.
call
(
h
,
e
)){
for
(
R
=
e
.
attributes
,
j
=
0
,
U
=
R
.
length
;
U
>
j
;
j
++
)
if
(
s
=
R
[
j
],
i
.
test
(
s
.
name
)){
if
(
E
=
s
.
name
.
replace
(
i
,
""
),
!
(
u
=
f
.
binders
[
E
])){
B
=
f
.
binders
;
for
(
d
in
B
)
k
=
B
[
d
],
"*"
!==
d
&&-
1
!==
d
.
indexOf
(
"*"
)
&&
(
w
=
RegExp
(
"^"
+
d
.
replace
(
"*"
,
".+"
)
+
"$"
),
w
.
test
(
E
)
&&
(
u
=
k
))}
if
(
u
||
(
u
=
f
.
binders
[
"*"
]),
u
.
block
){
for
(
F
=
e
.
getElementsByTagName
(
"*"
),
L
=
0
,
V
=
F
.
length
;
V
>
L
;
L
++
)
b
=
F
[
L
],
h
.
push
(
b
);
r
=
[
s
]}}
for
(
O
=
r
||
e
.
attributes
,
N
=
0
,
Q
=
O
.
length
;
Q
>
N
;
N
++
)
s
=
O
[
N
],
i
.
test
(
s
.
name
)
&&
(
v
=
{},
E
=
s
.
name
.
replace
(
i
,
""
),
m
=
function
(){
var
t
,
i
,
e
,
n
;
for
(
e
=
s
.
value
.
split
(
"|"
),
n
=
[],
t
=
0
,
i
=
e
.
length
;
i
>
t
;
t
++
)
y
=
e
[
t
],
n
.
push
(
y
.
trim
());
return
n
}(),
o
=
function
(){
var
t
,
i
,
e
,
n
;
for
(
e
=
m
.
shift
().
split
(
"<"
),
n
=
[],
t
=
0
,
i
=
e
.
length
;
i
>
t
;
t
++
)
l
=
e
[
t
],
n
.
push
(
l
.
trim
());
return
n
}(),
g
=
o
.
shift
(),
x
=
g
.
split
(
/
\.
|:/
),
v
.
formatters
=
m
,
v
.
bypass
=-
1
!==
g
.
indexOf
(
":"
),
x
[
0
]?
c
=
x
.
shift
():(
c
=
null
,
x
.
shift
()),
p
=
x
.
join
(
"."
),
null
!=
f
.
models
[
c
]
&&
((
a
=
o
.
shift
())
&&
(
v
.
dependencies
=
a
.
split
(
/
\s
+/
)),
f
.
bindings
.
push
(
new
t
.
Binding
(
f
,
e
,
E
,
c
,
p
,
v
))));
r
&&
(
r
=
null
)}},
d
=
this
.
els
,
u
=
0
,
l
=
d
.
length
;
l
>
u
;
u
++
)
for
(
e
=
d
[
u
],
r
(
e
),
c
=
e
.
getElementsByTagName
(
"*"
),
o
=
0
,
a
=
c
.
length
;
a
>
o
;
o
++
)
s
=
c
[
o
],
null
!=
s
.
attributes
&&
r
(
s
)},
e
.
prototype
.
select
=
function
(
t
){
var
i
,
e
,
n
,
s
,
r
;
for
(
s
=
this
.
bindings
,
r
=
[],
e
=
0
,
n
=
s
.
length
;
n
>
e
;
e
++
)
i
=
s
[
e
],
t
(
i
)
&&
r
.
push
(
i
);
return
r
},
e
.
prototype
.
bind
=
function
(){
var
t
,
i
,
e
,
n
,
s
;
for
(
n
=
this
.
bindings
,
s
=
[],
i
=
0
,
e
=
n
.
length
;
e
>
i
;
i
++
)
t
=
n
[
i
],
s
.
push
(
t
.
bind
());
return
s
},
e
.
prototype
.
unbind
=
function
(){
var
t
,
i
,
e
,
n
,
s
;
for
(
n
=
this
.
bindings
,
s
=
[],
i
=
0
,
e
=
n
.
length
;
e
>
i
;
i
++
)
t
=
n
[
i
],
s
.
push
(
t
.
unbind
());
return
s
},
e
.
prototype
.
sync
=
function
(){
var
t
,
i
,
e
,
n
,
s
;
for
(
n
=
this
.
bindings
,
s
=
[],
i
=
0
,
e
=
n
.
length
;
e
>
i
;
i
++
)
t
=
n
[
i
],
s
.
push
(
t
.
sync
());
return
s
},
e
.
prototype
.
publish
=
function
(){
var
t
,
i
,
e
,
n
,
s
;
for
(
n
=
this
.
select
(
function
(
t
){
return
t
.
binder
.
publishes
}),
s
=
[],
i
=
0
,
e
=
n
.
length
;
e
>
i
;
i
++
)
t
=
n
[
i
],
s
.
push
(
t
.
publish
());
return
s
},
e
.
prototype
.
update
=
function
(
t
){
var
i
,
e
,
n
,
s
;
null
==
t
&&
(
t
=
{}),
s
=
[];
for
(
e
in
t
)
n
=
t
[
e
],
this
.
models
[
e
]
=
n
,
s
.
push
(
function
(){
var
t
,
n
,
s
,
r
;
for
(
s
=
this
.
select
(
function
(
t
){
return
t
.
key
===
e
}),
r
=
[],
t
=
0
,
n
=
s
.
length
;
n
>
t
;
t
++
)
i
=
s
[
t
],
r
.
push
(
i
.
update
());
return
r
}.
call
(
this
));
return
s
},
e
}(),
t
.
Util
=
{
bindEvent
:
function
(
t
,
i
,
e
,
n
){
var
s
;
return
s
=
function
(
t
){
return
e
.
call
(
n
,
t
)},
null
!=
window
.
jQuery
?(
t
=
jQuery
(
t
),
null
!=
t
.
on
?
t
.
on
(
i
,
s
):
t
.
bind
(
i
,
s
)):
null
!=
window
.
addEventListener
?
t
.
addEventListener
(
i
,
s
,
!
1
):(
i
=
"on"
+
i
,
t
.
attachEvent
(
i
,
s
)),
s
},
unbindEvent
:
function
(
t
,
i
,
e
){
return
null
!=
window
.
jQuery
?(
t
=
jQuery
(
t
),
null
!=
t
.
off
?
t
.
off
(
i
,
e
):
t
.
unbind
(
i
,
e
)):
window
.
removeEventListener
?
t
.
removeEventListener
(
i
,
e
,
!
1
):(
i
=
"on"
+
i
,
t
.
detachEvent
(
i
,
e
))},
getInputValue
:
function
(
t
){
var
i
,
e
,
n
,
s
;
if
(
null
!=
window
.
jQuery
)
switch
(
t
=
jQuery
(
t
),
t
[
0
].
type
){
case
"checkbox"
:
return
t
.
is
(
":checked"
);
default
:
return
t
.
val
()}
else
switch
(
t
.
type
){
case
"checkbox"
:
return
t
.
checked
;
case
"select-multiple"
:
for
(
s
=
[],
e
=
0
,
n
=
t
.
length
;
n
>
e
;
e
++
)
i
=
t
[
e
],
i
.
selected
&&
s
.
push
(
i
.
value
);
return
s
;
default
:
return
t
.
value
}}},
t
.
binders
=
{
enabled
:
function
(
t
,
i
){
return
t
.
disabled
=!
i
},
disabled
:
function
(
t
,
i
){
return
t
.
disabled
=!!
i
},
checked
:{
publishes
:
!
0
,
bind
:
function
(
i
){
return
this
.
currentListener
=
t
.
Util
.
bindEvent
(
i
,
"change"
,
this
.
publish
)},
unbind
:
function
(
i
){
return
t
.
Util
.
unbindEvent
(
i
,
"change"
,
this
.
currentListener
)},
routine
:
function
(
t
,
i
){
var
e
;
return
t
.
checked
=
"radio"
===
t
.
type
?(
null
!=
(
e
=
t
.
value
)?
""
+
e
:
void
0
)
===
(
null
!=
i
?
""
+
i
:
void
0
):
!!
i
}},
unchecked
:{
publishes
:
!
0
,
bind
:
function
(
i
){
return
this
.
currentListener
=
t
.
Util
.
bindEvent
(
i
,
"change"
,
this
.
publish
)},
unbind
:
function
(
i
){
return
t
.
Util
.
unbindEvent
(
i
,
"change"
,
this
.
currentListener
)},
routine
:
function
(
t
,
i
){
var
e
;
return
t
.
checked
=
"radio"
===
t
.
type
?(
null
!=
(
e
=
t
.
value
)?
""
+
e
:
void
0
)
!==
(
null
!=
i
?
""
+
i
:
void
0
):
!
i
}},
show
:
function
(
t
,
i
){
return
t
.
style
.
display
=
i
?
""
:
"none"
},
hide
:
function
(
t
,
i
){
return
t
.
style
.
display
=
i
?
"none"
:
""
},
html
:
function
(
t
,
i
){
return
t
.
innerHTML
=
null
!=
i
?
i
:
""
},
value
:{
publishes
:
!
0
,
bind
:
function
(
i
){
return
this
.
currentListener
=
t
.
Util
.
bindEvent
(
i
,
"change"
,
this
.
publish
)},
unbind
:
function
(
i
){
return
t
.
Util
.
unbindEvent
(
i
,
"change"
,
this
.
currentListener
)},
routine
:
function
(
t
,
i
){
var
e
,
s
,
r
,
h
,
u
,
o
,
l
;
if
(
null
!=
window
.
jQuery
){
if
(
t
=
jQuery
(
t
),(
null
!=
i
?
""
+
i
:
void
0
)
!==
(
null
!=
(
h
=
t
.
val
())?
""
+
h
:
void
0
))
return
t
.
val
(
null
!=
i
?
i
:
""
)}
else
if
(
"select-multiple"
===
t
.
type
){
if
(
null
!=
i
){
for
(
l
=
[],
s
=
0
,
r
=
t
.
length
;
r
>
s
;
s
++
)
e
=
t
[
s
],
l
.
push
(
e
.
selected
=
(
u
=
e
.
value
,
n
.
call
(
i
,
u
)
>=
0
));
return
l
}}
else
if
((
null
!=
i
?
""
+
i
:
void
0
)
!==
(
null
!=
(
o
=
t
.
value
)?
""
+
o
:
void
0
))
return
t
.
value
=
null
!=
i
?
i
:
""
}},
text
:
function
(
t
,
i
){
return
null
!=
t
.
innerText
?
t
.
innerText
=
null
!=
i
?
i
:
""
:
t
.
textContent
=
null
!=
i
?
i
:
""
},
"on-*"
:{
"function"
:
!
0
,
routine
:
function
(
i
,
e
){
return
this
.
currentListener
&&
t
.
Util
.
unbindEvent
(
i
,
this
.
args
[
0
],
this
.
currentListener
),
this
.
currentListener
=
t
.
Util
.
bindEvent
(
i
,
this
.
args
[
0
],
e
,
this
.
model
)}},
"each-*"
:{
block
:
!
0
,
bind
:
function
(
t
){
return
t
.
removeAttribute
([
"data"
,
this
.
view
.
config
.
prefix
,
this
.
type
].
join
(
"-"
).
replace
(
"--"
,
"-"
))},
unbind
:
function
(){
var
t
,
i
,
e
,
n
,
s
;
if
(
null
!=
this
.
iterated
){
for
(
n
=
this
.
iterated
,
s
=
[],
i
=
0
,
e
=
n
.
length
;
e
>
i
;
i
++
)
t
=
n
[
i
],
s
.
push
(
t
.
unbind
());
return
s
}},
routine
:
function
(
i
,
e
){
var
n
,
s
,
r
,
h
,
u
,
o
,
l
,
a
,
d
,
c
,
f
,
p
,
b
,
v
,
g
,
y
,
m
,
w
,
x
;
if
(
null
!=
this
.
iterated
)
for
(
g
=
this
.
iterated
,
d
=
0
,
p
=
g
.
length
;
p
>
d
;
d
++
)
for
(
a
=
g
[
d
],
a
.
unbind
(),
y
=
a
.
els
,
c
=
0
,
b
=
y
.
length
;
b
>
c
;
c
++
)
s
=
y
[
c
],
s
.
parentNode
.
removeChild
(
s
);
else
this
.
marker
=
document
.
createComment
(
" rivets: "
+
this
.
type
+
" "
),
i
.
parentNode
.
insertBefore
(
this
.
marker
,
i
),
i
.
parentNode
.
removeChild
(
i
);
if
(
this
.
iterated
=
[],
e
){
for
(
x
=
[],
f
=
0
,
v
=
e
.
length
;
v
>
f
;
f
++
){
r
=
e
[
f
],
n
=
{},
m
=
this
.
view
.
models
;
for
(
o
in
m
)
u
=
m
[
o
],
n
[
o
]
=
u
;
n
[
this
.
args
[
0
]]
=
r
,
h
=
i
.
cloneNode
(
!
0
),
l
=
this
.
iterated
.
length
?
this
.
iterated
[
this
.
iterated
.
length
-
1
].
els
[
0
]:
this
.
marker
,
this
.
marker
.
parentNode
.
insertBefore
(
h
,
null
!=
(
w
=
l
.
nextSibling
)?
w
:
null
),
a
=
new
t
.
View
(
h
,
n
,
this
.
view
.
options
),
a
.
bind
(),
x
.
push
(
this
.
iterated
.
push
(
a
))}
return
x
}}},
"class-*"
:
function
(
t
,
i
){
var
e
;
return
e
=
" "
+
t
.
className
+
" "
,
!
i
==
(
-
1
!==
e
.
indexOf
(
" "
+
this
.
args
[
0
]
+
" "
))?
t
.
className
=
i
?
""
+
t
.
className
+
" "
+
this
.
args
[
0
]:
e
.
replace
(
" "
+
this
.
args
[
0
]
+
" "
,
" "
).
trim
():
void
0
},
"*"
:
function
(
t
,
i
){
return
i
?
t
.
setAttribute
(
this
.
type
,
i
):
t
.
removeAttribute
(
this
.
type
)}},
t
.
config
=
{
preloadData
:
!
0
},
t
.
formatters
=
{},
t
.
factory
=
function
(
i
){
return
i
.
binders
=
t
.
binders
,
i
.
formatters
=
t
.
formatters
,
i
.
config
=
t
.
config
,
i
.
configure
=
function
(
i
){
var
e
,
n
;
null
==
i
&&
(
i
=
{});
for
(
e
in
i
)
n
=
i
[
e
],
t
.
config
[
e
]
=
n
},
i
.
bind
=
function
(
i
,
e
,
n
){
var
s
;
return
null
==
e
&&
(
e
=
{}),
null
==
n
&&
(
n
=
{}),
s
=
new
t
.
View
(
i
,
e
,
n
),
s
.
bind
(),
s
}},
"object"
==
typeof
exports
?
t
.
factory
(
exports
):
"function"
==
typeof
define
&&
define
.
amd
?
define
([
"exports"
],
function
(
i
){
return
t
.
factory
(
this
.
rivets
=
i
),
i
}):
t
.
factory
(
this
.
rivets
=
{})}).
call
(
this
);
\ No newline at end of file
...
...
package.json
View file @
421bf22
{
"name"
:
"rivets"
,
"description"
:
"Declarative data binding facility."
,
"version"
:
"0.5.
0
"
,
"version"
:
"0.5.
1
"
,
"author"
:
"Michael Richards"
,
"url"
:
"http://rivetsjs.com"
,
"main"
:
"./dist/rivets.js"
,
...
...
src/rivets.coffee
View file @
421bf22
# Rivets.js
# =========
# > version: 0.5.
0
# > version: 0.5.
1
# > author: Michael Richards
# > license: MIT
# >
...
...
Please
register
or
sign in
to post a comment