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
df3ed73f
Commit
df3ed73f
authored
Dec 31, 2011
by
Aaron Boushley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding checkall functionality to the application.
parent
ba3a573b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
todo-example/backbone_require/index.html
todo-example/backbone_require/index.html
+2
-0
todo-example/backbone_require/js/views/app.js
todo-example/backbone_require/js/views/app.js
+15
-4
No files found.
todo-example/backbone_require/index.html
View file @
df3ed73f
...
@@ -22,6 +22,8 @@
...
@@ -22,6 +22,8 @@
</div>
</div>
<div
id=
"todos"
>
<div
id=
"todos"
>
<input
class=
"check mark-all-done"
type=
"checkbox"
/>
<label
for=
"check-all"
>
Mark all as complete
</label>
<ul
id=
"todo-list"
></ul>
<ul
id=
"todo-list"
></ul>
</div>
</div>
...
...
todo-example/backbone_require/js/views/app.js
View file @
df3ed73f
...
@@ -19,16 +19,18 @@ define([
...
@@ -19,16 +19,18 @@ define([
events
:
{
events
:
{
"
keypress #new-todo
"
:
"
createOnEnter
"
,
"
keypress #new-todo
"
:
"
createOnEnter
"
,
"
keyup #new-todo
"
:
"
showTooltip
"
,
"
keyup #new-todo
"
:
"
showTooltip
"
,
"
click .todo-clear a
"
:
"
clearCompleted
"
"
click .todo-clear a
"
:
"
clearCompleted
"
,
"
click .mark-all-done
"
:
"
toggleAllComplete
"
},
},
// At initialization we bind to the relevant events on the `Todos`
// At initialization we bind to the relevant events on the `Todos`
// collection, when items are added or changed. Kick things off by
// collection, when items are added or changed. Kick things off by
// loading any preexisting todos that might be saved in *localStorage*.
// loading any preexisting todos that might be saved in *localStorage*.
initialize
:
function
()
{
initialize
:
function
()
{
_
.
bindAll
(
this
,
'
addOne
'
,
'
addAll
'
,
'
render
'
);
_
.
bindAll
(
this
,
'
addOne
'
,
'
addAll
'
,
'
render
'
,
'
toggleAllComplete
'
);
this
.
input
=
this
.
$
(
"
#new-todo
"
);
this
.
input
=
this
.
$
(
"
#new-todo
"
);
this
.
allCheckbox
=
this
.
$
(
"
.mark-all-done
"
)[
0
];
Todos
.
bind
(
'
add
'
,
this
.
addOne
);
Todos
.
bind
(
'
add
'
,
this
.
addOne
);
Todos
.
bind
(
'
reset
'
,
this
.
addAll
);
Todos
.
bind
(
'
reset
'
,
this
.
addAll
);
...
@@ -41,11 +43,15 @@ define([
...
@@ -41,11 +43,15 @@ define([
// of the app doesn't change.
// of the app doesn't change.
render
:
function
()
{
render
:
function
()
{
var
done
=
Todos
.
done
().
length
;
var
done
=
Todos
.
done
().
length
;
var
remaining
=
Todos
.
remaining
().
length
;
this
.
$
(
'
#todo-stats
'
).
html
(
this
.
statsTemplate
({
this
.
$
(
'
#todo-stats
'
).
html
(
this
.
statsTemplate
({
total
:
Todos
.
length
,
total
:
Todos
.
length
,
done
:
Todos
.
done
().
length
,
done
:
done
,
remaining
:
Todos
.
remaining
().
length
remaining
:
remaining
}));
}));
this
.
allCheckbox
.
checked
=
!
remaining
;
},
},
// Add a single todo item to the list by creating a view for it, and
// Add a single todo item to the list by creating a view for it, and
...
@@ -93,6 +99,11 @@ define([
...
@@ -93,6 +99,11 @@ define([
if
(
val
==
''
||
val
==
this
.
input
.
attr
(
'
placeholder
'
))
return
;
if
(
val
==
''
||
val
==
this
.
input
.
attr
(
'
placeholder
'
))
return
;
var
show
=
function
(){
tooltip
.
show
().
fadeIn
();
};
var
show
=
function
(){
tooltip
.
show
().
fadeIn
();
};
this
.
tooltipTimeout
=
_
.
delay
(
show
,
1000
);
this
.
tooltipTimeout
=
_
.
delay
(
show
,
1000
);
},
toggleAllComplete
:
function
()
{
var
done
=
this
.
allCheckbox
.
checked
;
Todos
.
each
(
function
(
todo
)
{
todo
.
save
({
'
done
'
:
done
});
});
}
}
});
});
...
...
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