Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

adding patch for keyDown eventsthat werent correctly rendering on cre…

…ation. also patches for using native checkbox rather than the simulated variation
  • Loading branch information...
commit bdf404e3b329a289207c02e9ec0b0721ab3ee117 1 parent b9357bf
Addy Osmani authored
3  app.css
@@ -11,8 +11,7 @@ dd { margin: 0 0 5px 15px; padding: 0; font-size: 17px; cursor: pointer; }
11 11 h2 { position: absolute; top: 56px; left: 77px; margin: 0; font-size: 30px; width: 275px; height: 1.2em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: normal; }
12 12 /*ul { position: absolute; top: 116px; left: 80px; margin: 0; padding: 0; width: 275px; list-style: none; }*/
13 13 li { position: relative; margin: 0 0 0 25px; padding: 0; font-size: 20px; line-height: 27px; }
14   -li .checkbox { position: absolute; top: 0; left: -25px; display: inline-block; width: 20px; height: 22px; cursor: pointer; background: url(assets/checkbox-unchecked.png) no-repeat; }
15   -li.done .checkbox { background-image: url(assets/checkbox-checked.png); /*text-decoration: line-through;*/ }
  14 +
16 15 p { position: absolute; top: 116px; left: 80px; margin: 0; padding: 0; width: 275px; font-size: 20px; line-height: 27px; }
17 16
18 17
60 app.js
@@ -35,47 +35,29 @@
35 35
36 36 var title = localStorage.getItem('title') || "Todo";
37 37 $('h1').text(title);
  38 +
  39 + if(Lists._data.length <=0){
  40 + var list = Lists.create({ name: 'My new list' });
  41 + app.trigger('updateLists');
  42 + }
  43 +
  44 + $('#new-todo').keydown(function(e) {
  45 + if (e.keyCode == 13){
  46 + var todoContent = $(this).val();
  47 + var todo = Todos.create({ name: todoContent, done: false, listId: parseInt($('h2').attr('data-id'), 10) });
  48 + context.partial('templates/_todo.template', todo, function(html) {
  49 + //$(html).insertAfter('#todo-list li:last');
  50 + var q = $(html);
  51 + console.log(q);
  52 + $('#todo-list').append(q);
38 53
39   -if(Lists._data.length <=0){
40   - var list = Lists.create({ name: 'My new list' });
41   - //Todos.create({ name: 'Something todo', done: false, listId: list.id });
42   - //context.redirect('#/list/'+list.id);
43   - app.trigger('updateLists');
44   -}
45   -
46   -$('#new-todo').keydown(function(e) {
47   - if (e.keyCode == 13){
48   - var todoContent = $(this).val();
49   - var todo = Todos.create({ name: todoContent, done: false, listId: parseInt($('h2').attr('data-id'), 10) });
50   - context.partial('templates/_todo.template', todo, function(html) {
51   - $(html).insertAfter('#todo-list li:last');
52   - });
53   - $(this).val('');
54   -
55   - }
56   -});
  54 + });
  55 + $(this).val('');
  56 +
  57 + }
  58 + });
57 59
58   - /*
59   - $('.new')
60   - .live('click', function() {
61   - var $this = $(this),
62   - type = $this.attr('data-type');
63   -
64   - switch (type) {
65   - case "list":
66   - var list = Lists.create({ name: 'My new list' });
67   - Todos.create({ name: 'Something todo', done: false, listId: list.id });
68   - context.redirect('#/list/'+list.id);
69   - app.trigger('updateLists');
70   - break;
71   - case "todo":
72   - var todo = Todos.create({ name: 'My new todo', done: false, listId: parseInt($('h2').attr('data-id'), 10) });
73   - context.partial('templates/_todo.template', todo, function(html) {
74   - $(html).insertBefore('#todo-list li:last');
75   - });
76   - break;
77   - }
78   - });*/
  60 +
79 61
80 62 $('#lists')
81 63 .delegate('dd[data-id]', 'click', function() {
10 readme.markdown
Source Rendered
... ... @@ -1,11 +1,5 @@
1 1 # Sammy's Todos
2 2
3   -This is a demo todo list app built on top of Sammy.js. It uses some advanced browser features and therefore requires an advanced browser. Features like CSS3 and HTML5 storage.
  3 +This is a demo todo list app built on top of Sammy.js.
4 4
5   -You can see a live demo of the app at: http://sammystodos.brandonaaron.net/
6   -
7   -## License
8   -
9   -Sammy's Todos is licensed under the MIT License (LICENSE.txt).
10   -
11   -Copyright (c) 2010 [Brandon Aaron](http://brandonaaron.net)
  5 +Original base code: [Brandon Aaron](http://brandonaaron.net). This version, refactored and rewritten: Addy Osmani
12 templates/_todo.template
... ... @@ -1 +1,11 @@
1   -<li data-type="todo" data-id="<%= id %>" class="<%= done ? 'done' : '' %>"><span class="checkbox"></span><span class="trashcan" data-type="todo" data-id="<%= id %>"></span><span contenteditable="true" data-type="todo" data-id="<%= id %>"><%= name %></span></li>
  1 +<li data-type="todo" data-id="<%= id %>" class="<%= done ? 'done' : '' %>">
  2 +<div class="todo">
  3 + <div class="display">
  4 +<input class="check" type="checkbox" <%= done ? 'checked' : '' %>/>
  5 +<span class="trashcan" data-type="todo" data-id="<%= id %>"></span>
  6 +<span contenteditable="true" data-type="todo" data-id="<%= id %>" class="todo-item"><%= name %></span>
  7 +</div>
  8 +</div>
  9 +</li>
  10 +
  11 +
4 templates/todolist.template
@@ -3,8 +3,8 @@
3 3 <li data-type="todo" data-id="<%= todo.id %>" class="<%= todo.done ? 'done' : '' %>">
4 4 <div class="todo">
5 5 <div class="display">
6   -<input class="check" type="checkbox"/>
7   -<span class="checkbox"></span><span class="trashcan" data-type="todo" data-id="<%= todo.id %>"></span><span contenteditable="true" data-type="todo" data-id="<%= todo.id %>" class="todo-item"><%= todo.name %></span>
  6 +<input class="check" type="checkbox" <%= todo.done ? 'checked' : '' %>/>
  7 +<span class="trashcan" data-type="todo" data-id="<%= todo.id %>"></span><span contenteditable="true" data-type="todo" data-id="<%= todo.id %>" class="todo-item"><%= todo.name %></span>
8 8 </div>
9 9 </div>
10 10 </li>

0 comments on commit bdf404e

Please sign in to comment.
Something went wrong with that request. Please try again.