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
6a5ed20c
authored
2014-03-17 11:54:38 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Check in built files.
1 parent
fc2a7409
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
285 additions
and
221 deletions
lib/rivets.js
lib/rivets.min.js
lib/rivets.js
View file @
6a5ed20
...
...
@@ -3,7 +3,7 @@
// author: Michael Richards
// license: MIT
(
function
()
{
var
Rivets
,
bindEvent
,
getInputValue
,
rivets
,
unbindEvent
,
var
Rivets
,
bindEvent
,
convertToModel
,
createInputBinder
,
createSubExpressionBinder
,
defaultExpressionParser
,
expressionRegex
,
findBinder
,
getInputValue
,
iterate
,
loopDeps
,
rivets
,
unbindEvent
,
__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
;
};
...
...
@@ -16,15 +16,39 @@
};
}
findBinder
=
function
(
type
)
{
var
args
,
binder
,
identifier
,
regexp
,
value
,
_ref
;
if
(
!
(
binder
=
Rivets
.
binders
[
type
]))
{
binder
=
Rivets
.
binders
[
'*'
];
_ref
=
Rivets
.
binders
;
for
(
identifier
in
_ref
)
{
value
=
_ref
[
identifier
];
if
(
identifier
!==
'*'
&&
identifier
.
indexOf
(
'*'
)
!==
-
1
)
{
regexp
=
new
RegExp
(
"^"
+
(
identifier
.
replace
(
'*'
,
'(.+)'
))
+
"$"
);
if
(
regexp
.
test
(
type
))
{
binder
=
value
;
args
=
regexp
.
exec
(
type
);
args
.
shift
();
}
}
}
}
if
(
binder
instanceof
Function
)
{
binder
=
{
routine
:
binder
};
}
return
[
binder
,
args
];
};
Rivets
.
Binding
=
(
function
()
{
function
Binding
(
el
,
type
,
model
,
keypath
,
options
)
{
var
identifier
,
regexp
,
value
,
_ref
;
var
_ref
;
this
.
el
=
el
;
this
.
type
=
type
;
this
.
model
=
model
;
this
.
keypath
=
keypath
;
this
.
options
=
options
!=
null
?
options
:
{};
this
.
unbind
=
__bind
(
this
.
unbind
,
this
);
this
.
bind
=
__bind
(
this
.
bind
,
this
);
...
...
@@ -37,37 +61,21 @@
this
.
formattedValue
=
__bind
(
this
.
formattedValue
,
this
);
if
(
!
(
this
.
binder
=
Rivets
.
binders
[
type
]))
{
_ref
=
Rivets
.
binders
;
for
(
identifier
in
_ref
)
{
value
=
_ref
[
identifier
];
if
(
identifier
!==
'*'
&&
identifier
.
indexOf
(
'*'
)
!==
-
1
)
{
regexp
=
new
RegExp
(
"^"
+
(
identifier
.
replace
(
'*'
,
'.+'
))
+
"$"
);
if
(
regexp
.
test
(
type
))
{
this
.
binder
=
value
;
this
.
args
=
new
RegExp
(
"^"
+
(
identifier
.
replace
(
'*'
,
'(.+)'
))
+
"$"
).
exec
(
type
);
this
.
args
.
shift
();
}
}
}
}
this
.
binder
||
(
this
.
binder
=
Rivets
.
binders
[
'*'
]);
if
(
this
.
binder
instanceof
Function
)
{
this
.
binder
=
{
routine
:
this
.
binder
};
}
this
.
formatters
=
this
.
options
.
formatters
||
[];
this
.
options
=
(
options
||
(
options
=
{}));
_ref
=
options
.
binder
?
[
options
.
binder
,
options
.
args
]
:
findBinder
(
type
),
this
.
binder
=
_ref
[
0
],
this
.
args
=
_ref
[
1
];
this
.
formatters
=
options
.
formatters
||
[];
}
Binding
.
prototype
.
formattedValue
=
function
(
value
)
{
var
args
,
formatter
,
id
,
_i
,
_len
,
_ref
;
var
args
,
formatter
,
id
,
m
,
model
,
_i
,
_len
,
_ref
;
model
=
this
.
model
;
_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
];
m
=
Rivets
.
config
.
adapter
.
read
(
model
,
id
);
formatter
=
m
instanceof
Function
?
m
:
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
)
{
...
...
@@ -78,97 +86,205 @@
};
Binding
.
prototype
.
set
=
function
(
value
)
{
var
_ref
;
value
=
value
instanceof
Function
&&
!
this
.
binder
[
"function"
]
?
this
.
formattedValue
(
value
.
call
(
this
.
model
))
:
this
.
formattedValue
(
value
);
return
(
_ref
=
this
.
binder
.
routine
)
!=
null
?
_ref
.
call
(
this
,
this
.
el
,
value
)
:
void
0
;
var
binder
,
_ref
;
binder
=
this
.
binder
;
value
=
this
.
formattedValue
(
value
instanceof
Function
&&
!
binder
[
"function"
]
?
value
.
call
(
this
.
model
,
this
.
options
.
bindContext
)
:
value
);
return
(
_ref
=
binder
.
routine
)
!=
null
?
_ref
.
call
(
this
,
this
.
el
,
value
)
:
void
0
;
};
Binding
.
prototype
.
sync
=
function
()
{
return
this
.
set
(
this
.
options
.
bypass
?
this
.
model
[
this
.
keypath
]
:
Rivets
.
config
.
adapter
.
read
(
this
.
model
,
this
.
keypath
));
var
keypath
,
model
;
keypath
=
this
.
keypath
;
model
=
this
.
model
;
return
this
.
set
(
this
.
options
.
bypass
?
model
[
keypath
]
:
Rivets
.
config
.
adapter
.
read
(
model
,
keypath
));
};
Binding
.
prototype
.
publish
=
function
()
{
var
args
,
formatter
,
id
,
value
,
_i
,
_len
,
_ref
,
_ref1
,
_ref2
;
var
args
,
f
,
formatter
,
id
,
value
,
_i
,
_len
,
_ref
;
if
(
this
.
binder
.
tokenizes
)
{
return
;
}
value
=
getInputValue
(
this
.
el
);
_ref
=
this
.
formatters
.
slice
(
0
).
reverse
();
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
formatter
=
_ref
[
_i
];
args
=
formatter
.
split
(
/
\s
+/
);
id
=
args
.
shift
();
if
((
_ref1
=
Rivets
.
formatters
[
id
])
!=
null
?
_ref1
.
publish
:
void
0
)
{
value
=
(
_ref2
=
Rivets
.
formatters
[
id
]).
publish
.
apply
(
_ref2
,
[
value
].
concat
(
__slice
.
call
(
args
)));
f
=
Rivets
.
formatters
[
id
];
if
(
f
!=
null
?
f
.
publish
:
void
0
)
{
value
=
f
.
publish
.
apply
(
f
,
[
value
].
concat
(
__slice
.
call
(
args
)));
}
}
return
Rivets
.
config
.
adapter
.
publish
(
this
.
model
,
this
.
keypath
,
value
);
};
Binding
.
prototype
.
bind
=
function
()
{
var
dependency
,
keypath
,
model
,
_i
,
_len
,
_ref
,
_ref1
,
_ref2
,
_results
;
var
_ref
,
_this
=
this
;
if
((
_ref
=
this
.
binder
.
bind
)
!=
null
)
{
_ref
.
call
(
this
,
this
.
el
);
}
if
(
this
.
options
.
bypass
)
{
this
.
sync
();
}
else
{
if
(
this
.
keypath
&&
!
this
.
binder
.
tokenizes
)
{
Rivets
.
config
.
adapter
.
subscribe
(
this
.
model
,
this
.
keypath
,
this
.
sync
);
}
if
(
Rivets
.
config
.
preloadData
)
{
this
.
sync
();
}
}
if
((
_ref1
=
this
.
options
.
dependencies
)
!=
null
?
_ref1
.
length
:
void
0
)
{
_ref2
=
this
.
options
.
dependencies
;
_results
=
[];
for
(
_i
=
0
,
_len
=
_ref2
.
length
;
_i
<
_len
;
_i
++
)
{
dependency
=
_ref2
[
_i
];
if
(
/^
\.
/
.
test
(
dependency
))
{
model
=
this
.
model
;
keypath
=
dependency
.
substr
(
1
);
}
else
{
dependency
=
dependency
.
split
(
'.'
);
model
=
this
.
view
.
models
[
dependency
.
shift
()];
keypath
=
dependency
.
join
(
'.'
);
}
_results
.
push
(
Rivets
.
config
.
adapter
.
subscribe
(
model
,
keypath
,
this
.
sync
));
}
return
_results
;
}
return
loopDeps
(
this
,
function
(
model
,
keypath
)
{
return
Rivets
.
config
.
adapter
.
subscribe
(
model
,
keypath
,
_this
.
sync
);
});
};
Binding
.
prototype
.
unbind
=
function
()
{
var
dependency
,
keypath
,
model
,
_i
,
_len
,
_ref
,
_ref1
,
_ref2
,
_results
;
var
_ref
,
_this
=
this
;
if
((
_ref
=
this
.
binder
.
unbind
)
!=
null
)
{
_ref
.
call
(
this
,
this
.
el
);
}
if
(
!
this
.
options
.
bypass
)
{
if
(
!
(
this
.
options
.
bypass
||
!
this
.
binder
.
tokenizes
))
{
if
(
this
.
keypath
)
{
Rivets
.
config
.
adapter
.
unsubscribe
(
this
.
model
,
this
.
keypath
,
this
.
sync
);
}
if
((
_ref1
=
this
.
options
.
dependencies
)
!=
null
?
_ref1
.
length
:
void
0
)
{
_ref2
=
this
.
options
.
dependencies
;
}
return
loopDeps
(
this
,
function
(
model
,
keypath
)
{
return
Rivets
.
config
.
adapter
.
unsubscribe
(
model
,
keypath
,
_this
.
sync
);
});
};
return
Binding
;
})();
loopDeps
=
function
(
binder
,
callback
)
{
var
dependency
,
keypath
,
model
,
_i
,
_len
,
_ref
,
_ref1
,
_results
;
if
((
_ref
=
binder
.
options
.
dependencies
)
!=
null
?
_ref
.
length
:
void
0
)
{
_ref1
=
binder
.
options
.
dependencies
;
_results
=
[];
for
(
_i
=
0
,
_len
=
_ref2
.
length
;
_i
<
_len
;
_i
++
)
{
dependency
=
_ref2
[
_i
];
for
(
_i
=
0
,
_len
=
_ref1
.
length
;
_i
<
_len
;
_i
++
)
{
dependency
=
_ref1
[
_i
];
if
(
/^
\.
/
.
test
(
dependency
))
{
model
=
this
.
model
;
model
=
binder
.
model
;
keypath
=
dependency
.
substr
(
1
);
}
else
{
dependency
=
dependency
.
split
(
'.'
);
model
=
this
.
view
.
models
[
dependency
.
shift
()]
;
model
=
Rivets
.
config
.
adapter
.
read
(
binder
.
view
.
models
(
dependency
.
shift
()))
;
keypath
=
dependency
.
join
(
'.'
);
}
_results
.
push
(
Rivets
.
config
.
adapter
.
unsubscribe
(
model
,
keypath
,
this
.
sync
));
_results
.
push
(
callback
(
model
,
keypath
));
}
return
_results
;
}
};
return
Binding
;
expressionRegex
=
/
(
.*
?)\{\{([^
{}
]
+
)\}\}
/
;
createSubExpressionBinder
=
function
(
outerBinding
,
values
,
i
)
{
values
[
i
]
=
null
;
return
{
routine
:
function
(
el
,
value
)
{
values
[
i
]
=
value
;
return
outerBinding
.
sync
();
}
};
};
defaultExpressionParser
=
function
(
view
,
node
,
type
,
models
,
value
)
{
var
bindMethod
,
binder
,
binderTokenizes
,
binding
,
context
,
ctx
,
dependencies
,
firstPart
,
keypath
,
matches
,
model
,
options
,
parsingSupport
,
path
,
pipe
,
pipes
,
splitPath
,
subBinding
,
subs
,
unbindMethod
,
values
,
_ref
;
if
(
expressionRegex
.
test
(
value
))
{
binding
=
new
Rivets
.
Binding
(
node
,
type
,
models
);
values
=
[];
subs
=
[];
while
(
value
&&
expressionRegex
.
test
(
value
))
{
matches
=
expressionRegex
.
exec
(
value
);
value
=
value
.
substring
(
matches
[
0
].
length
);
if
(
matches
[
1
])
{
values
[
values
.
length
]
=
matches
[
1
];
}
subs
[
subs
.
length
]
=
subBinding
=
defaultExpressionParser
(
view
,
null
,
'*'
,
models
,
matches
[
2
]);
subBinding
.
binder
=
createSubExpressionBinder
(
binding
,
values
,
values
.
length
);
}
if
(
value
)
{
values
[
values
.
length
]
=
value
;
}
bindMethod
=
binding
.
bind
;
unbindMethod
=
binding
.
unbind
;
binding
.
sync
=
function
()
{
return
binding
.
set
(
values
.
join
(
''
));
};
binding
.
publish
=
function
()
{};
binding
.
bind
=
function
()
{
var
sub
,
_i
,
_len
,
_results
;
bindMethod
();
_results
=
[];
for
(
_i
=
0
,
_len
=
subs
.
length
;
_i
<
_len
;
_i
++
)
{
sub
=
subs
[
_i
];
_results
.
push
(
sub
.
bind
());
}
return
_results
;
};
binding
.
unbind
=
function
()
{
var
sub
,
_i
,
_len
,
_results
;
unbindMethod
();
_results
=
[];
for
(
_i
=
0
,
_len
=
subs
.
length
;
_i
<
_len
;
_i
++
)
{
sub
=
subs
[
_i
];
_results
.
push
(
sub
.
unbind
());
}
return
_results
;
};
return
binding
;
}
pipes
=
(
function
()
{
var
_i
,
_len
,
_ref
,
_results
;
_ref
=
value
.
split
(
'|'
);
_results
=
[];
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
pipe
=
_ref
[
_i
];
_results
.
push
(
pipe
.
trim
());
}
return
_results
;
})();
context
=
(
function
()
{
var
_i
,
_len
,
_ref
,
_results
;
_ref
=
pipes
.
shift
().
split
(
'<'
);
_results
=
[];
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
ctx
=
_ref
[
_i
];
_results
.
push
(
ctx
.
trim
());
}
return
_results
;
})();
path
=
context
.
shift
();
splitPath
=
path
.
split
(
/
\.
|:/
);
options
=
{
formatters
:
pipes
,
bypass
:
path
.
indexOf
(
':'
)
!==
-
1
,
bindContext
:
models
};
parsingSupport
=
Rivets
.
config
.
adapter
.
parsingSupport
;
_ref
=
findBinder
(
type
),
binder
=
_ref
[
0
],
options
.
args
=
_ref
[
1
];
binderTokenizes
=
binder
.
tokenizes
;
options
.
binder
=
binder
;
firstPart
=
parsingSupport
||
binderTokenizes
?
splitPath
[
0
]
:
splitPath
.
shift
();
model
=
firstPart
||
!
binderTokenizes
?
Rivets
.
config
.
adapter
.
read
(
models
,
firstPart
)
:
models
;
keypath
=
splitPath
.
join
(
'.'
);
if
(
model
||
binderTokenizes
)
{
if
(
dependencies
=
context
.
shift
())
{
options
.
dependencies
=
dependencies
.
split
(
/
\s
+/
);
}
binding
=
new
Rivets
.
Binding
(
node
,
type
,
(
parsingSupport
?
models
:
model
),
keypath
,
options
);
binding
.
view
=
view
;
}
return
binding
;
};
Rivets
.
View
=
(
function
()
{
function
View
(
els
,
models
)
{
this
.
els
=
els
;
this
.
models
=
models
;
this
.
publish
=
__bind
(
this
.
publish
,
this
);
...
...
@@ -184,9 +300,7 @@
this
.
bindingRegExp
=
__bind
(
this
.
bindingRegExp
,
this
);
if
(
!
(
this
.
els
.
jquery
||
this
.
els
instanceof
Array
))
{
this
.
els
=
[
this
.
els
];
}
this
.
els
=
els
.
jquery
||
els
instanceof
Array
?
els
:
[
els
];
this
.
build
();
}
...
...
@@ -201,13 +315,13 @@
};
View
.
prototype
.
build
=
function
()
{
var
bindingRegExp
,
el
,
node
,
parse
,
skipNodes
,
_i
,
_j
,
_len
,
_len1
,
_ref
,
_ref1
,
var
bindingRegExp
,
bindings
,
el
,
node
,
parse
,
skipNodes
,
_i
,
_j
,
_len
,
_len1
,
_ref
,
_ref1
,
_this
=
this
;
this
.
bindings
=
[];
bindings
=
this
.
bindings
=
[];
skipNodes
=
[];
bindingRegExp
=
this
.
bindingRegExp
();
parse
=
function
(
node
)
{
var
attribute
,
attributes
,
binder
,
binding
,
context
,
ctx
,
dependencies
,
identifier
,
keypath
,
model
,
n
,
options
,
path
,
pipe
,
pipes
,
regexp
,
splitPath
,
type
,
value
,
_i
,
_j
,
_k
,
_len
,
_len1
,
_len2
,
_ref
,
_ref1
,
_ref2
,
_ref3
;
var
attribute
,
attributes
,
binder
,
binding
,
identifier
,
n
,
regexp
,
type
,
value
,
_i
,
_j
,
_k
,
_len
,
_len1
,
_len2
,
_ref
,
_ref1
,
_ref2
,
_ref3
;
if
(
__indexOf
.
call
(
skipNodes
,
node
)
<
0
)
{
_ref
=
node
.
attributes
;
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
...
...
@@ -241,47 +355,10 @@
for
(
_k
=
0
,
_len2
=
_ref3
.
length
;
_k
<
_len2
;
_k
++
)
{
attribute
=
_ref3
[
_k
];
if
(
bindingRegExp
.
test
(
attribute
.
name
))
{
options
=
{};
type
=
attribute
.
name
.
replace
(
bindingRegExp
,
''
);
pipes
=
(
function
()
{
var
_l
,
_len3
,
_ref4
,
_results
;
_ref4
=
attribute
.
value
.
split
(
'|'
);
_results
=
[];
for
(
_l
=
0
,
_len3
=
_ref4
.
length
;
_l
<
_len3
;
_l
++
)
{
pipe
=
_ref4
[
_l
];
_results
.
push
(
pipe
.
trim
());
}
return
_results
;
})();
context
=
(
function
()
{
var
_l
,
_len3
,
_ref4
,
_results
;
_ref4
=
pipes
.
shift
().
split
(
'<'
);
_results
=
[];
for
(
_l
=
0
,
_len3
=
_ref4
.
length
;
_l
<
_len3
;
_l
++
)
{
ctx
=
_ref4
[
_l
];
_results
.
push
(
ctx
.
trim
());
}
return
_results
;
})();
path
=
context
.
shift
();
splitPath
=
path
.
split
(
/
\.
|:/
);
options
.
formatters
=
pipes
;
options
.
bypass
=
path
.
indexOf
(
':'
)
!==
-
1
;
options
.
bindContext
=
_this
.
models
;
if
(
splitPath
[
0
])
{
model
=
_this
.
models
[
splitPath
.
shift
()];
}
else
{
model
=
_this
.
models
;
splitPath
.
shift
();
}
keypath
=
splitPath
.
join
(
'.'
);
if
(
model
)
{
if
(
dependencies
=
context
.
shift
())
{
options
.
dependencies
=
dependencies
.
split
(
/
\s
+/
);
}
binding
=
new
Rivets
.
Binding
(
node
,
type
,
model
,
keypath
,
options
);
binding
.
view
=
_this
;
_this
.
bindings
.
push
(
binding
);
binding
=
defaultExpressionParser
(
_this
,
node
,
type
,
_this
.
models
,
attribute
.
value
);
if
(
binding
)
{
bindings
.
push
(
binding
);
}
}
}
...
...
@@ -293,7 +370,9 @@
_ref
=
this
.
els
;
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
el
=
_ref
[
_i
];
if
(
el
.
attributes
!=
null
)
{
parse
(
el
);
}
_ref1
=
el
.
getElementsByTagName
(
'*'
);
for
(
_j
=
0
,
_len1
=
_ref1
.
length
;
_j
<
_len1
;
_j
++
)
{
node
=
_ref1
[
_j
];
...
...
@@ -318,49 +397,29 @@
};
View
.
prototype
.
bind
=
function
()
{
var
binding
,
_i
,
_len
,
_ref
,
_results
;
_ref
=
this
.
bindings
;
_results
=
[];
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
binding
=
_ref
[
_i
];
_results
.
push
(
binding
.
bind
());
}
return
_results
;
return
this
.
bindings
.
map
(
function
(
binding
)
{
return
binding
.
bind
();
});
};
View
.
prototype
.
unbind
=
function
()
{
var
binding
,
_i
,
_len
,
_ref
,
_results
;
_ref
=
this
.
bindings
;
_results
=
[];
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
binding
=
_ref
[
_i
];
_results
.
push
(
binding
.
unbind
());
}
return
_results
;
return
this
.
bindings
.
map
(
function
(
binding
)
{
return
binding
.
unbind
();
});
};
View
.
prototype
.
sync
=
function
()
{
var
binding
,
_i
,
_len
,
_ref
,
_results
;
_ref
=
this
.
bindings
;
_results
=
[];
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
binding
=
_ref
[
_i
];
_results
.
push
(
binding
.
sync
());
}
return
_results
;
return
this
.
bindings
.
map
(
function
(
binding
)
{
return
binding
.
sync
();
});
};
View
.
prototype
.
publish
=
function
()
{
var
binding
,
_i
,
_len
,
_ref
,
_results
;
_ref
=
this
.
select
(
function
(
b
)
{
return
(
this
.
select
(
function
(
b
)
{
return
b
.
binder
.
publishes
;
})).
map
(
function
(
binding
)
{
return
binding
.
publish
();
});
_results
=
[];
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
binding
=
_ref
[
_i
];
_results
.
push
(
binding
.
publish
());
}
return
_results
;
};
return
View
;
...
...
@@ -424,30 +483,37 @@
}
};
Rivets
.
binders
=
{
enabled
:
function
(
el
,
value
)
{
return
el
.
disabled
=
!
value
;
},
disabled
:
function
(
el
,
value
)
{
return
el
.
disabled
=
!!
value
;
},
checked
:
{
publishes
:
true
,
bind
:
function
(
el
)
{
return
this
.
currentListener
=
bindEvent
(
el
,
'change'
,
this
.
publish
);
},
unbind
:
function
(
el
)
{
return
unbindEvent
(
el
,
'change'
,
this
.
currentListener
);
},
routine
:
function
(
el
,
value
)
{
if
(
el
.
type
===
'radio'
)
{
return
el
.
checked
=
el
.
value
===
value
;
iterate
=
function
(
collection
,
callback
)
{
var
i
,
item
,
m
,
n
,
_i
,
_len
,
_results
,
_results1
;
if
(
Rivets
.
config
.
adapter
.
iterate
)
{
return
Rivets
.
config
.
adapter
.
iterate
(
collection
,
callback
);
}
else
if
(
collection
instanceof
Array
)
{
_results
=
[];
for
(
i
=
_i
=
0
,
_len
=
collection
.
length
;
_i
<
_len
;
i
=
++
_i
)
{
item
=
collection
[
i
];
_results
.
push
(
callback
(
item
,
i
));
}
return
_results
;
}
else
{
return
el
.
checked
=
!!
value
;
_results1
=
[];
for
(
n
in
collection
)
{
m
=
collection
[
n
];
_results1
.
push
(
callback
(
m
,
n
));
}
return
_results1
;
}
},
unchecked
:
{
};
convertToModel
=
function
(
data
)
{
if
(
Rivets
.
config
.
adapter
.
convertToModel
)
{
return
Rivets
.
config
.
adapter
.
convertToModel
(
data
);
}
else
{
return
data
;
}
};
createInputBinder
=
function
(
routine
)
{
return
{
publishes
:
true
,
bind
:
function
(
el
)
{
return
this
.
currentListener
=
bindEvent
(
el
,
'change'
,
this
.
publish
);
...
...
@@ -455,14 +521,23 @@
unbind
:
function
(
el
)
{
return
unbindEvent
(
el
,
'change'
,
this
.
currentListener
);
},
routine
:
function
(
el
,
value
)
{
if
(
el
.
type
===
'radio'
)
{
return
el
.
checked
=
el
.
value
!==
value
;
}
else
{
return
el
.
checked
=
!
value
;
}
}
routine
:
routine
};
}
;
Rivets
.
binders
=
{
enabled
:
function
(
el
,
value
)
{
return
el
.
disabled
=
!
value
;
},
disabled
:
function
(
el
,
value
)
{
return
el
.
disabled
=
!!
value
;
},
checked
:
createInputBinder
(
function
(
el
,
value
)
{
return
el
.
checked
=
el
.
type
===
'radio'
?
el
.
value
===
value
:
!!
value
;
}),
unchecked
:
createInputBinder
(
function
(
el
,
value
)
{
return
el
.
checked
=
el
.
type
===
'radio'
?
el
.
value
!==
value
:
!
value
;
}),
show
:
function
(
el
,
value
)
{
return
el
.
style
.
display
=
value
?
''
:
'none'
;
},
...
...
@@ -472,15 +547,7 @@
html
:
function
(
el
,
value
)
{
return
el
.
innerHTML
=
value
!=
null
?
value
:
''
;
},
value
:
{
publishes
:
true
,
bind
:
function
(
el
)
{
return
this
.
currentListener
=
bindEvent
(
el
,
'change'
,
this
.
publish
);
},
unbind
:
function
(
el
)
{
return
unbindEvent
(
el
,
'change'
,
this
.
currentListener
);
},
routine
:
function
(
el
,
value
)
{
value
:
createInputBinder
(
function
(
el
,
value
)
{
var
o
,
_i
,
_len
,
_ref
,
_results
;
if
(
el
.
type
===
'select-multiple'
)
{
if
(
value
!=
null
)
{
...
...
@@ -494,22 +561,26 @@
}
else
{
return
el
.
value
=
value
!=
null
?
value
:
''
;
}
}
},
}),
text
:
function
(
el
,
value
)
{
var
newValue
;
newValue
=
value
!=
null
?
value
:
''
;
if
(
el
.
innerText
!=
null
)
{
return
el
.
innerText
=
value
!=
null
?
value
:
''
;
return
el
.
innerText
=
newValue
;
}
else
{
return
el
.
textContent
=
value
!=
null
?
value
:
''
;
return
el
.
textContent
=
newValue
;
}
},
"on-*"
:
{
"function"
:
true
,
routine
:
function
(
el
,
value
)
{
if
(
this
.
currentListener
)
{
unbindEvent
(
el
,
this
.
args
[
0
],
this
.
currentListener
);
var
currentListener
,
firstArg
;
firstArg
=
this
.
args
[
0
];
currentListener
=
this
.
currentListener
;
if
(
currentListener
)
{
unbindEvent
(
el
,
firstArg
,
currentListener
);
}
return
this
.
currentListener
=
bindEvent
(
el
,
this
.
args
[
0
]
,
value
,
this
.
model
,
this
.
options
.
bindContext
);
return
this
.
currentListener
=
bindEvent
(
el
,
firstArg
,
value
,
this
.
model
,
this
.
options
.
bindContext
);
}
},
"each-*"
:
{
...
...
@@ -518,45 +589,42 @@
return
el
.
removeAttribute
([
'data'
,
rivets
.
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
;
if
(
this
.
iterated
!=
null
)
{
_ref
=
this
.
iterated
;
for
(
_i
=
0
,
_len
=
_ref
.
length
;
_i
<
_len
;
_i
++
)
{
view
=
_ref
[
_i
];
var
e
,
iterated
,
marker
,
parentNode
,
view
,
_i
,
_j
,
_len
,
_len1
,
_ref
,
_this
=
this
;
iterated
=
this
.
iterated
;
if
(
iterated
!=
null
)
{
for
(
_i
=
0
,
_len
=
iterated
.
length
;
_i
<
_len
;
_i
++
)
{
view
=
iterated
[
_i
];
view
.
unbind
();
_ref
1
=
view
.
els
;
for
(
_j
=
0
,
_len1
=
_ref
1
.
length
;
_j
<
_len1
;
_j
++
)
{
e
=
_ref
1
[
_j
];
_ref
=
view
.
els
;
for
(
_j
=
0
,
_len1
=
_ref
.
length
;
_j
<
_len1
;
_j
++
)
{
e
=
_ref
[
_j
];
e
.
parentNode
.
removeChild
(
e
);
}
}
}
else
{
this
.
marker
=
document
.
createComment
(
" rivets: "
+
this
.
type
+
" "
);
el
.
parentNode
.
insertBefore
(
this
.
marker
,
el
);
el
.
parentNode
.
removeChild
(
el
);
marker
=
this
.
marker
=
document
.
createComment
(
" rivets: "
+
this
.
type
+
" "
);
parentNode
=
el
.
parentNode
;
parentNode
.
insertBefore
(
marker
,
el
);
parentNode
.
removeChild
(
el
);
}
this
.
iterated
=
[];
this
.
iterated
=
iterated
=
[];
if
(
collection
)
{
_results
=
[]
;
for
(
_k
=
0
,
_len2
=
collection
.
length
;
_k
<
_len2
;
_k
++
)
{
item
=
collection
[
_k
]
;
marker
=
this
.
marker
;
return
iterate
(
collection
,
function
(
item
,
i
)
{
var
data
,
itemEl
,
previous
,
_ref1
;
data
=
{};
_ref2
=
this
.
view
.
models
;
for
(
n
in
_ref2
)
{
m
=
_ref2
[
n
]
;
data
[
n
]
=
m
;
}
data
[
this
.
args
[
0
]]
=
item
;
iterate
(
_this
.
view
.
models
,
function
(
item
,
i
)
{
return
data
[
i
]
=
item
;
})
;
data
[
_this
.
args
[
0
]]
=
ite
m
;
data
[
""
+
_this
.
args
[
0
]
+
"_index"
]
=
data
[
'rivets_index'
]
=
i
;
data
=
convertToModel
(
data
)
;
itemEl
=
el
.
cloneNode
(
true
);
if
(
this
.
iterated
.
length
>
0
)
{
previous
=
this
.
iterated
[
this
.
iterated
.
length
-
1
].
els
[
0
];
}
else
{
previous
=
this
.
marker
;
}
this
.
marker
.
parentNode
.
insertBefore
(
itemEl
,
(
_ref3
=
previous
.
nextSibling
)
!=
null
?
_ref3
:
null
);
_results
.
push
(
this
.
iterated
.
push
(
rivets
.
bind
(
itemEl
,
data
)));
}
return
_results
;
previous
=
iterated
.
length
>
0
?
iterated
[
iterated
.
length
-
1
].
els
[
0
]
:
marker
;
marker
.
parentNode
.
insertBefore
(
itemEl
,
(
_ref1
=
previous
.
nextSibling
)
!=
null
?
_ref1
:
null
);
return
iterated
.
push
(
rivets
.
bind
(
itemEl
,
data
));
});
}
}
},
...
...
@@ -588,9 +656,7 @@
config
:
Rivets
.
config
,
configure
:
function
(
options
)
{
var
property
,
value
;
if
(
options
==
null
)
{
options
=
{};
}
options
||
(
options
=
{});
for
(
property
in
options
)
{
value
=
options
[
property
];
Rivets
.
config
[
property
]
=
value
;
...
...
@@ -598,9 +664,7 @@
},
bind
:
function
(
el
,
models
)
{
var
view
;
if
(
models
==
null
)
{
models
=
{};
}
models
||
(
models
=
{});
view
=
new
Rivets
.
View
(
el
,
models
);
view
.
bind
();
return
view
;
...
...
lib/rivets.min.js
View file @
6a5ed20
...
...
@@ -2,4 +2,4 @@
// version: 0.4.5
// author: Michael Richards
// license: MIT
(
function
(){
var
e
,
t
,
n
,
r
,
i
,
s
=
function
(
e
,
t
){
return
function
(){
return
e
.
apply
(
t
,
arguments
)}},
o
=
[].
slice
,
u
=
[].
indexOf
||
function
(
e
){
for
(
var
t
=
0
,
n
=
this
.
length
;
t
<
n
;
t
++
)
if
(
t
in
this
&&
this
[
t
]
===
e
)
return
t
;
return
-
1
};
e
=
{},
String
.
prototype
.
trim
||
(
String
.
prototype
.
trim
=
function
(){
return
this
.
replace
(
/^
\s
+|
\s
+$/g
,
""
)}),
e
.
Binding
=
function
(){
function
t
(
t
,
n
,
r
,
i
,
o
){
var
u
,
a
,
f
,
l
;
this
.
el
=
t
,
this
.
type
=
n
,
this
.
model
=
r
,
this
.
keypath
=
i
,
this
.
options
=
o
!=
null
?
o
:{},
this
.
unbind
=
s
(
this
.
unbind
,
this
),
this
.
bind
=
s
(
this
.
bind
,
this
),
this
.
publish
=
s
(
this
.
publish
,
this
),
this
.
sync
=
s
(
this
.
sync
,
this
),
this
.
set
=
s
(
this
.
set
,
this
),
this
.
formattedValue
=
s
(
this
.
formattedValue
,
this
);
if
(
!
(
this
.
binder
=
e
.
binders
[
n
])){
l
=
e
.
binders
;
for
(
u
in
l
)
f
=
l
[
u
],
u
!==
"*"
&&
u
.
indexOf
(
"*"
)
!==-
1
&&
(
a
=
new
RegExp
(
"^"
+
u
.
replace
(
"*"
,
".+"
)
+
"$"
),
a
.
test
(
n
)
&&
(
this
.
binder
=
f
,
this
.
args
=
(
new
RegExp
(
"^"
+
u
.
replace
(
"*"
,
"(.+)"
)
+
"$"
)).
exec
(
n
),
this
.
args
.
shift
()))}
this
.
binder
||
(
this
.
binder
=
e
.
binders
[
"*"
]),
this
.
binder
instanceof
Function
&&
(
this
.
binder
=
{
routine
:
this
.
binder
}),
this
.
formatters
=
this
.
options
.
formatters
||
[]}
return
t
.
prototype
.
formattedValue
=
function
(
t
){
var
n
,
r
,
i
,
s
,
u
,
a
;
a
=
this
.
formatters
;
for
(
s
=
0
,
u
=
a
.
length
;
s
<
u
;
s
++
)
r
=
a
[
s
],
n
=
r
.
split
(
/
\s
+/
),
i
=
n
.
shift
(),
r
=
this
.
model
[
i
]
instanceof
Function
?
this
.
model
[
i
]:
e
.
formatters
[
i
],(
r
!=
null
?
r
.
read
:
void
0
)
instanceof
Function
?
t
=
r
.
read
.
apply
(
r
,[
t
].
concat
(
o
.
call
(
n
))):
r
instanceof
Function
&&
(
t
=
r
.
apply
(
null
,[
t
].
concat
(
o
.
call
(
n
))));
return
t
},
t
.
prototype
.
set
=
function
(
e
){
var
t
;
return
e
=
e
instanceof
Function
&&!
this
.
binder
[
"function"
]?
this
.
formattedValue
(
e
.
call
(
this
.
model
)):
this
.
formattedValue
(
e
),(
t
=
this
.
binder
.
routine
)
!=
null
?
t
.
call
(
this
,
this
.
el
,
e
):
void
0
},
t
.
prototype
.
sync
=
function
(){
return
this
.
set
(
this
.
options
.
bypass
?
this
.
model
[
this
.
keypath
]:
e
.
config
.
adapter
.
read
(
this
.
model
,
this
.
keypath
))},
t
.
prototype
.
publish
=
function
(){
var
t
,
r
,
i
,
s
,
u
,
a
,
f
,
l
,
c
;
s
=
n
(
this
.
el
),
f
=
this
.
formatters
.
slice
(
0
).
reverse
();
for
(
u
=
0
,
a
=
f
.
length
;
u
<
a
;
u
++
){
r
=
f
[
u
],
t
=
r
.
split
(
/
\s
+/
),
i
=
t
.
shift
();
if
((
l
=
e
.
formatters
[
i
])
!=
null
?
l
.
publish
:
void
0
)
s
=
(
c
=
e
.
formatters
[
i
]).
publish
.
apply
(
c
,[
s
].
concat
(
o
.
call
(
t
)))}
return
e
.
config
.
adapter
.
publish
(
this
.
model
,
this
.
keypath
,
s
)},
t
.
prototype
.
bind
=
function
(){
var
t
,
n
,
r
,
i
,
s
,
o
,
u
,
a
,
f
;(
o
=
this
.
binder
.
bind
)
!=
null
&&
o
.
call
(
this
,
this
.
el
),
this
.
options
.
bypass
?
this
.
sync
():(
e
.
config
.
adapter
.
subscribe
(
this
.
model
,
this
.
keypath
,
this
.
sync
),
e
.
config
.
preloadData
&&
this
.
sync
());
if
((
u
=
this
.
options
.
dependencies
)
!=
null
?
u
.
length
:
void
0
){
a
=
this
.
options
.
dependencies
,
f
=
[];
for
(
i
=
0
,
s
=
a
.
length
;
i
<
s
;
i
++
)
t
=
a
[
i
],
/^
\.
/
.
test
(
t
)?(
r
=
this
.
model
,
n
=
t
.
substr
(
1
)):(
t
=
t
.
split
(
"."
),
r
=
this
.
view
.
models
[
t
.
shift
()],
n
=
t
.
join
(
"."
)),
f
.
push
(
e
.
config
.
adapter
.
subscribe
(
r
,
n
,
this
.
sync
));
return
f
}},
t
.
prototype
.
unbind
=
function
(){
var
t
,
n
,
r
,
i
,
s
,
o
,
u
,
a
,
f
;(
o
=
this
.
binder
.
unbind
)
!=
null
&&
o
.
call
(
this
,
this
.
el
),
this
.
options
.
bypass
||
e
.
config
.
adapter
.
unsubscribe
(
this
.
model
,
this
.
keypath
,
this
.
sync
);
if
((
u
=
this
.
options
.
dependencies
)
!=
null
?
u
.
length
:
void
0
){
a
=
this
.
options
.
dependencies
,
f
=
[];
for
(
i
=
0
,
s
=
a
.
length
;
i
<
s
;
i
++
)
t
=
a
[
i
],
/^
\.
/
.
test
(
t
)?(
r
=
this
.
model
,
n
=
t
.
substr
(
1
)):(
t
=
t
.
split
(
"."
),
r
=
this
.
view
.
models
[
t
.
shift
()],
n
=
t
.
join
(
"."
)),
f
.
push
(
e
.
config
.
adapter
.
unsubscribe
(
r
,
n
,
this
.
sync
));
return
f
}},
t
}(),
e
.
View
=
function
(){
function
t
(
e
,
t
){
this
.
els
=
e
,
this
.
models
=
t
,
this
.
publish
=
s
(
this
.
publish
,
this
),
this
.
sync
=
s
(
this
.
sync
,
this
),
this
.
unbind
=
s
(
this
.
unbind
,
this
),
this
.
bind
=
s
(
this
.
bind
,
this
),
this
.
select
=
s
(
this
.
select
,
this
),
this
.
build
=
s
(
this
.
build
,
this
),
this
.
bindingRegExp
=
s
(
this
.
bindingRegExp
,
this
),
this
.
els
.
jquery
||
this
.
els
instanceof
Array
||
(
this
.
els
=
[
this
.
els
]),
this
.
build
()}
return
t
.
prototype
.
bindingRegExp
=
function
(){
var
t
;
return
t
=
e
.
config
.
prefix
,
t
?
new
RegExp
(
"^data-"
+
t
+
"-"
):
/^data-/
},
t
.
prototype
.
build
=
function
(){
var
t
,
n
,
r
,
i
,
s
,
o
,
a
,
f
,
l
,
c
,
h
,
p
=
this
;
this
.
bindings
=
[],
s
=
[],
t
=
this
.
bindingRegExp
(),
i
=
function
(
n
){
var
r
,
i
,
o
,
a
,
f
,
l
,
c
,
h
,
d
,
v
,
m
,
g
,
y
,
b
,
w
,
E
,
S
,
x
,
T
,
N
,
C
,
k
,
L
,
A
,
O
,
M
,
_
,
D
,
P
;
if
(
u
.
call
(
s
,
n
)
<
0
){
M
=
n
.
attributes
;
for
(
N
=
0
,
L
=
M
.
length
;
N
<
L
;
N
++
){
r
=
M
[
N
];
if
(
t
.
test
(
r
.
name
)){
x
=
r
.
name
.
replace
(
t
,
""
);
if
(
!
(
o
=
e
.
binders
[
x
])){
_
=
e
.
binders
;
for
(
h
in
_
)
T
=
_
[
h
],
h
!==
"*"
&&
h
.
indexOf
(
"*"
)
!==-
1
&&
(
E
=
new
RegExp
(
"^"
+
h
.
replace
(
"*"
,
".+"
)
+
"$"
),
E
.
test
(
x
)
&&
(
o
=
T
))}
o
||
(
o
=
e
.
binders
[
"*"
]);
if
(
o
.
block
){
D
=
n
.
getElementsByTagName
(
"*"
);
for
(
C
=
0
,
A
=
D
.
length
;
C
<
A
;
C
++
)
m
=
D
[
C
],
s
.
push
(
m
);
i
=
[
r
]}}}
P
=
i
||
n
.
attributes
;
for
(
k
=
0
,
O
=
P
.
length
;
k
<
O
;
k
++
){
r
=
P
[
k
];
if
(
t
.
test
(
r
.
name
)){
g
=
{},
x
=
r
.
name
.
replace
(
t
,
""
),
w
=
function
(){
var
e
,
t
,
n
,
i
;
n
=
r
.
value
.
split
(
"|"
),
i
=
[];
for
(
e
=
0
,
t
=
n
.
length
;
e
<
t
;
e
++
)
b
=
n
[
e
],
i
.
push
(
b
.
trim
());
return
i
}(),
f
=
function
(){
var
e
,
t
,
n
,
r
;
n
=
w
.
shift
().
split
(
"<"
),
r
=
[];
for
(
e
=
0
,
t
=
n
.
length
;
e
<
t
;
e
++
)
l
=
n
[
e
],
r
.
push
(
l
.
trim
());
return
r
}(),
y
=
f
.
shift
(),
S
=
y
.
split
(
/
\.
|:/
),
g
.
formatters
=
w
,
g
.
bypass
=
y
.
indexOf
(
":"
)
!==-
1
,
g
.
bindContext
=
p
.
models
,
S
[
0
]?
v
=
p
.
models
[
S
.
shift
()]:(
v
=
p
.
models
,
S
.
shift
()),
d
=
S
.
join
(
"."
);
if
(
v
){
if
(
c
=
f
.
shift
())
g
.
dependencies
=
c
.
split
(
/
\s
+/
);
a
=
new
e
.
Binding
(
n
,
x
,
v
,
d
,
g
),
a
.
view
=
p
,
p
.
bindings
.
push
(
a
)}}}
i
&&
(
i
=
null
)}},
c
=
this
.
els
;
for
(
o
=
0
,
f
=
c
.
length
;
o
<
f
;
o
++
){
n
=
c
[
o
],
i
(
n
),
h
=
n
.
getElementsByTagName
(
"*"
);
for
(
a
=
0
,
l
=
h
.
length
;
a
<
l
;
a
++
)
r
=
h
[
a
],
r
.
attributes
!=
null
&&
i
(
r
)}},
t
.
prototype
.
select
=
function
(
e
){
var
t
,
n
,
r
,
i
,
s
;
i
=
this
.
bindings
,
s
=
[];
for
(
n
=
0
,
r
=
i
.
length
;
n
<
r
;
n
++
)
t
=
i
[
n
],
e
(
t
)
&&
s
.
push
(
t
);
return
s
},
t
.
prototype
.
bind
=
function
(){
var
e
,
t
,
n
,
r
,
i
;
r
=
this
.
bindings
,
i
=
[];
for
(
t
=
0
,
n
=
r
.
length
;
t
<
n
;
t
++
)
e
=
r
[
t
],
i
.
push
(
e
.
bind
());
return
i
},
t
.
prototype
.
unbind
=
function
(){
var
e
,
t
,
n
,
r
,
i
;
r
=
this
.
bindings
,
i
=
[];
for
(
t
=
0
,
n
=
r
.
length
;
t
<
n
;
t
++
)
e
=
r
[
t
],
i
.
push
(
e
.
unbind
());
return
i
},
t
.
prototype
.
sync
=
function
(){
var
e
,
t
,
n
,
r
,
i
;
r
=
this
.
bindings
,
i
=
[];
for
(
t
=
0
,
n
=
r
.
length
;
t
<
n
;
t
++
)
e
=
r
[
t
],
i
.
push
(
e
.
sync
());
return
i
},
t
.
prototype
.
publish
=
function
(){
var
e
,
t
,
n
,
r
,
i
;
r
=
this
.
select
(
function
(
e
){
return
e
.
binder
.
publishes
}),
i
=
[];
for
(
t
=
0
,
n
=
r
.
length
;
t
<
n
;
t
++
)
e
=
r
[
t
],
i
.
push
(
e
.
publish
());
return
i
},
t
}(),
t
=
function
(
e
,
t
,
n
,
r
,
i
){
var
s
;
return
s
=
function
(
e
){
return
n
.
call
(
r
,
e
,
i
)},
window
.
jQuery
!=
null
?(
e
=
jQuery
(
e
),
e
.
on
!=
null
?
e
.
on
(
t
,
s
):
e
.
bind
(
t
,
s
)):
window
.
addEventListener
!=
null
?
e
.
addEventListener
(
t
,
s
,
!
1
):(
t
=
"on"
+
t
,
e
.
attachEvent
(
t
,
s
)),
s
},
i
=
function
(
e
,
t
,
n
){
return
window
.
jQuery
!=
null
?(
e
=
jQuery
(
e
),
e
.
off
!=
null
?
e
.
off
(
t
,
n
):
e
.
unbind
(
t
,
n
)):
window
.
removeEventListener
?
e
.
removeEventListener
(
t
,
n
,
!
1
):(
t
=
"on"
+
t
,
e
.
detachEvent
(
t
,
n
))},
n
=
function
(
e
){
var
t
,
n
,
r
,
i
;
switch
(
e
.
type
){
case
"checkbox"
:
return
e
.
checked
;
case
"select-multiple"
:
i
=
[];
for
(
n
=
0
,
r
=
e
.
length
;
n
<
r
;
n
++
)
t
=
e
[
n
],
t
.
selected
&&
i
.
push
(
t
.
value
);
return
i
;
default
:
return
e
.
value
}},
e
.
binders
=
{
enabled
:
function
(
e
,
t
){
return
e
.
disabled
=!
t
},
disabled
:
function
(
e
,
t
){
return
e
.
disabled
=!!
t
},
checked
:{
publishes
:
!
0
,
bind
:
function
(
e
){
return
this
.
currentListener
=
t
(
e
,
"change"
,
this
.
publish
)},
unbind
:
function
(
e
){
return
i
(
e
,
"change"
,
this
.
currentListener
)},
routine
:
function
(
e
,
t
){
return
e
.
type
===
"radio"
?
e
.
checked
=
e
.
value
===
t
:
e
.
checked
=!!
t
}},
unchecked
:{
publishes
:
!
0
,
bind
:
function
(
e
){
return
this
.
currentListener
=
t
(
e
,
"change"
,
this
.
publish
)},
unbind
:
function
(
e
){
return
i
(
e
,
"change"
,
this
.
currentListener
)},
routine
:
function
(
e
,
t
){
return
e
.
type
===
"radio"
?
e
.
checked
=
e
.
value
!==
t
:
e
.
checked
=!
t
}},
show
:
function
(
e
,
t
){
return
e
.
style
.
display
=
t
?
""
:
"none"
},
hide
:
function
(
e
,
t
){
return
e
.
style
.
display
=
t
?
"none"
:
""
},
html
:
function
(
e
,
t
){
return
e
.
innerHTML
=
t
!=
null
?
t
:
""
},
value
:{
publishes
:
!
0
,
bind
:
function
(
e
){
return
this
.
currentListener
=
t
(
e
,
"change"
,
this
.
publish
)},
unbind
:
function
(
e
){
return
i
(
e
,
"change"
,
this
.
currentListener
)},
routine
:
function
(
e
,
t
){
var
n
,
r
,
i
,
s
,
o
;
if
(
e
.
type
!==
"select-multiple"
)
return
e
.
value
=
t
!=
null
?
t
:
""
;
if
(
t
!=
null
){
o
=
[];
for
(
r
=
0
,
i
=
e
.
length
;
r
<
i
;
r
++
)
n
=
e
[
r
],
o
.
push
(
n
.
selected
=
(
s
=
n
.
value
,
u
.
call
(
t
,
s
)
>=
0
));
return
o
}}},
text
:
function
(
e
,
t
){
return
e
.
innerText
!=
null
?
e
.
innerText
=
t
!=
null
?
t
:
""
:
e
.
textContent
=
t
!=
null
?
t
:
""
},
"on-*"
:{
"function"
:
!
0
,
routine
:
function
(
e
,
n
){
return
this
.
currentListener
&&
i
(
e
,
this
.
args
[
0
],
this
.
currentListener
),
this
.
currentListener
=
t
(
e
,
this
.
args
[
0
],
n
,
this
.
model
,
this
.
options
.
bindContext
)}},
"each-*"
:{
block
:
!
0
,
bind
:
function
(
e
,
t
){
return
e
.
removeAttribute
([
"data"
,
r
.
config
.
prefix
,
this
.
type
].
join
(
"-"
).
replace
(
"--"
,
"-"
))},
routine
:
function
(
e
,
t
){
var
n
,
i
,
s
,
o
,
u
,
a
,
f
,
l
,
c
,
h
,
p
,
d
,
v
,
m
,
g
,
y
,
b
,
w
,
E
;
if
(
this
.
iterated
!=
null
){
g
=
this
.
iterated
;
for
(
c
=
0
,
d
=
g
.
length
;
c
<
d
;
c
++
){
l
=
g
[
c
],
l
.
unbind
(),
y
=
l
.
els
;
for
(
h
=
0
,
v
=
y
.
length
;
h
<
v
;
h
++
)
i
=
y
[
h
],
i
.
parentNode
.
removeChild
(
i
)}}
else
this
.
marker
=
document
.
createComment
(
" rivets: "
+
this
.
type
+
" "
),
e
.
parentNode
.
insertBefore
(
this
.
marker
,
e
),
e
.
parentNode
.
removeChild
(
e
);
this
.
iterated
=
[];
if
(
t
){
E
=
[];
for
(
p
=
0
,
m
=
t
.
length
;
p
<
m
;
p
++
){
s
=
t
[
p
],
n
=
{},
b
=
this
.
view
.
models
;
for
(
a
in
b
)
u
=
b
[
a
],
n
[
a
]
=
u
;
n
[
this
.
args
[
0
]]
=
s
,
o
=
e
.
cloneNode
(
!
0
),
this
.
iterated
.
length
>
0
?
f
=
this
.
iterated
[
this
.
iterated
.
length
-
1
].
els
[
0
]:
f
=
this
.
marker
,
this
.
marker
.
parentNode
.
insertBefore
(
o
,(
w
=
f
.
nextSibling
)
!=
null
?
w
:
null
),
E
.
push
(
this
.
iterated
.
push
(
r
.
bind
(
o
,
n
)))}
return
E
}}},
"class-*"
:
function
(
e
,
t
){
var
n
;
n
=
" "
+
e
.
className
+
" "
;
if
(
!
t
==
(
n
.
indexOf
(
" "
+
this
.
args
[
0
]
+
" "
)
!==-
1
))
return
e
.
className
=
t
?
""
+
e
.
className
+
" "
+
this
.
args
[
0
]:
n
.
replace
(
" "
+
this
.
args
[
0
]
+
" "
,
" "
).
trim
()},
"*"
:
function
(
e
,
t
){
return
t
?
e
.
setAttribute
(
this
.
type
,
t
):
e
.
removeAttribute
(
this
.
type
)}},
e
.
config
=
{
preloadData
:
!
0
},
e
.
formatters
=
{},
r
=
{
binders
:
e
.
binders
,
formatters
:
e
.
formatters
,
config
:
e
.
config
,
configure
:
function
(
t
){
var
n
,
r
;
t
==
null
&&
(
t
=
{});
for
(
n
in
t
)
r
=
t
[
n
],
e
.
config
[
n
]
=
r
},
bind
:
function
(
t
,
n
){
var
r
;
return
n
==
null
&&
(
n
=
{}),
r
=
new
e
.
View
(
t
,
n
),
r
.
bind
(),
r
}},
typeof
module
!=
"undefined"
&&
module
!==
null
?
module
.
exports
=
r
:
this
.
rivets
=
r
}).
call
(
this
);
\ No newline at end of file
(
function
(){
var
e
,
t
,
n
,
r
,
i
,
s
,
o
,
u
,
a
,
f
,
l
,
c
,
h
,
p
=
function
(
e
,
t
){
return
function
(){
return
e
.
apply
(
t
,
arguments
)}},
d
=
[].
slice
,
v
=
[].
indexOf
||
function
(
e
){
for
(
var
t
=
0
,
n
=
this
.
length
;
t
<
n
;
t
++
)
if
(
t
in
this
&&
this
[
t
]
===
e
)
return
t
;
return
-
1
};
e
=
{},
String
.
prototype
.
trim
||
(
String
.
prototype
.
trim
=
function
(){
return
this
.
replace
(
/^
\s
+|
\s
+$/g
,
""
)}),
u
=
function
(
t
){
var
n
,
r
,
i
,
s
,
o
,
u
;
if
(
!
(
r
=
e
.
binders
[
t
])){
r
=
e
.
binders
[
"*"
],
u
=
e
.
binders
;
for
(
i
in
u
)
o
=
u
[
i
],
i
!==
"*"
&&
i
.
indexOf
(
"*"
)
!==-
1
&&
(
s
=
new
RegExp
(
"^"
+
i
.
replace
(
"*"
,
"(.+)"
)
+
"$"
),
s
.
test
(
t
)
&&
(
r
=
o
,
n
=
s
.
exec
(
t
),
n
.
shift
()))}
return
r
instanceof
Function
&&
(
r
=
{
routine
:
r
}),[
r
,
n
]},
e
.
Binding
=
function
(){
function
t
(
e
,
t
,
n
,
r
,
i
){
var
s
;
this
.
el
=
e
,
this
.
type
=
t
,
this
.
model
=
n
,
this
.
keypath
=
r
,
this
.
unbind
=
p
(
this
.
unbind
,
this
),
this
.
bind
=
p
(
this
.
bind
,
this
),
this
.
publish
=
p
(
this
.
publish
,
this
),
this
.
sync
=
p
(
this
.
sync
,
this
),
this
.
set
=
p
(
this
.
set
,
this
),
this
.
formattedValue
=
p
(
this
.
formattedValue
,
this
),
this
.
options
=
i
||
(
i
=
{}),
s
=
i
.
binder
?[
i
.
binder
,
i
.
args
]:
u
(
t
),
this
.
binder
=
s
[
0
],
this
.
args
=
s
[
1
],
this
.
formatters
=
i
.
formatters
||
[]}
return
t
.
prototype
.
formattedValue
=
function
(
t
){
var
n
,
r
,
i
,
s
,
o
,
u
,
a
,
f
;
o
=
this
.
model
,
f
=
this
.
formatters
;
for
(
u
=
0
,
a
=
f
.
length
;
u
<
a
;
u
++
)
r
=
f
[
u
],
n
=
r
.
split
(
/
\s
+/
),
i
=
n
.
shift
(),
s
=
e
.
config
.
adapter
.
read
(
o
,
i
),
r
=
s
instanceof
Function
?
s
:
e
.
formatters
[
i
],(
r
!=
null
?
r
.
read
:
void
0
)
instanceof
Function
?
t
=
r
.
read
.
apply
(
r
,[
t
].
concat
(
d
.
call
(
n
))):
r
instanceof
Function
&&
(
t
=
r
.
apply
(
null
,[
t
].
concat
(
d
.
call
(
n
))));
return
t
},
t
.
prototype
.
set
=
function
(
e
){
var
t
,
n
;
return
t
=
this
.
binder
,
e
=
this
.
formattedValue
(
e
instanceof
Function
&&!
t
[
"function"
]?
e
.
call
(
this
.
model
,
this
.
options
.
bindContext
):
e
),(
n
=
t
.
routine
)
!=
null
?
n
.
call
(
this
,
this
.
el
,
e
):
void
0
},
t
.
prototype
.
sync
=
function
(){
var
t
,
n
;
return
t
=
this
.
keypath
,
n
=
this
.
model
,
this
.
set
(
this
.
options
.
bypass
?
n
[
t
]:
e
.
config
.
adapter
.
read
(
n
,
t
))},
t
.
prototype
.
publish
=
function
(){
var
t
,
n
,
r
,
i
,
s
,
o
,
u
,
f
;
if
(
this
.
binder
.
tokenizes
)
return
;
s
=
a
(
this
.
el
),
f
=
this
.
formatters
.
slice
(
0
).
reverse
();
for
(
o
=
0
,
u
=
f
.
length
;
o
<
u
;
o
++
){
r
=
f
[
o
],
t
=
r
.
split
(
/
\s
+/
),
i
=
t
.
shift
(),
n
=
e
.
formatters
[
i
];
if
(
n
!=
null
?
n
.
publish
:
void
0
)
s
=
n
.
publish
.
apply
(
n
,[
s
].
concat
(
d
.
call
(
t
)))}
return
e
.
config
.
adapter
.
publish
(
this
.
model
,
this
.
keypath
,
s
)},
t
.
prototype
.
bind
=
function
(){
var
t
,
n
=
this
;
return
(
t
=
this
.
binder
.
bind
)
!=
null
&&
t
.
call
(
this
,
this
.
el
),
this
.
options
.
bypass
?
this
.
sync
():(
this
.
keypath
&&!
this
.
binder
.
tokenizes
&&
e
.
config
.
adapter
.
subscribe
(
this
.
model
,
this
.
keypath
,
this
.
sync
),
e
.
config
.
preloadData
&&
this
.
sync
()),
l
(
this
,
function
(
t
,
r
){
return
e
.
config
.
adapter
.
subscribe
(
t
,
r
,
n
.
sync
)})},
t
.
prototype
.
unbind
=
function
(){
var
t
,
n
=
this
;
return
(
t
=
this
.
binder
.
unbind
)
!=
null
&&
t
.
call
(
this
,
this
.
el
),
!
this
.
options
.
bypass
&&!!
this
.
binder
.
tokenizes
&&
this
.
keypath
&&
e
.
config
.
adapter
.
unsubscribe
(
this
.
model
,
this
.
keypath
,
this
.
sync
),
l
(
this
,
function
(
t
,
r
){
return
e
.
config
.
adapter
.
unsubscribe
(
t
,
r
,
n
.
sync
)})},
t
}(),
l
=
function
(
t
,
n
){
var
r
,
i
,
s
,
o
,
u
,
a
,
f
,
l
;
if
((
a
=
t
.
options
.
dependencies
)
!=
null
?
a
.
length
:
void
0
){
f
=
t
.
options
.
dependencies
,
l
=
[];
for
(
o
=
0
,
u
=
f
.
length
;
o
<
u
;
o
++
)
r
=
f
[
o
],
/^
\.
/
.
test
(
r
)?(
s
=
t
.
model
,
i
=
r
.
substr
(
1
)):(
r
=
r
.
split
(
"."
),
s
=
e
.
config
.
adapter
.
read
(
t
.
view
.
models
(
r
.
shift
())),
i
=
r
.
join
(
"."
)),
l
.
push
(
n
(
s
,
i
));
return
l
}},
o
=
/
(
.*
?)\{\{([^
{}
]
+
)\}\}
/
,
i
=
function
(
e
,
t
,
n
){
return
t
[
n
]
=
null
,{
routine
:
function
(
r
,
i
){
return
t
[
n
]
=
i
,
e
.
sync
()}}},
s
=
function
(
t
,
n
,
r
,
a
,
f
){
var
l
,
c
,
h
,
p
,
d
,
v
,
m
,
g
,
y
,
b
,
w
,
E
,
S
,
x
,
T
,
N
,
C
,
k
,
L
,
A
,
O
,
M
;
if
(
o
.
test
(
f
)){
p
=
new
e
.
Binding
(
n
,
r
,
a
),
O
=
[],
L
=
[];
while
(
f
&&
o
.
test
(
f
))
b
=
o
.
exec
(
f
),
f
=
f
.
substring
(
b
[
0
].
length
),
b
[
1
]
&&
(
O
[
O
.
length
]
=
b
[
1
]),
L
[
L
.
length
]
=
k
=
s
(
t
,
null
,
"*"
,
a
,
b
[
2
]),
k
.
binder
=
i
(
p
,
O
,
O
.
length
);
return
f
&&
(
O
[
O
.
length
]
=
f
),
l
=
p
.
bind
,
A
=
p
.
unbind
,
p
.
sync
=
function
(){
return
p
.
set
(
O
.
join
(
""
))},
p
.
publish
=
function
(){},
p
.
bind
=
function
(){
var
e
,
t
,
n
,
r
;
l
(),
r
=
[];
for
(
t
=
0
,
n
=
L
.
length
;
t
<
n
;
t
++
)
e
=
L
[
t
],
r
.
push
(
e
.
bind
());
return
r
},
p
.
unbind
=
function
(){
var
e
,
t
,
n
,
r
;
A
(),
r
=
[];
for
(
t
=
0
,
n
=
L
.
length
;
t
<
n
;
t
++
)
e
=
L
[
t
],
r
.
push
(
e
.
unbind
());
return
r
},
p
}
N
=
function
(){
var
e
,
t
,
n
,
r
;
n
=
f
.
split
(
"|"
),
r
=
[];
for
(
e
=
0
,
t
=
n
.
length
;
e
<
t
;
e
++
)
T
=
n
[
e
],
r
.
push
(
T
.
trim
());
return
r
}(),
d
=
function
(){
var
e
,
t
,
n
,
r
;
n
=
N
.
shift
().
split
(
"<"
),
r
=
[];
for
(
e
=
0
,
t
=
n
.
length
;
e
<
t
;
e
++
)
v
=
n
[
e
],
r
.
push
(
v
.
trim
());
return
r
}(),
x
=
d
.
shift
(),
C
=
x
.
split
(
/
\.
|:/
),
E
=
{
formatters
:
N
,
bypass
:
x
.
indexOf
(
":"
)
!==-
1
,
bindContext
:
a
},
S
=
e
.
config
.
adapter
.
parsingSupport
,
M
=
u
(
r
),
c
=
M
[
0
],
E
.
args
=
M
[
1
],
h
=
c
.
tokenizes
,
E
.
binder
=
c
,
g
=
S
||
h
?
C
[
0
]:
C
.
shift
(),
w
=
g
||!
h
?
e
.
config
.
adapter
.
read
(
a
,
g
):
a
,
y
=
C
.
join
(
"."
);
if
(
w
||
h
){
if
(
m
=
d
.
shift
())
E
.
dependencies
=
m
.
split
(
/
\s
+/
);
p
=
new
e
.
Binding
(
n
,
r
,
S
?
a
:
w
,
y
,
E
),
p
.
view
=
t
}
return
p
},
e
.
View
=
function
(){
function
t
(
e
,
t
){
this
.
models
=
t
,
this
.
publish
=
p
(
this
.
publish
,
this
),
this
.
sync
=
p
(
this
.
sync
,
this
),
this
.
unbind
=
p
(
this
.
unbind
,
this
),
this
.
bind
=
p
(
this
.
bind
,
this
),
this
.
select
=
p
(
this
.
select
,
this
),
this
.
build
=
p
(
this
.
build
,
this
),
this
.
bindingRegExp
=
p
(
this
.
bindingRegExp
,
this
),
this
.
els
=
e
.
jquery
||
e
instanceof
Array
?
e
:[
e
],
this
.
build
()}
return
t
.
prototype
.
bindingRegExp
=
function
(){
var
t
;
return
t
=
e
.
config
.
prefix
,
t
?
new
RegExp
(
"^data-"
+
t
+
"-"
):
/^data-/
},
t
.
prototype
.
build
=
function
(){
var
t
,
n
,
r
,
i
,
o
,
u
,
a
,
f
,
l
,
c
,
h
,
p
,
d
=
this
;
n
=
this
.
bindings
=
[],
u
=
[],
t
=
this
.
bindingRegExp
(),
o
=
function
(
r
){
var
i
,
o
,
a
,
f
,
l
,
c
,
h
,
p
,
m
,
g
,
y
,
b
,
w
,
E
,
S
,
x
,
T
,
N
,
C
;
if
(
v
.
call
(
u
,
r
)
<
0
){
x
=
r
.
attributes
;
for
(
g
=
0
,
w
=
x
.
length
;
g
<
w
;
g
++
){
i
=
x
[
g
];
if
(
t
.
test
(
i
.
name
)){
p
=
i
.
name
.
replace
(
t
,
""
);
if
(
!
(
a
=
e
.
binders
[
p
])){
T
=
e
.
binders
;
for
(
l
in
T
)
m
=
T
[
l
],
l
!==
"*"
&&
l
.
indexOf
(
"*"
)
!==-
1
&&
(
h
=
new
RegExp
(
"^"
+
l
.
replace
(
"*"
,
".+"
)
+
"$"
),
h
.
test
(
p
)
&&
(
a
=
m
))}
a
||
(
a
=
e
.
binders
[
"*"
]);
if
(
a
.
block
){
N
=
r
.
getElementsByTagName
(
"*"
);
for
(
y
=
0
,
E
=
N
.
length
;
y
<
E
;
y
++
)
c
=
N
[
y
],
u
.
push
(
c
);
o
=
[
i
]}}}
C
=
o
||
r
.
attributes
;
for
(
b
=
0
,
S
=
C
.
length
;
b
<
S
;
b
++
)
i
=
C
[
b
],
t
.
test
(
i
.
name
)
&&
(
p
=
i
.
name
.
replace
(
t
,
""
),
f
=
s
(
d
,
r
,
p
,
d
.
models
,
i
.
value
),
f
&&
n
.
push
(
f
));
o
&&
(
o
=
null
)}},
h
=
this
.
els
;
for
(
a
=
0
,
l
=
h
.
length
;
a
<
l
;
a
++
){
r
=
h
[
a
],
r
.
attributes
!=
null
&&
o
(
r
),
p
=
r
.
getElementsByTagName
(
"*"
);
for
(
f
=
0
,
c
=
p
.
length
;
f
<
c
;
f
++
)
i
=
p
[
f
],
i
.
attributes
!=
null
&&
o
(
i
)}},
t
.
prototype
.
select
=
function
(
e
){
var
t
,
n
,
r
,
i
,
s
;
i
=
this
.
bindings
,
s
=
[];
for
(
n
=
0
,
r
=
i
.
length
;
n
<
r
;
n
++
)
t
=
i
[
n
],
e
(
t
)
&&
s
.
push
(
t
);
return
s
},
t
.
prototype
.
bind
=
function
(){
return
this
.
bindings
.
map
(
function
(
e
){
return
e
.
bind
()})},
t
.
prototype
.
unbind
=
function
(){
return
this
.
bindings
.
map
(
function
(
e
){
return
e
.
unbind
()})},
t
.
prototype
.
sync
=
function
(){
return
this
.
bindings
.
map
(
function
(
e
){
return
e
.
sync
()})},
t
.
prototype
.
publish
=
function
(){
return
this
.
select
(
function
(
e
){
return
e
.
binder
.
publishes
}).
map
(
function
(
e
){
return
e
.
publish
()})},
t
}(),
t
=
function
(
e
,
t
,
n
,
r
,
i
){
var
s
;
return
s
=
function
(
e
){
return
n
.
call
(
r
,
e
,
i
)},
window
.
jQuery
!=
null
?(
e
=
jQuery
(
e
),
e
.
on
!=
null
?
e
.
on
(
t
,
s
):
e
.
bind
(
t
,
s
)):
window
.
addEventListener
!=
null
?
e
.
addEventListener
(
t
,
s
,
!
1
):(
t
=
"on"
+
t
,
e
.
attachEvent
(
t
,
s
)),
s
},
h
=
function
(
e
,
t
,
n
){
return
window
.
jQuery
!=
null
?(
e
=
jQuery
(
e
),
e
.
off
!=
null
?
e
.
off
(
t
,
n
):
e
.
unbind
(
t
,
n
)):
window
.
removeEventListener
?
e
.
removeEventListener
(
t
,
n
,
!
1
):(
t
=
"on"
+
t
,
e
.
detachEvent
(
t
,
n
))},
a
=
function
(
e
){
var
t
,
n
,
r
,
i
;
switch
(
e
.
type
){
case
"checkbox"
:
return
e
.
checked
;
case
"select-multiple"
:
i
=
[];
for
(
n
=
0
,
r
=
e
.
length
;
n
<
r
;
n
++
)
t
=
e
[
n
],
t
.
selected
&&
i
.
push
(
t
.
value
);
return
i
;
default
:
return
e
.
value
}},
f
=
function
(
t
,
n
){
var
r
,
i
,
s
,
o
,
u
,
a
,
f
,
l
;
if
(
e
.
config
.
adapter
.
iterate
)
return
e
.
config
.
adapter
.
iterate
(
t
,
n
);
if
(
t
instanceof
Array
){
f
=
[];
for
(
r
=
u
=
0
,
a
=
t
.
length
;
u
<
a
;
r
=++
u
)
i
=
t
[
r
],
f
.
push
(
n
(
i
,
r
));
return
f
}
l
=
[];
for
(
o
in
t
)
s
=
t
[
o
],
l
.
push
(
n
(
s
,
o
));
return
l
},
n
=
function
(
t
){
return
e
.
config
.
adapter
.
convertToModel
?
e
.
config
.
adapter
.
convertToModel
(
t
):
t
},
r
=
function
(
e
){
return
{
publishes
:
!
0
,
bind
:
function
(
e
){
return
this
.
currentListener
=
t
(
e
,
"change"
,
this
.
publish
)},
unbind
:
function
(
e
){
return
h
(
e
,
"change"
,
this
.
currentListener
)},
routine
:
e
}},
e
.
binders
=
{
enabled
:
function
(
e
,
t
){
return
e
.
disabled
=!
t
},
disabled
:
function
(
e
,
t
){
return
e
.
disabled
=!!
t
},
checked
:
r
(
function
(
e
,
t
){
return
e
.
checked
=
e
.
type
===
"radio"
?
e
.
value
===
t
:
!!
t
}),
unchecked
:
r
(
function
(
e
,
t
){
return
e
.
checked
=
e
.
type
===
"radio"
?
e
.
value
!==
t
:
!
t
}),
show
:
function
(
e
,
t
){
return
e
.
style
.
display
=
t
?
""
:
"none"
},
hide
:
function
(
e
,
t
){
return
e
.
style
.
display
=
t
?
"none"
:
""
},
html
:
function
(
e
,
t
){
return
e
.
innerHTML
=
t
!=
null
?
t
:
""
},
value
:
r
(
function
(
e
,
t
){
var
n
,
r
,
i
,
s
,
o
;
if
(
e
.
type
!==
"select-multiple"
)
return
e
.
value
=
t
!=
null
?
t
:
""
;
if
(
t
!=
null
){
o
=
[];
for
(
r
=
0
,
i
=
e
.
length
;
r
<
i
;
r
++
)
n
=
e
[
r
],
o
.
push
(
n
.
selected
=
(
s
=
n
.
value
,
v
.
call
(
t
,
s
)
>=
0
));
return
o
}}),
text
:
function
(
e
,
t
){
var
n
;
return
n
=
t
!=
null
?
t
:
""
,
e
.
innerText
!=
null
?
e
.
innerText
=
n
:
e
.
textContent
=
n
},
"on-*"
:{
"function"
:
!
0
,
routine
:
function
(
e
,
n
){
var
r
,
i
;
return
i
=
this
.
args
[
0
],
r
=
this
.
currentListener
,
r
&&
h
(
e
,
i
,
r
),
this
.
currentListener
=
t
(
e
,
i
,
n
,
this
.
model
,
this
.
options
.
bindContext
)}},
"each-*"
:{
block
:
!
0
,
bind
:
function
(
e
,
t
){
return
e
.
removeAttribute
([
"data"
,
c
.
config
.
prefix
,
this
.
type
].
join
(
"-"
).
replace
(
"--"
,
"-"
))},
routine
:
function
(
e
,
t
){
var
r
,
i
,
s
,
o
,
u
,
a
,
l
,
h
,
p
,
d
,
v
=
this
;
i
=
this
.
iterated
;
if
(
i
!=
null
)
for
(
a
=
0
,
h
=
i
.
length
;
a
<
h
;
a
++
){
u
=
i
[
a
],
u
.
unbind
(),
d
=
u
.
els
;
for
(
l
=
0
,
p
=
d
.
length
;
l
<
p
;
l
++
)
r
=
d
[
l
],
r
.
parentNode
.
removeChild
(
r
)}
else
s
=
this
.
marker
=
document
.
createComment
(
" rivets: "
+
this
.
type
+
" "
),
o
=
e
.
parentNode
,
o
.
insertBefore
(
s
,
e
),
o
.
removeChild
(
e
);
this
.
iterated
=
i
=
[];
if
(
t
)
return
s
=
this
.
marker
,
f
(
t
,
function
(
t
,
r
){
var
o
,
u
,
a
,
l
;
return
o
=
{},
f
(
v
.
view
.
models
,
function
(
e
,
t
){
return
o
[
t
]
=
e
}),
o
[
v
.
args
[
0
]]
=
t
,
o
[
""
+
v
.
args
[
0
]
+
"_index"
]
=
o
.
rivets_index
=
r
,
o
=
n
(
o
),
u
=
e
.
cloneNode
(
!
0
),
a
=
i
.
length
>
0
?
i
[
i
.
length
-
1
].
els
[
0
]:
s
,
s
.
parentNode
.
insertBefore
(
u
,(
l
=
a
.
nextSibling
)
!=
null
?
l
:
null
),
i
.
push
(
c
.
bind
(
u
,
o
))})}},
"class-*"
:
function
(
e
,
t
){
var
n
;
n
=
" "
+
e
.
className
+
" "
;
if
(
!
t
==
(
n
.
indexOf
(
" "
+
this
.
args
[
0
]
+
" "
)
!==-
1
))
return
e
.
className
=
t
?
""
+
e
.
className
+
" "
+
this
.
args
[
0
]:
n
.
replace
(
" "
+
this
.
args
[
0
]
+
" "
,
" "
).
trim
()},
"*"
:
function
(
e
,
t
){
return
t
?
e
.
setAttribute
(
this
.
type
,
t
):
e
.
removeAttribute
(
this
.
type
)}},
e
.
config
=
{
preloadData
:
!
0
},
e
.
formatters
=
{},
c
=
{
binders
:
e
.
binders
,
formatters
:
e
.
formatters
,
config
:
e
.
config
,
configure
:
function
(
t
){
var
n
,
r
;
t
||
(
t
=
{});
for
(
n
in
t
)
r
=
t
[
n
],
e
.
config
[
n
]
=
r
},
bind
:
function
(
t
,
n
){
var
r
;
return
n
||
(
n
=
{}),
r
=
new
e
.
View
(
t
,
n
),
r
.
bind
(),
r
}},
typeof
module
!=
"undefined"
&&
module
!==
null
?
module
.
exports
=
c
:
this
.
rivets
=
c
}).
call
(
this
);
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment