Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
todomvc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eugene Shen
todomvc
Commits
84b4a7b6
Commit
84b4a7b6
authored
Jul 26, 2012
by
Ralph Holzmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated can.each param order in each example.
parent
9447769a
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
51 additions
and
52 deletions
+51
-52
labs/architecture-examples/canjs/dojo-widget/todo.js
labs/architecture-examples/canjs/dojo-widget/todo.js
+4
-4
labs/architecture-examples/canjs/dojo/todo.js
labs/architecture-examples/canjs/dojo/todo.js
+4
-4
labs/architecture-examples/canjs/jquery-widget/todo.js
labs/architecture-examples/canjs/jquery-widget/todo.js
+5
-8
labs/architecture-examples/canjs/jquery/todo.js
labs/architecture-examples/canjs/jquery/todo.js
+17
-15
labs/architecture-examples/canjs/mootools/todo.js
labs/architecture-examples/canjs/mootools/todo.js
+5
-5
labs/architecture-examples/canjs/yui-widget/todo.js
labs/architecture-examples/canjs/yui-widget/todo.js
+5
-5
labs/architecture-examples/canjs/yui/todo.js
labs/architecture-examples/canjs/yui/todo.js
+5
-5
labs/architecture-examples/canjs/zepto/todo.js
labs/architecture-examples/canjs/zepto/todo.js
+6
-6
No files found.
labs/architecture-examples/canjs/dojo-widget/todo.js
View file @
84b4a7b6
...
...
@@ -33,7 +33,7 @@ Todo = can.Model({
data
=
dojo
.
fromJson
(
window
.
localStorage
[
name
]
||
(
window
.
localStorage
[
name
]
=
'
[]
'
)
),
res
=
cb
.
call
(
this
,
data
);
if
(
res
!==
false
){
can
.
each
(
data
,
function
(
i
,
todo
)
{
can
.
each
(
data
,
function
(
todo
)
{
delete
todo
.
editing
;
});
window
.
localStorage
[
name
]
=
dojo
.
toJson
(
data
);
...
...
@@ -45,7 +45,7 @@ Todo = can.Model({
this
.
localStore
(
function
(
todos
){
var
instances
=
[],
self
=
this
;
can
.
each
(
todos
,
function
(
i
,
todo
)
{
can
.
each
(
todos
,
function
(
todo
)
{
instances
.
push
(
new
self
(
todo
));
});
def
.
resolve
({
data
:
instances
});
...
...
@@ -128,7 +128,7 @@ Todo.List = can.Model.List({
this
.
attr
(
'
length
'
);
var
completed
=
0
;
this
.
each
(
function
(
i
,
todo
)
{
this
.
each
(
function
(
todo
)
{
completed
+=
todo
.
attr
(
'
complete
'
)
?
1
:
0
});
return
completed
;
...
...
@@ -223,7 +223,7 @@ Todos = can.Control({
// Listen for toggle all completed Todos
'
#toggle-all click
'
:
function
(
el
,
ev
)
{
var
toggle
=
el
.
attr
(
'
checked
'
)[
0
];
can
.
each
(
this
.
options
.
todos
,
function
(
i
,
todo
)
{
can
.
each
(
this
.
options
.
todos
,
function
(
todo
)
{
todo
.
attr
(
'
complete
'
,
toggle
).
save
();
});
},
...
...
labs/architecture-examples/canjs/dojo/todo.js
View file @
84b4a7b6
...
...
@@ -22,7 +22,7 @@ Todo = can.Model({
data
=
dojo
.
fromJson
(
window
.
localStorage
[
name
]
||
(
window
.
localStorage
[
name
]
=
'
[]
'
)
),
res
=
cb
.
call
(
this
,
data
);
if
(
res
!==
false
){
can
.
each
(
data
,
function
(
i
,
todo
)
{
can
.
each
(
data
,
function
(
todo
)
{
delete
todo
.
editing
;
});
window
.
localStorage
[
name
]
=
dojo
.
toJson
(
data
);
...
...
@@ -34,7 +34,7 @@ Todo = can.Model({
this
.
localStore
(
function
(
todos
){
var
instances
=
[],
self
=
this
;
can
.
each
(
todos
,
function
(
i
,
todo
)
{
can
.
each
(
todos
,
function
(
todo
)
{
instances
.
push
(
new
self
(
todo
));
});
def
.
resolve
({
data
:
instances
});
...
...
@@ -91,7 +91,7 @@ Todo.List = can.Model.List({
this
.
attr
(
'
length
'
);
var
completed
=
0
;
this
.
each
(
function
(
i
,
todo
)
{
this
.
each
(
function
(
todo
)
{
completed
+=
todo
.
attr
(
'
complete
'
)
?
1
:
0
});
return
completed
;
...
...
@@ -178,7 +178,7 @@ Todos = can.Control({
// Listen for toggle all completed Todos
'
#toggle-all click
'
:
function
(
el
,
ev
)
{
var
toggle
=
el
.
attr
(
'
checked
'
)[
0
];
can
.
each
(
this
.
options
.
todos
,
function
(
i
,
todo
)
{
can
.
each
(
this
.
options
.
todos
,
function
(
todo
)
{
todo
.
attr
(
'
complete
'
,
toggle
).
save
();
});
},
...
...
labs/architecture-examples/canjs/jquery-widget/todo.js
View file @
84b4a7b6
...
...
@@ -17,7 +17,7 @@ Todo = can.Model({
data
=
JSON
.
parse
(
window
.
localStorage
[
name
]
||
(
window
.
localStorage
[
name
]
=
'
[]
'
)
),
res
=
cb
.
call
(
this
,
data
);
if
(
res
!==
false
){
can
.
each
(
data
,
function
(
i
,
todo
)
{
can
.
each
(
data
,
function
(
todo
)
{
delete
todo
.
editing
;
});
window
.
localStorage
[
name
]
=
JSON
.
stringify
(
data
);
...
...
@@ -29,7 +29,7 @@ Todo = can.Model({
this
.
localStore
(
function
(
todos
){
var
instances
=
[],
self
=
this
;
can
.
each
(
todos
,
function
(
i
,
todo
)
{
can
.
each
(
todos
,
function
(
todo
)
{
instances
.
push
(
new
self
(
todo
));
});
def
.
resolve
({
data
:
instances
});
...
...
@@ -113,7 +113,7 @@ Todo.List = can.Model.List({
this
.
attr
(
'
length
'
);
var
completed
=
0
;
this
.
each
(
function
(
i
,
todo
)
{
this
.
each
(
function
(
todo
)
{
completed
+=
todo
.
attr
(
'
complete
'
)
?
1
:
0
});
return
completed
;
...
...
@@ -141,9 +141,6 @@ Todos = can.Control({
// Clear the new todo field
$
(
'
#new-todo
'
).
val
(
''
).
focus
();
$
.
each
(
this
.
element
.
data
(),
function
()
{
});
},
// Listen for when a new Todo has been entered
...
...
@@ -204,7 +201,7 @@ Todos = can.Control({
// Listen for toggle all completed Todos
'
#toggle-all click
'
:
function
(
el
,
ev
)
{
var
toggle
=
el
.
prop
(
'
checked
'
);
can
.
each
(
this
.
options
.
todos
,
function
(
i
,
todo
)
{
can
.
each
(
this
.
options
.
todos
,
function
(
todo
)
{
todo
.
attr
(
'
complete
'
,
toggle
).
save
();
});
},
...
...
labs/architecture-examples/canjs/jquery/todo.js
View file @
84b4a7b6
...
...
@@ -10,7 +10,7 @@ Todo = can.Model({
data
=
JSON
.
parse
(
window
.
localStorage
[
name
]
||
(
window
.
localStorage
[
name
]
=
'
[]
'
)
),
res
=
cb
.
call
(
this
,
data
);
if
(
res
!==
false
){
can
.
each
(
data
,
function
(
i
,
todo
)
{
can
.
each
(
data
,
function
(
todo
)
{
delete
todo
.
editing
;
});
window
.
localStorage
[
name
]
=
JSON
.
stringify
(
data
);
...
...
@@ -22,11 +22,11 @@ Todo = can.Model({
this
.
localStore
(
function
(
todos
){
var
instances
=
[],
self
=
this
;
can
.
each
(
todos
,
function
(
i
,
todo
)
{
can
.
each
(
todos
,
function
(
todo
)
{
instances
.
push
(
new
self
(
todo
));
});
def
.
resolve
({
data
:
instances
});
})
})
;
return
def
;
},
...
...
@@ -41,32 +41,32 @@ Todo = can.Model({
}
def
.
resolve
({});
});
return
def
return
def
;
},
create
:
function
(
attrs
){
var
def
=
new
can
.
Deferred
();
this
.
localStore
(
function
(
todos
){
attrs
.
id
=
attrs
.
id
||
parseInt
(
100000
*
Math
.
random
());
attrs
.
id
=
attrs
.
id
||
parseInt
(
100000
*
Math
.
random
()
,
10
);
todos
.
push
(
attrs
);
});
def
.
resolve
({
id
:
attrs
.
id
});
return
def
return
def
;
},
update
:
function
(
id
,
attrs
){
var
def
=
new
can
.
Deferred
();
var
def
=
new
can
.
Deferred
()
,
todo
;
this
.
localStore
(
function
(
todos
){
for
(
var
i
=
0
;
i
<
todos
.
length
;
i
++
)
{
if
(
todos
[
i
].
id
===
id
)
{
var
todo
=
todos
[
i
];
todo
=
todos
[
i
];
break
;
}
}
can
.
extend
(
todo
,
attrs
);
});
def
.
resolve
({});
return
def
return
def
;
}
},{});
...
...
@@ -79,8 +79,8 @@ Todo.List = can.Model.List({
this
.
attr
(
'
length
'
);
var
completed
=
0
;
this
.
each
(
function
(
i
,
todo
)
{
completed
+=
todo
.
attr
(
'
complete
'
)
?
1
:
0
this
.
each
(
function
(
todo
)
{
completed
+=
todo
.
attr
(
'
complete
'
)
?
1
:
0
;
});
return
completed
;
},
...
...
@@ -166,7 +166,7 @@ Todos = can.Control({
// Listen for toggle all completed Todos
'
#toggle-all click
'
:
function
(
el
,
ev
)
{
var
toggle
=
el
.
prop
(
'
checked
'
);
can
.
each
(
this
.
options
.
todos
,
function
(
i
,
todo
)
{
can
.
each
(
this
.
options
.
todos
,
function
(
todo
)
{
todo
.
attr
(
'
complete
'
,
toggle
).
save
();
});
},
...
...
@@ -174,11 +174,13 @@ Todos = can.Control({
// Listen for removing all completed Todos
'
#clear-completed click
'
:
function
()
{
for
(
var
i
=
this
.
options
.
todos
.
length
-
1
,
todo
;
i
>
-
1
&&
(
todo
=
this
.
options
.
todos
[
i
]);
i
--
)
{
todo
.
attr
(
'
complete
'
)
&&
todo
.
destroy
();
if
(
todo
.
attr
(
'
complete
'
)
)
{
todo
.
destroy
();
}
}
}
})
})
;
// Initialize the app
Todo
.
findAll
({},
function
(
todos
)
{
...
...
labs/architecture-examples/canjs/mootools/todo.js
View file @
84b4a7b6
...
...
@@ -10,7 +10,7 @@ Todo = can.Model({
data
=
JSON
.
decode
(
window
.
localStorage
[
name
]
||
(
window
.
localStorage
[
name
]
=
'
[]
'
)
),
res
=
cb
.
call
(
this
,
data
);
if
(
res
!==
false
){
can
.
each
(
data
,
function
(
i
,
todo
)
{
can
.
each
(
data
,
function
(
todo
)
{
delete
todo
.
editing
;
});
window
.
localStorage
[
name
]
=
JSON
.
encode
(
data
);
...
...
@@ -22,7 +22,7 @@ Todo = can.Model({
this
.
localStore
(
function
(
todos
){
var
instances
=
[],
self
=
this
;
can
.
each
(
todos
,
function
(
i
,
todo
)
{
can
.
each
(
todos
,
function
(
todo
)
{
instances
.
push
(
new
self
(
todo
));
});
def
.
resolve
({
data
:
instances
});
...
...
@@ -79,7 +79,7 @@ Todo.List = can.Model.List({
this
.
attr
(
'
length
'
);
var
completed
=
0
;
this
.
each
(
function
(
i
,
todo
)
{
this
.
each
(
function
(
todo
)
{
completed
+=
todo
.
attr
(
'
complete
'
)
?
1
:
0
});
return
completed
;
...
...
@@ -170,7 +170,7 @@ Todos = can.Control({
// Listen for toggle all completed Todos
'
#toggle-all click
'
:
function
(
el
,
ev
)
{
var
toggle
=
el
.
get
(
'
checked
'
)[
0
];
can
.
each
(
this
.
options
.
todos
,
function
(
i
,
todo
)
{
can
.
each
(
this
.
options
.
todos
,
function
(
todo
)
{
todo
.
attr
(
'
complete
'
,
toggle
).
save
();
});
},
...
...
labs/architecture-examples/canjs/yui-widget/todo.js
View file @
84b4a7b6
...
...
@@ -19,7 +19,7 @@ Todo = can.Model({
data
=
Y
.
JSON
.
parse
(
window
.
localStorage
[
name
]
||
(
window
.
localStorage
[
name
]
=
'
[]
'
)
),
res
=
cb
.
call
(
this
,
data
);
if
(
res
!==
false
){
can
.
each
(
data
,
function
(
i
,
todo
)
{
can
.
each
(
data
,
function
(
todo
)
{
delete
todo
.
editing
;
});
window
.
localStorage
[
name
]
=
Y
.
JSON
.
stringify
(
data
);
...
...
@@ -31,7 +31,7 @@ Todo = can.Model({
this
.
localStore
(
function
(
todos
){
var
instances
=
[],
self
=
this
;
can
.
each
(
todos
,
function
(
i
,
todo
)
{
can
.
each
(
todos
,
function
(
todo
)
{
instances
.
push
(
new
self
(
todo
));
});
def
.
resolve
({
data
:
instances
});
...
...
@@ -115,7 +115,7 @@ Todo.List = can.Model.List({
this
.
attr
(
'
length
'
);
var
completed
=
0
;
this
.
each
(
function
(
i
,
todo
)
{
this
.
each
(
function
(
todo
)
{
completed
+=
todo
.
attr
(
'
complete
'
)
?
1
:
0
});
return
completed
;
...
...
@@ -210,7 +210,7 @@ Todos = can.Control({
// Listen for toggle all completed Todos
'
#toggle-all click
'
:
function
(
el
,
ev
)
{
var
toggle
=
el
.
get
(
'
checked
'
);
can
.
each
(
this
.
options
.
todos
,
function
(
i
,
todo
)
{
can
.
each
(
this
.
options
.
todos
,
function
(
todo
)
{
todo
.
attr
(
'
complete
'
,
toggle
).
save
();
});
},
...
...
labs/architecture-examples/canjs/yui/todo.js
View file @
84b4a7b6
...
...
@@ -12,7 +12,7 @@ Todo = can.Model({
data
=
Y
.
JSON
.
parse
(
window
.
localStorage
[
name
]
||
(
window
.
localStorage
[
name
]
=
'
[]
'
)
),
res
=
cb
.
call
(
this
,
data
);
if
(
res
!==
false
){
can
.
each
(
data
,
function
(
i
,
todo
)
{
can
.
each
(
data
,
function
(
todo
)
{
delete
todo
.
editing
;
});
window
.
localStorage
[
name
]
=
Y
.
JSON
.
stringify
(
data
);
...
...
@@ -24,7 +24,7 @@ Todo = can.Model({
this
.
localStore
(
function
(
todos
){
var
instances
=
[],
self
=
this
;
can
.
each
(
todos
,
function
(
i
,
todo
)
{
can
.
each
(
todos
,
function
(
todo
)
{
instances
.
push
(
new
self
(
todo
));
});
def
.
resolve
({
data
:
instances
});
...
...
@@ -81,7 +81,7 @@ Todo.List = can.Model.List({
this
.
attr
(
'
length
'
);
var
completed
=
0
;
this
.
each
(
function
(
i
,
todo
)
{
this
.
each
(
function
(
todo
)
{
completed
+=
todo
.
attr
(
'
complete
'
)
?
1
:
0
});
return
completed
;
...
...
@@ -168,7 +168,7 @@ Todos = can.Control({
// Listen for toggle all completed Todos
'
#toggle-all click
'
:
function
(
el
,
ev
)
{
var
toggle
=
el
.
get
(
'
checked
'
);
can
.
each
(
this
.
options
.
todos
,
function
(
i
,
todo
)
{
can
.
each
(
this
.
options
.
todos
,
function
(
todo
)
{
todo
.
attr
(
'
complete
'
,
toggle
).
save
();
});
},
...
...
labs/architecture-examples/canjs/zepto/todo.js
View file @
84b4a7b6
...
...
@@ -10,7 +10,7 @@ Todo = can.Model({
data
=
JSON
.
parse
(
window
.
localStorage
[
name
]
||
(
window
.
localStorage
[
name
]
=
'
[]
'
)
),
res
=
cb
.
call
(
this
,
data
);
if
(
res
!==
false
){
can
.
each
(
data
,
function
(
i
,
todo
)
{
can
.
each
(
data
,
function
(
todo
)
{
delete
todo
.
editing
;
});
window
.
localStorage
[
name
]
=
JSON
.
stringify
(
data
);
...
...
@@ -22,7 +22,7 @@ Todo = can.Model({
this
.
localStore
(
function
(
todos
){
var
instances
=
[],
self
=
this
;
can
.
each
(
todos
,
function
(
i
,
todo
)
{
can
.
each
(
todos
,
function
(
todo
)
{
instances
.
push
(
new
self
(
todo
));
});
def
.
resolve
({
data
:
instances
});
...
...
@@ -79,7 +79,7 @@ Todo.List = can.Model.List({
this
.
attr
(
'
length
'
);
var
completed
=
0
;
this
.
each
(
function
(
i
,
todo
)
{
this
.
each
(
function
(
todo
)
{
completed
+=
todo
.
attr
(
'
complete
'
)
?
1
:
0
});
return
completed
;
...
...
@@ -110,7 +110,7 @@ Todos = can.Control({
// Listen for when a new Todo has been entered
'
#new-todo keyup
'
:
function
(
el
,
ev
){
if
(
ev
.
keyCode
==
13
)
{
if
(
ev
.
keyCode
==
13
)
{
new
Todo
({
text
:
el
.
val
(),
complete
:
false
...
...
@@ -168,7 +168,7 @@ Todos = can.Control({
// Listen for toggle all completed Todos
'
#toggle-all change
'
:
function
(
el
,
ev
)
{
var
toggle
=
el
[
0
].
checked
;
can
.
each
(
this
.
options
.
todos
,
function
(
i
,
todo
)
{
can
.
each
(
this
.
options
.
todos
,
function
(
todo
)
{
todo
.
attr
(
'
complete
'
,
toggle
).
save
();
});
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment