Permalink
Browse files

m

  • Loading branch information...
1 parent d2307a8 commit 0bc2fe7f93c4b361c1780be29ac652c12426571e @soney committed Jun 6, 2012
Showing with 52 additions and 6 deletions.
  1. +42 −6 demo/files/files_template.ejs.html
  2. +1 −0 include_libs.js
  3. +5 −0 src/constraint/cjs_anim.js
  4. +4 −0 src/template/handlebars_template.js
@@ -92,8 +92,6 @@
var filenames = cjs.async(function(on_success, on_fail) {
list_files(path.get(), on_success, on_fail);
});
- filenames = cjs(["file1.txt"]);
- filenames.state = cjs.fsm().add_state("resolved");
var filetypes = filenames.map(function(filename) {
var filetype = cjs.async(function(on_success, on_fail) {
get_file_type(path.get() + "/" + filename, on_success, on_fail);
@@ -110,6 +108,48 @@
window.filetypes = filetypes;
var template;
template = cjs.template("#filelist");
+ template = function(obj) {
+ with (obj) {
+ return cjs.create('dom_element', 'span', {} // (root)
+ , cjs.create('fsm_constraint', files.state, { // {{#diagram files.item('state')}}
+ 'pending': [
+ cjs.create('dom_text', 'Loading...') // (text /)
+ ], 'resolved': [
+ files.map(function(filename, index) { // {{#each files}}
+ return [ // {{#each}}
+ cjs.create('fsm_constraint', filetypes.item(index).item('state'), { // {{#diagram filetypes.item(index).item('state')}}
+ 'pending': [
+ cjs.create('dom_element', 'div', { // <div>
+ 'class': cjs.concat('loading')
+ }
+ , cjs.create('dom_text', '...') // (text /)
+ ) // </div>
+ ], 'resolved': [
+ , cjs.create('dom_element', 'div', { // <div>
+ 'class': cjs.concat('resolved')
+ }
+ , cjs.create('dom_text', filename) // {{filename}}
+ , cjs.create('dom_text', ' ') // (text /)
+ , cjs.create('dom_text', filetypes.item(index)) // {{filetypes[index]}}
+ ) // </div>
+ ], 'rejected': [
+ cjs.create('dom_element', 'div', { // <div>
+ 'class': cjs.concat('error')
+ }
+ , cjs.create('dom_text', 'error') // (text /)
+ ) // </div>
+ ]
+ }) // {/diagram}
+ ];
+ }) // {{/each}}
+ ], 'rejected': [
+ cjs.create('dom_text', 'Error') // (text /)
+ ]
+ }) // {/diagram}
+ ); // (/root)
+ }
+ };
+ /*
template = function (obj) {
with(obj) {
return cjs.create('dom_element', 'span', {} // (root)
@@ -118,15 +158,12 @@
'pending': [
cjs.create('dom_text', 'Loading...') // (text /)
], 'resolved': [
- cjs.create('dom_text', 'OK') // (text /)
- /*
files.map(function(filename, index) { // {{#each files}}
return [ // {{#each}}
(function() {
with(cjs.constraint.item(filetypes, cjs.get(index))) { // {{#with filetypes[index]}}
var filetype = cjs.constraint.item(filetypes, cjs.get(index));
var state = cjs.constraint.item(filetypes, cjs.get(index), "state");
- console.log(filetype, filetype.get(), state, state.get());
return [
cjs.create('fsm_constraint', cjs.constraint.item(filetype, "state"), { // {{#diagram filetype.state}}
@@ -145,7 +182,6 @@
}
}()) // {{/with}}
];}) // {{/each}}
- */
]
, 'rejected': [
cjs.create('dom_text', 'Error') // (text /)
View
@@ -39,6 +39,7 @@ exports.main_src = c(
, "constraint/cjs_dom_constraints.js"
, "constraint/cjs_dom_mixins.js"
, "constraint/cjs_input_widgets.js"
+ , "constraint/cjs_anim.js"
, "binding/cjs_binding.js"
, "binding/cjs_dom_bindings.js"
, "binding/cjs_form_bindings.js"
@@ -0,0 +1,5 @@
+(function (cjs) {
+var _ = cjs._;
+cjs.constraint.mixin("anim", function() {
+});
+}(cjs));
@@ -11,6 +11,10 @@
var parent_text = parsed_var_fn_val(parent);
var child_text = parsed_var_fn_val(child);
if(subtype === "square_brackets") {
+ if(child.type === "constant" && child.subtype === "string") {
+ child_text = '"' + child_text + '"';
+ }
+
return parent_text + ".item(" + child_text + ")";
} else if(subtype === "dot") {
return parent_text + ".item('" + child_text + "')";

0 comments on commit 0bc2fe7

Please sign in to comment.