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
2540365e
Commit
2540365e
authored
Oct 22, 2012
by
Contra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dermis example
parent
4834e5f8
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
232 additions
and
0 deletions
+232
-0
architecture-examples/.DS_Store
architecture-examples/.DS_Store
+0
-0
architecture-examples/dermis/.DS_Store
architecture-examples/dermis/.DS_Store
+0
-0
architecture-examples/dermis/index.html
architecture-examples/dermis/index.html
+68
-0
architecture-examples/dermis/js/app.js
architecture-examples/dermis/js/app.js
+41
-0
architecture-examples/dermis/js/lib/dermis.js
architecture-examples/dermis/js/lib/dermis.js
+1
-0
architecture-examples/dermis/js/models/Todo.js
architecture-examples/dermis/js/models/Todo.js
+16
-0
architecture-examples/dermis/js/models/Todos.js
architecture-examples/dermis/js/models/Todos.js
+58
-0
architecture-examples/dermis/js/storage.js
architecture-examples/dermis/js/storage.js
+18
-0
architecture-examples/dermis/routes/active.js
architecture-examples/dermis/routes/active.js
+10
-0
architecture-examples/dermis/routes/completed.js
architecture-examples/dermis/routes/completed.js
+10
-0
architecture-examples/dermis/routes/index.js
architecture-examples/dermis/routes/index.js
+10
-0
No files found.
architecture-examples/.DS_Store
0 → 100644
View file @
2540365e
File added
architecture-examples/dermis/.DS_Store
0 → 100644
View file @
2540365e
File added
architecture-examples/dermis/index.html
0 → 100644
View file @
2540365e
<!doctype html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge,chrome=1"
>
<title>
Dermis • TodoMVC
</title>
<link
rel=
"stylesheet"
href=
"../../assets/base.css"
>
<!--[if IE]>
<script src="../../assets/ie.js"></script>
<![endif]-->
</head>
<body>
<section
id=
"todoapp"
>
<header
id=
"header"
>
<h1>
todos
</h1>
<input
id=
"new-todo"
placeholder=
"What needs to be done?"
autofocus
>
</header>
<div
id=
"content"
>
<section
id=
"main"
data-show=
".items | length | overZero"
>
<input
id=
"toggle-all"
type=
"checkbox"
data-on-click=
":toggle"
data-checked=
":allCompleted < .items"
>
<label
for=
"toggle-all"
>
Mark all as complete
</label>
<ul
id=
"todo-list"
>
<li
data-each-todo=
":todos < .items .mode"
data-class-completed=
"todo.completed"
data-class-editing=
"todo.editable"
>
<div
class=
"view"
>
<input
class=
"toggle"
type=
"checkbox"
data-checked=
"todo.completed"
>
<label
data-text=
"todo.title"
data-on-dblclick=
"todo:editable"
></label>
<button
class=
"destroy"
data-on-click=
"todo:destroy"
></button>
</div>
<input
class=
"edit"
data-value=
"todo.title"
data-on-change=
"todo:uneditable"
>
</li>
</ul>
</section>
<footer
id=
"footer"
data-show=
".items | length | overZero"
>
<span
id=
"todo-count"
>
<strong
data-text=
":active < .items | length"
></strong>
item
<span
data-show=
":active < .items | length | plural"
>
s
</span>
left
</span>
<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-on-click=
":clear"
data-show=
":completed < .items | length | overZero"
>
Clear completed (
<span
data-text=
":completed < .items | length"
></span>
)
</button>
</footer>
</section>
</div>
<footer
id=
"info"
>
<p>
Double-click to edit a todo
</p>
<p>
Created by
<a
href=
"http://github.com/Contra"
>
Contra
</a></p>
</footer>
<script
src=
"../../assets/base.js"
></script>
<script
src=
"../../assets/jquery.min.js"
></script>
<script
src=
"../../assets/require.min.js"
></script>
<script
src=
"js/lib/dermis.js"
></script>
<script
src=
"js/app.js"
></script>
</body>
</html>
\ No newline at end of file
architecture-examples/dermis/js/app.js
0 → 100644
View file @
2540365e
(
function
(
window
)
{
'
use strict
'
;
dermis
.
route
(
'
/
'
);
dermis
.
route
(
'
/active
'
);
dermis
.
route
(
'
/completed
'
);
require
([
"
js/models/Todo
"
,
"
js/models/Todos
"
,
"
js/storage
"
],
function
(
Todo
,
Todos
,
storage
){
//Bind Todos to DOM
Todos
.
bind
(
$
(
"
#content
"
));
//Load previous todos
var
todos
=
storage
.
load
(
'
todos-dermis
'
);
if
(
todos
){
todos
.
forEach
(
function
(
todo
){
todo
.
editable
=
false
;
Todos
.
push
(
Todo
.
create
().
set
(
todo
));
});
}
//Save when todos modified
Todos
.
on
(
'
change:items
'
,
function
(){
storage
.
save
(
'
todos-dermis
'
,
Todos
.
serialize
());
});
//Add todo when box submitted
var
box
=
$
(
"
#new-todo
"
);
box
.
change
(
function
(){
var
title
=
box
.
val
().
trim
();
if
(
title
.
length
===
0
)
return
;
Todos
.
push
(
Todo
.
create
()
.
set
({
title
:
title
,
completed
:
false
,
active
:
true
,
editable
:
false
}));
box
.
val
(
''
);
});
});
})(
window
);
\ No newline at end of file
architecture-examples/dermis/js/lib/dermis.js
0 → 100644
View file @
2540365e
This diff is collapsed.
Click to expand it.
architecture-examples/dermis/js/models/Todo.js
0 → 100644
View file @
2540365e
define
(
function
(){
var
Todo
=
dermis
.
model
({
editable
:
function
(){
this
.
set
(
'
editable
'
,
true
);
},
uneditable
:
function
(){
this
.
set
(
'
editable
'
,
false
);
var
title
=
this
.
get
(
'
title
'
).
trim
();
if
(
title
.
length
===
0
)
this
.
destroy
();
},
destroy
:
function
(){
this
.
set
(
'
active
'
,
false
);
}
});
return
Todo
;
});
\ No newline at end of file
architecture-examples/dermis/js/models/Todos.js
0 → 100644
View file @
2540365e
define
(
function
(
Todo
){
var
Todos
=
dermis
.
collection
({
toggle
:
function
(){
var
toggled
=
this
.
allCompleted
();
this
.
emit
(
'
change:toggle
'
);
this
.
all
().
forEach
(
function
(
todo
){
todo
.
set
(
'
completed
'
,
!
toggled
);
});
},
clear
:
function
(){
this
.
completed
().
forEach
(
function
(
todo
){
todo
.
destroy
();
});
},
// These can all be implemented as rivets formatters
allCompleted
:
function
(){
return
this
.
completed
().
length
===
this
.
all
().
length
;
},
todos
:
function
(){
return
this
[
this
.
get
(
'
mode
'
)]();
},
all
:
function
(){
var
out
=
[];
this
.
get
(
'
items
'
).
forEach
(
function
(
todo
){
if
(
todo
.
get
(
'
active
'
))
out
.
push
(
todo
);
});
return
out
;
},
completed
:
function
(){
var
out
=
[];
this
.
all
().
forEach
(
function
(
todo
){
if
(
todo
.
get
(
'
completed
'
))
out
.
push
(
todo
);
});
return
out
;
},
active
:
function
(){
var
out
=
[];
this
.
all
().
forEach
(
function
(
todo
){
if
(
!
todo
.
get
(
'
completed
'
))
out
.
push
(
todo
);
});
return
out
;
},
serialize
:
function
(){
var
out
=
[];
this
.
all
().
forEach
(
function
(
todo
){
out
.
push
(
todo
.
getAll
());
});
return
out
;
}
});
Todos
.
set
(
'
mode
'
,
'
all
'
);
return
Todos
;
});
\ No newline at end of file
architecture-examples/dermis/js/storage.js
0 → 100644
View file @
2540365e
define
(
function
(){
var
mod
=
{
load
:
function
(
key
){
if
(
!
'
localStorage
'
in
window
)
return
;
var
d
=
window
.
localStorage
[
key
];
if
(
d
){
return
JSON
.
parse
(
d
);
}
else
{
return
;
}
},
save
:
function
(
key
,
data
){
if
(
!
'
localStorage
'
in
window
)
return
;
window
.
localStorage
[
key
]
=
JSON
.
stringify
(
data
);
}
};
return
mod
;
});
\ No newline at end of file
architecture-examples/dermis/routes/active.js
0 → 100644
View file @
2540365e
define
([
"
js/models/Todo
"
,
"
js/models/Todos
"
],
function
(
Todo
,
Todos
){
var
app
=
{
show
:
function
(){
Todos
.
set
(
'
mode
'
,
'
active
'
);
$
(
"
.selected
"
).
removeClass
(
"
selected
"
);
$
(
'
a[href$="#/active"]
'
).
addClass
(
"
selected
"
);
}
};
return
app
;
});
\ No newline at end of file
architecture-examples/dermis/routes/completed.js
0 → 100644
View file @
2540365e
define
([
"
js/models/Todo
"
,
"
js/models/Todos
"
],
function
(
Todo
,
Todos
){
var
app
=
{
show
:
function
(){
Todos
.
set
(
'
mode
'
,
'
completed
'
);
$
(
"
.selected
"
).
removeClass
(
"
selected
"
);
$
(
'
a[href$="#/completed"]
'
).
addClass
(
"
selected
"
);
}
};
return
app
;
});
\ No newline at end of file
architecture-examples/dermis/routes/index.js
0 → 100644
View file @
2540365e
define
([
"
js/models/Todo
"
,
"
js/models/Todos
"
],
function
(
Todo
,
Todos
){
var
app
=
{
show
:
function
(){
Todos
.
set
(
'
mode
'
,
'
all
'
);
$
(
"
.selected
"
).
removeClass
(
"
selected
"
);
$
(
'
a[href$="#/"]
'
).
addClass
(
"
selected
"
);
}
};
return
app
;
});
\ 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