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
14895be2
Commit
14895be2
authored
Jan 01, 2012
by
Sindre Sorhus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorder methods and var rename
parent
7708e877
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
21 deletions
+23
-21
todo-example/jquery/js/app.js
todo-example/jquery/js/app.js
+23
-21
No files found.
todo-example/jquery/js/app.js
View file @
14895be2
...
...
@@ -37,23 +37,19 @@ jQuery(function($) {
var
App
=
{
init
:
function
()
{
this
.
cacheElements
();
this
.
store
=
new
Store
(
'
todo-jquery
'
);
this
.
todos
=
this
.
store
.
get
(
'
todos
'
)
||
[];
this
.
bindEvents
();
this
.
render
();
},
cacheElements
:
function
()
{
this
.
$template
=
$
(
'
#todo-template
'
);
this
.
$todoApp
=
$
(
'
#todoapp
'
);
this
.
$todoList
=
this
.
$todoApp
.
find
(
'
.items
'
);
this
.
$footer
=
this
.
$todoApp
.
find
(
'
footer
'
);
this
.
$count
=
this
.
$footer
.
find
(
'
.count
'
);
this
.
$clearBtn
=
this
.
$footer
.
find
(
'
.clear
'
);
// localStorage support
this
.
store
=
new
Store
(
'
todo-jquery
'
);
this
.
todos
=
this
.
store
.
get
(
'
todos
'
)
||
[];
this
.
bindEvents
();
this
.
render
();
},
render
:
function
()
{
var
html
=
this
.
$template
.
tmpl
(
this
.
todos
);
this
.
$todoList
.
html
(
html
);
this
.
renderFooter
();
this
.
store
.
set
(
'
todos
'
,
this
.
todos
);
},
bindEvents
:
function
()
{
var
app
=
this
.
$todoApp
,
...
...
@@ -66,14 +62,11 @@ jQuery(function($) {
list
.
on
(
'
blur
'
,
'
input[type="text"]
'
,
this
.
update
);
list
.
on
(
'
click
'
,
'
.destroy
'
,
this
.
destroy
);
},
activeTodoCount
:
function
()
{
var
count
=
0
;
$
.
each
(
this
.
todos
,
function
(
i
,
val
)
{
if
(
!
val
.
done
)
{
count
++
;
}
});
return
count
;
render
:
function
()
{
var
html
=
this
.
$template
.
tmpl
(
this
.
todos
);
this
.
$todoList
.
html
(
html
);
this
.
renderFooter
();
this
.
store
.
set
(
'
todos
'
,
this
.
todos
);
},
renderFooter
:
function
()
{
var
todoCount
=
this
.
todos
.
length
,
...
...
@@ -88,6 +81,15 @@ jQuery(function($) {
// Toggle clear button and update title
this
.
$clearBtn
.
text
(
clearTitle
).
toggle
(
!!
completedTodos
);
},
activeTodoCount
:
function
()
{
var
count
=
0
;
$
.
each
(
this
.
todos
,
function
(
i
,
val
)
{
if
(
!
val
.
done
)
{
count
++
;
}
});
return
count
;
},
destroyDone
:
function
()
{
var
todos
=
App
.
todos
,
l
=
todos
.
length
;
...
...
@@ -138,9 +140,9 @@ jQuery(function($) {
}
},
update
:
function
()
{
var
newV
al
=
$
(
this
).
removeClass
(
'
editing
'
).
val
();
var
v
al
=
$
(
this
).
removeClass
(
'
editing
'
).
val
();
App
.
getTodo
(
this
,
function
(
i
)
{
this
.
todos
[
i
].
title
=
newV
al
;
this
.
todos
[
i
].
title
=
v
al
;
});
App
.
render
();
},
...
...
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