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
Sven Franck
todomvc
Commits
93a7b965
Commit
93a7b965
authored
Apr 30, 2012
by
Sindre Sorhus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
o_O app: Cleanup
parent
5763d113
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
39 deletions
+37
-39
labs/architecture-examples/o_O/index.html
labs/architecture-examples/o_O/index.html
+22
-24
labs/architecture-examples/o_O/js/app.js
labs/architecture-examples/o_O/js/app.js
+15
-15
No files found.
labs/architecture-examples/o_O/index.html
View file @
93a7b965
...
...
@@ -9,38 +9,36 @@
<section
id=
"todoapp"
>
<header
id=
"header"
>
<h1>
Todos
</h1>
<input
id=
"new-todo"
data-bind=
"value: current; enterKey: add"
placeholder=
"What needs to be done?"
>
</header>
<input
id=
"new-todo"
data-bind=
"value: current; enterKey: add"
placeholder=
"What needs to be done?"
>
</header>
<section
id=
"main"
data-bind=
"visible: todos.count"
>
<div>
<input
id=
"toggle-all"
type=
"checkbox"
data-bind=
"value: allCompleted;"
>
<label
for=
"toggle-all"
>
Mark all as complete
</label>
<input
id=
"toggle-all"
type=
"checkbox"
data-bind=
"value: allCompleted;"
>
<label
for=
"toggle-all"
>
Mark all as complete
</label>
</div>
<ul
id=
"todo-list"
data-bind=
"foreach: todos"
>
<li
data-bind=
"class: klass; visible; dblclick: startEditing"
>
<div
class=
"view"
>
<input
class=
"toggle"
type=
"checkbox"
data-bind=
"value: completed"
>
<label
data-bind=
"text: title"
></label>
<button
class=
"destroy"
data-bind=
"click: remove"
></button>
</div>
<input
class=
"edit"
data-bind=
"value: title; enterKey: stopEditing; blur: stopEditing"
/>
</li>
<li
data-bind=
"class: klass; visible; dblclick: startEditing"
>
<div
class=
"view"
>
<input
class=
"toggle"
type=
"checkbox"
data-bind=
"value: completed"
>
<label
data-bind=
"text: title"
></label>
<button
class=
"destroy"
data-bind=
"click: remove"
></button>
</div>
<input
class=
"edit"
data-bind=
"value: title; enterKey: stopEditing; blur: stopEditing"
/>
</li>
</ul>
</section>
<footer
id=
"footer"
data-bind=
"visible: todos.count"
>
<span
id=
"todo-count"
>
<strong
data-bind=
"text: remainingCount"
></strong>
<span
class=
"word"
data-bind=
"text: pluralize('item', remainingCount())"
></span>
left
<strong
data-bind=
"text: remainingCount"
></strong>
<span
class=
"word"
data-bind=
"text: pluralize('item', remainingCount())"
></span>
left
</span>
<ul
id=
"filters"
>
<li><a
href=
"#/"
>
All
</a></li>
<ul
id=
"filters"
>
<li><a
href=
"#/"
>
All
</a></li>
<li><a
href=
"#/active"
>
Active
</a></li>
<li><a
href=
"#/completed"
>
Completed
</a></li>
</ul>
<button
id=
"clear-completed"
data-bind=
"click: removeCompleted; visible: completedCount"
>
Clear completed
(
<span
data-bind=
'text: completedCount'
></span>
)
Clear completed (
<span
data-bind=
'text: completedCount'
></span>
)
</button>
</footer>
</section>
...
...
@@ -48,9 +46,9 @@
<p>
Double-click to edit a todo
</p>
<p>
Created by
<a
href=
"http://weepy.github.com"
>
weepy (Jonah Fox)
</a></p>
</footer>
<script
src=
"../../../assets/jquery.min.js"
></script>
<script
src=
"js/lib/o_O.js"
type=
"text/javascript"
></script>
<script
src=
"js/lib/o_O.router.js"
type=
"text/javascript
"
></script>
<script
src=
"js/app.js"
></script>
<script
src=
"../../../assets/jquery.min.js"
></script>
<script
src=
"js/lib/o_O.js"
></script>
<script
src=
"js/lib/o_O.router.js
"
></script>
<script
src=
"js/app.js"
></script>
</body>
</html>
</html>
\ No newline at end of file
labs/architecture-examples/o_O/js/app.js
View file @
93a7b965
//a custom binding to handle the enter key
o_O
.
bindings
.
enterKey
=
function
(
func
,
$el
)
{
var
ENTER_KEY
=
13
;
var
context
=
this
var
context
=
this
;
$el
.
keyup
(
function
(
e
)
{
if
(
e
.
keyCode
===
ENTER_KEY
)
func
.
call
(
context
);
...
...
@@ -20,7 +20,7 @@ var Todo = o_O.model.extend({
this
.
editing
=
o_O
(
false
)
},
startEditing
:
function
()
{
startEditing
:
function
()
{
this
.
editing
(
true
)
var
self
=
this
setTimeout
(
function
()
{
...
...
@@ -32,7 +32,7 @@ var Todo = o_O.model.extend({
var
text
=
$
.
trim
(
this
.
title
()
)
text
?
this
.
title
(
text
)
?
this
.
title
(
text
)
:
this
.
remove
()
this
.
editing
(
false
)
...
...
@@ -51,7 +51,7 @@ var Todo = o_O.model.extend({
klass
:
function
()
{
if
(
this
.
editing
())
return
'
editing
'
if
(
this
.
completed
())
if
(
this
.
completed
())
return
'
completed
'
else
return
''
...
...
@@ -61,7 +61,7 @@ var Todo = o_O.model.extend({
// main application
var
TodoApp
=
o_O
.
model
.
extend
({
current
:
""
,
current
:
''
,
completedCount
:
0
,
filter
:
''
},
{
...
...
@@ -76,15 +76,15 @@ var TodoApp = o_O.model.extend({
self
.
completedCount
(
completed
.
length
)
self
.
persist
()
})
this
.
remainingCount
=
o_O
(
function
()
{
return
self
.
todos
.
count
()
-
self
.
completedCount
()
})
// writeable computed observable
// writeable computed observable
// handles marking all complete/incomplete
// or retrieving if this is true
this
.
allCompleted
=
o_O
(
function
(
v
)
{
this
.
allCompleted
=
o_O
(
function
(
v
)
{
if
(
arguments
.
length
==
0
)
{
return
self
.
remainingCount
()
==
0
}
...
...
@@ -102,7 +102,7 @@ var TodoApp = o_O.model.extend({
var
text
=
$
.
trim
(
this
.
current
()
);
if
(
text
)
{
this
.
todos
.
unshift
(
Todo
({
title
:
text
})
);
this
.
current
(
""
)
this
.
current
(
""
)
}
},
...
...
@@ -129,11 +129,11 @@ function main() {
var
todos
=
[]
try
{
todos
=
JSON
.
parse
(
localStorage
[
'
todos-o_O
'
]
);
}
}
catch
(
e
)
{
}
// create models
for
(
var
i
=
0
;
i
<
todos
.
length
;
i
++
)
for
(
var
i
=
0
;
i
<
todos
.
length
;
i
++
)
todos
[
i
]
=
Todo
.
create
(
todos
[
i
]
)
// create app
...
...
@@ -147,14 +147,14 @@ function main() {
o_O
.
router
()
.
add
(
'
*filter
'
,
function
(
filt
)
{
todoapp
.
filter
(
filt
)
$
(
'
#filters a
'
)
.
removeClass
(
'
selected
'
)
.
filter
(
"
[href='#/
"
+
filt
+
"
']
"
)
.
addClass
(
'
selected
'
)
.
addClass
(
'
selected
'
)
})
.
start
()
}
// kick it off
main
();
main
();
\ No newline at end of file
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