OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
4 for details. All rights reserved. Use of this source code is governed by a | 4 for details. All rights reserved. Use of this source code is governed by a |
5 BSD-style license that can be found in the LICENSE file. | 5 BSD-style license that can be found in the LICENSE file. |
6 --> | 6 --> |
7 <html lang="en"> | 7 <html lang="en"> |
8 <head> | 8 <head> |
9 <meta charset="utf-8"> | 9 <meta charset="utf-8"> |
10 <link rel="import" href="router_options.html"> | 10 <link rel="import" href="router_options.html"> |
11 <link rel="import" href="todo_row.html"> | 11 <link rel="import" href="todo_row.html"> |
12 </head> | 12 </head> |
13 <body> | 13 <body> |
14 <element name="todo-app" apply-author-styles> | 14 <polymer-element name="todo-app"> |
15 <template> | 15 <template> |
16 <section id="todoapp"> | 16 <section id="todoapp"> |
17 <header id="header"> | 17 <header id="header"> |
18 <h1 class='title'>todos</h1> | 18 <h1 class='title'>todos</h1> |
19 <form on-submit="addTodo($event)"> | 19 <form on-submit="addTodo"> |
20 <input id="new-todo" placeholder="What needs to be done?" autofocus | 20 <input id="new-todo" placeholder="What needs to be done?" autofocus |
21 on-change="addTodo($event)"> | 21 on-change="addTodo"> |
22 </form> | 22 </form> |
23 </header> | 23 </header> |
24 <section id="main"> | 24 <section id="main"> |
25 <input id="toggle-all" type="checkbox" bind-checked="app.allChecked"> | 25 <input id="toggle-all" type="checkbox" checked="{{app.allChecked}}"> |
26 <label for="toggle-all"></label> | 26 <label for="toggle-all"></label> |
27 <ul id="todo-list"> | 27 <ul id="todo-list"> |
28 <template iterate="x in app.todos"> | 28 <template repeat="{{app.visibleTodos}}"> |
29 <template if="viewModel.isVisible(x)"> | 29 <li is="todo-row" todo="{{}}"></li> |
30 <todo-row todo="{{x}}"></todo-row> | |
31 </template> | |
32 </template> | 30 </template> |
33 </ul> | 31 </ul> |
34 </section> | 32 </section> |
35 <template if="app.todos.length > 0"> | 33 <template bind if="{{app.todos.length > 0}}"> |
36 <footer id="footer"> | 34 <footer id="footer"> |
37 <span id="todo-count"><strong>{{app.remaining}}</strong></span> | 35 <span id="todo-count"><strong>{{app.remaining}}</strong></span> |
38 <router-options id="filters"> | 36 <ul is="router-options" id="filters"> |
39 <li> <a href="#/">All</a> </li> | 37 <li> <a href="#/">All</a> </li> |
40 <li> <a href="#/active">Active</a> </li> | 38 <li> <a href="#/active">Active</a> </li> |
41 <li> <a href="#/completed">Completed</a> </li> | 39 <li> <a href="#/completed">Completed</a> </li> |
42 </router-options> | 40 </ul> |
43 <template if="app.doneCount > 0"> | 41 <template bind if="{{app.hasCompleteTodos}}"> |
44 <button id="clear-completed" on-click="app.clearDone()"> | 42 <button id="clear-completed" on-click="clear"> |
45 Clear completed ({{app.doneCount}}) | 43 Clear completed ({{app.doneCount}}) |
46 </button> | 44 </button> |
47 </template> | 45 </template> |
48 </footer> | 46 </footer> |
49 </template> | 47 </template> |
50 </section> | 48 </section> |
51 <footer id="info"> | 49 <footer id="info"> |
52 <p>Double-click to edit a todo.</p> | 50 <p>Double-click to edit a todo.</p> |
53 <p>Credits: the <a href="http://www.dartlang.org">Dart</a> team.</p> | 51 <p>Credits: the <a href="http://www.dartlang.org">Dart</a> team.</p> |
54 <p> | 52 <p> |
55 Learn more about | 53 Learn more about |
56 <a href="https://www.dartlang.org/articles/dart-web-components/">Dart + We
b Components</a> | 54 <a href="https://www.dartlang.org/articles/dart-web-components/">Dart + We
b Components</a> |
57 or | 55 or |
58 <a href="https://github.com/dart-lang/web-ui/tree/master/example/todomvc">
view the source</a>. | 56 <a href="https://github.com/dart-lang/web-ui/tree/master/example/todomvc">
view the source</a>. |
59 </p> | 57 </p> |
60 <p>Part of <a href="http://todomvc.com">TodoMVC</a>.</p> | 58 <p>Part of <a href="http://todomvc.com">TodoMVC</a>.</p> |
61 </footer> | 59 </footer> |
62 </template> | 60 </template> |
63 <script type="application/dart"> | 61 <script type="application/dart" src="app.dart"></script> |
64 import 'dart:html'; | 62 </polymer-element> |
65 import 'model.dart'; | |
66 import 'package:web_ui/web_ui.dart'; | |
67 | |
68 class TodoApp extends WebComponent { | |
69 void addTodo(Event e) { | |
70 e.preventDefault(); // don't submit the form | |
71 var input = query('#new-todo'); | |
72 if (input.value == '') return; | |
73 app.todos.add(new Todo(input.value)); | |
74 input.value = ''; | |
75 } | |
76 } | |
77 </script> | |
78 </element> | |
79 </body> | 63 </body> |
80 </html> | 64 </html> |
OLD | NEW |