Commit ea1bb59f authored by Stephen McKamey's avatar Stephen McKamey

Addressing comments in PR #1427.

parent 6eec6408
target/
node_modules/
www/cdn/debug/
\ No newline at end of file
www/cdn/debug/
{
"private": true,
"scripts": {
"postinstall": "cp node_modules/todomvc-app-css/*.css src/main/webapp/css/ && cp node_modules/todomvc-common/*.css src/main/webapp/css/ && cp node_modules/todomvc-common/base.js src/main/webapp/js/lib/todos.js"
},
"dependencies": {
"todomvc-app-css": "^2.0.0",
"todomvc-common": "^1.0.1"
}
"private": true,
"scripts": {
"postinstall": "cp node_modules/todomvc-app-css/*.css src/main/webapp/css/ && cp node_modules/todomvc-common/*.css src/main/webapp/css/ && cp node_modules/todomvc-common/base.js src/main/webapp/js/lib/todos.js"
},
"dependencies": {
"todomvc-app-css": "^2.0.0",
"todomvc-common": "^1.0.1"
}
}
......@@ -72,13 +72,10 @@ var todos = todos || {};
// event handlers
todos.actions = {
add_keypress: function (e) {
switch (e.keyCode) {
case ENTER_KEY:
add(this);
break;
case ESC_KEY:
refreshView();
break;
if (e.keyCode === ENTER_KEY) {
add(this);
} else if (e.keyCode === ESC_KEY) {
refreshView();
}
},
......@@ -92,15 +89,12 @@ var todos = todos || {};
edit_keypress: function (id) {
// create a closure around the ID
return function (e) {
switch (e.keyCode) {
case ENTER_KEY:
// just blur so doesn't get triggered twice
this.blur();
break;
case ESC_KEY:
reset(this, id);
this.blur();
break;
if (e.keyCode === ENTER_KEY) {
// just blur so doesn't get triggered twice
this.blur();
} else if (e.keyCode === ESC_KEY) {
reset(this, id);
this.blur();
}
};
},
......
......@@ -27,6 +27,6 @@ type:"text",value:function(a){return a.title},onblur:function(a){return todos.ac
todos.views.Tasks=duel([""," ",["$if",{test:function(a){return a.tasks&&a.tasks.length}},["section",{"class":"main"}," ",["input",{"class":"toggle-all",type:"checkbox",checked:function(a){return!a.stats.active},onchange:function(){return todos.actions.toggle_change}}]," ",["label",{"for":"toggle-all"},"Mark all as complete"]," ",["ul",{"class":"todo-list"}," ",["$for",{each:function(a){return a.tasks}}," ",["$call",{view:function(){return todos.views.Task}}]]," "]]]]);var todos=todos||{};todos.views=todos.views||{};todos.views.TodoApp=duel(["section",{"class":"todoapp"}," ",["header",{"class":"header"}," ",["h1","todos"]," ",["input",{"class":"new-todo",placeholder:"What needs to be done?",autofocus:!0,onblur:function(){return todos.actions.add_blur},onkeydown:function(){return todos.actions.add_keypress}}]," "]," ",["$call",{view:function(){return todos.views.Tasks},data:function(a){return a}}]," ",["$call",{view:function(){return todos.views.Stats},data:function(a){return a.stats}}]]);var todos=todos||{};
(function(j,f,h){function g(a){return b.filter(function(c){return c.id===a})[0]}function d(){var a="undefined"!==typeof JSON?JSON.stringify(b):b;f.setItem(h,a)}var b,e;if(!(e=f)){var i={};e={getItem:function(a){return i[a]},setItem:function(a,c){i[a]=c}}}f=e;b=(e=f.getItem(h))?"undefined"!==typeof JSON?JSON.parse(e):e:[];j.model={tasks:function(){return b},stats:function(){var a={};a.total=b.length;a.completed=b.filter(function(a){return a.completed}).length;a.active=a.total-a.completed;return a},
add:function(a){a={id:((new Date).getTime()+Math.random()).toString(36),title:a,completed:!1};b.push(a);d();return a},find:g,edit:function(a,b){(g(a)||{}).title=b;d()},toggle:function(a,b){(g(a)||{}).completed=b;d()},toggleAll:function(a){b.forEach(function(b){b.completed=a});d()},remove:function(a){for(var c=b.length-1;0<=c;c--)b[c].id===a&&b.splice(c,1);d()},expunge:function(){for(var a=b.length-1;0<=a;a--)b[a].completed&&b.splice(a,1);d()}}})(todos,window.localStorage,"todos-duel");var todos=todos||{};
(function(b,e){function d(){var a={tasks:b.model.tasks(),stats:b.model.stats()},a=b.views.TodoApp(a).toDOM(),c=e.querySelector(".todoapp");c?c.parentNode.replaceChild(a,c):e.body.insertBefore(a,e.body.firstChild);e.querySelector(".new-todo").focus()}b.actions={add_keypress:function(a){switch(a.keyCode){case 13:a=(this.value||"").trim();this.value="";a&&(b.model.add(a),d());break;case 27:d()}},edit_blur:function(a){return function(){var c=(this.value||"").trim();(this.value=c)?b.model.edit(a,c):b.model.remove(a);
d()}},edit_keypress:function(a){return function(c){switch(c.keyCode){case 13:this.blur();break;case 27:if(c=b.model.find(a))this.value=c.title;this.blur()}}},remove_click:function(a){return function(){b.model.remove(a);d()}},clear_click:function(){b.model.expunge();d()},content_dblclick:function(){for(var a=this;"LI"!==a.tagName;)a=a.parentNode;a.className="editing";(a=(a||e).querySelector("input[type=text]"))&&a.focus()},completed_change:function(a){return function(){b.model.toggle(a,this.checked);
(function(b,e){function d(){var a={tasks:b.model.tasks(),stats:b.model.stats()},a=b.views.TodoApp(a).toDOM(),c=e.querySelector(".todoapp");c?c.parentNode.replaceChild(a,c):e.body.insertBefore(a,e.body.firstChild);e.querySelector(".new-todo").focus()}b.actions={add_keypress:function(a){13===a.keyCode?(a=(this.value||"").trim(),this.value="",a&&(b.model.add(a),d())):27===a.keyCode&&d()},edit_blur:function(a){return function(){var c=(this.value||"").trim();(this.value=c)?b.model.edit(a,c):b.model.remove(a);
d()}},edit_keypress:function(a){return function(c){if(13===c.keyCode)this.blur();else if(27===c.keyCode){if(c=b.model.find(a))this.value=c.title;this.blur()}}},remove_click:function(a){return function(){b.model.remove(a);d()}},clear_click:function(){b.model.expunge();d()},content_dblclick:function(){for(var a=this;"LI"!==a.tagName;)a=a.parentNode;a.className="editing";(a=(a||e).querySelector("input[type=text]"))&&a.focus()},completed_change:function(a){return function(){b.model.toggle(a,this.checked);
d()}},toggle_change:function(){b.model.toggleAll(this.checked);d()}};d()})(todos,window.document);
\ No newline at end of file
......@@ -12,7 +12,7 @@
<p>Ported to <a href="http://duelengine.org">DUEL</a> by <a href="http://mck.me">Stephen McKamey</a></p>
<p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
</footer>
<script src="./cdn/916ee1b55ac72cc1cc01404ca8e13a695228cc13.js"></script>
<script src="./cdn/0246d47e943708b571e47bd968ef697d343ae178.js"></script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment