forked from tastejs/todomvc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c08c83b
commit c9d80c1
Showing
20 changed files
with
580 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
labs/architecture-examples/cujo/app/controls/template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,8 @@ | ||
<footer id="footer"> | ||
<!-- This should be `0 items left` by default --> | ||
<span id="todo-count"> | ||
<span class="remaining-count-zero">${itemsLeft.zero}</span> | ||
<span class="remaining-count-one">${itemsLeft.one}</span> | ||
<span class="remaining-count-many">${itemsLeft.many}</span> | ||
</span> | ||
<!-- Remove this if you don't implement routing --> | ||
<ul id="filters"> | ||
<li> | ||
<a class="selected" href="#/">${filter.all}</a> | ||
</li> | ||
<li> | ||
<a href="#/active">${filter.active}</a> | ||
</li> | ||
<li> | ||
<a href="#/completed">${filter.completed}</a> | ||
</li> | ||
</ul> | ||
<button id="clear-completed">${clearCompleted} (<span class="count">1</span>)</button> | ||
</footer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
define(function() { | ||
/*global define */ | ||
define(function () { | ||
'use strict'; | ||
|
||
return function(todo) { | ||
return function (todo) { | ||
todo.text = todo.text && todo.text.trim() || ''; | ||
todo.complete = !!todo.complete; | ||
|
||
return todo; | ||
} | ||
|
||
}; | ||
}); |
32 changes: 17 additions & 15 deletions
32
labs/architecture-examples/cujo/app/create/generateMetadata.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
define(function() { | ||
|
||
/** | ||
* Since we're using a datastore (localStorage) that doesn't generate ids and such | ||
* for us, this transform generates a GUID id and a dateCreated. It can be | ||
* injected into a pipeline for creating new todos. | ||
*/ | ||
return function generateMetadata(item) { | ||
item.id = guidLike(); | ||
item.dateCreated = new Date().getTime(); | ||
|
||
return item; | ||
}; | ||
/*global define */ | ||
/*jshint bitwise:false */ | ||
define(function () { | ||
'use strict'; | ||
|
||
// GUID-like generation, not actually a GUID, tho, from: | ||
// http://stackoverflow.com/questions/7940616/what-makes-this-pseudo-guid-generator-better-than-math-random | ||
function s4() { | ||
return (((1+Math.random())*0x10000)|0).toString(16).substring(1); | ||
return (((1 + Math.random()) * 0x10000)|0).toString(16).substring(1); | ||
} | ||
|
||
function guidLike() { | ||
return (s4()+s4()+"-"+s4()+"-"+s4()+"-"+s4()+"-"+s4()+s4()+s4()); | ||
return (s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4()); | ||
} | ||
|
||
/** | ||
* Since we're using a datastore (localStorage) that doesn't generate ids and | ||
* such for us, this transform generates a GUID id and a dateCreated. It can | ||
* be injected into a pipeline for creating new todos. | ||
*/ | ||
return function generateMetadata(item) { | ||
item.id = guidLike(); | ||
item.dateCreated = new Date().getTime(); | ||
|
||
return item; | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/*global define */ | ||
define({ | ||
title: 'todos', | ||
todo: { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
define(function() { | ||
/*global define */ | ||
define(function () { | ||
'use strict'; | ||
|
||
/** | ||
* Validate a todo | ||
*/ | ||
return function validateTodo(todo) { | ||
var valid, result; | ||
|
||
// Must be a valid object, and have a text property that is non-empty | ||
valid = todo && 'text' in todo && todo.text.trim(); | ||
result = { valid: !!valid }; | ||
var valid = todo && 'text' in todo && todo.text.trim(); | ||
var result = { valid: !!valid }; | ||
|
||
if(!valid) result.errors = [{ property: 'text', message: 'missing' }]; | ||
if (!valid) { | ||
result.errors = [{ property: 'text', message: 'missing' }]; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/*global define */ | ||
define({ | ||
edit: 'Double-click to edit a todo', | ||
templateBy: 'Template by', | ||
|
7 changes: 4 additions & 3 deletions
7
labs/architecture-examples/cujo/app/list/setCompletedClass.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
define(function() { | ||
/*global define */ | ||
define(function () { | ||
'use strict'; | ||
|
||
/** | ||
* Custom data linking handler for setting the "completed" class. | ||
* The intent here is just to show that you can implement custom | ||
* handlers for data/dom linking to do anything that isn't provided | ||
* by default. | ||
*/ | ||
return function(node, data, info) { | ||
return function (node, data, info) { | ||
// Simple-minded implementation just to show custom data linking handler | ||
node.className = data[info.prop] ? 'completed' : ''; | ||
}; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/*global define */ | ||
define({ | ||
markAll: 'Mark all as complete' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
#toggle-all { | ||
display: none; | ||
display: none; | ||
} | ||
.todos-one #toggle-all, .todos-many #toggle-all { | ||
display: block; | ||
|
||
.todos-one #toggle-all, | ||
.todos-many #toggle-all { | ||
display: block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.