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
e5b9f664
Commit
e5b9f664
authored
Dec 03, 2015
by
Sam Saccone
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1539 from dmethvin/795-spine
spine: Fix the "mark all complete" checkbox
parents
aa8706f3
1cf5060a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
16 deletions
+19
-16
examples/spine/js/app.js
examples/spine/js/app.js
+11
-10
examples/spine/src/app.coffee
examples/spine/src/app.coffee
+8
-6
No files found.
examples/spine/js/app.js
View file @
e5b9f664
// Generated by CoffeeScript 1.
9.1
// Generated by CoffeeScript 1.
10.0
(
function
()
{
var
TodoApp
,
bind
=
function
(
fn
,
me
){
return
function
(){
return
fn
.
apply
(
me
,
arguments
);
};
},
...
...
@@ -96,13 +96,15 @@
};
TodoApp
.
prototype
.
toggleAll
=
function
(
e
)
{
var
checked
;
checked
=
e
.
target
.
checked
;
return
Todo
.
each
(
function
(
todo
)
{
/*
TODO: Model updateAttribute sometimes won't stick:
https://github.com/maccman/spine/issues/219
*/
todo
.
updateAttribute
(
'
completed
'
,
e
.
target
.
checked
);
todo
.
updateAttribute
(
'
completed
'
,
checked
);
return
todo
.
trigger
(
'
update
'
,
todo
);
});
};
...
...
@@ -112,14 +114,13 @@
};
TodoApp
.
prototype
.
toggleElems
=
function
()
{
var
isTodos
;
isTodos
=
!!
Todo
.
count
();
this
.
main
.
toggle
(
isTodos
);
this
.
footer
.
toggle
(
isTodos
);
this
.
clearCompleted
.
toggle
(
!!
Todo
.
completed
().
length
);
if
(
!
Todo
.
completed
().
length
)
{
return
this
.
toggleAllElem
.
removeAttr
(
'
checked
'
);
}
var
completed
,
total
;
completed
=
Todo
.
completed
().
length
;
total
=
Todo
.
count
();
this
.
main
.
toggle
(
total
!==
0
);
this
.
footer
.
toggle
(
total
!==
0
);
this
.
toggleAllElem
.
prop
(
'
checked
'
,
completed
===
total
);
return
this
.
clearCompleted
.
toggle
(
completed
!==
0
);
};
TodoApp
.
prototype
.
renderFooter
=
function
()
{
...
...
examples/spine/src/app.coffee
View file @
e5b9f664
...
...
@@ -57,23 +57,25 @@ class TodoApp extends Spine.Controller
@
addNew
todo
for
todo
in
@
getByFilter
()
toggleAll
:
(
e
)
->
checked
=
e
.
target
.
checked
Todo
.
each
(
todo
)
->
###
TODO: Model updateAttribute sometimes won't stick:
https://github.com/maccman/spine/issues/219
###
todo
.
updateAttribute
'completed'
,
e
.
target
.
checked
todo
.
updateAttribute
'completed'
,
checked
todo
.
trigger
'update'
,
todo
clearCompletedItem
:
->
Todo
.
destroyCompleted
()
toggleElems
:
=>
isTodos
=
!!
Todo
.
count
()
@
main
.
toggle
isTodos
@
footer
.
toggle
isTodos
@
clearCompleted
.
toggle
!!
Todo
.
completed
().
length
@
toggleAllElem
.
removeAttr
'checked'
if
!
Todo
.
completed
().
length
completed
=
Todo
.
completed
().
length
total
=
Todo
.
count
()
@
main
.
toggle
total
!=
0
@
footer
.
toggle
total
!=
0
@
toggleAllElem
.
prop
'checked'
,
completed
==
total
@
clearCompleted
.
toggle
completed
!=
0
renderFooter
:
=>
text
=
(
count
)
->
if
count
is
1
then
'item'
else
'items'
...
...
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