OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library main; | 5 library main; |
6 | 6 |
7 import 'dart:html'; | 7 import 'dart:html'; |
8 import 'model.dart'; | 8 import 'model.dart'; |
9 import 'package:web_ui/web_ui.dart'; | 9 import 'package:web_ui/web_ui.dart'; |
10 | 10 |
11 main() { | 11 main() { |
| 12 useObservers = true; |
| 13 |
12 // listen on changes to #hash in the URL | 14 // listen on changes to #hash in the URL |
13 // Note: listen on both popState and hashChange, because IE9 doens't support | 15 // Note: listen on both popState and hashChange, because IE9 doens't support |
14 // history API, and it doesn't work properly on Opera 12. | 16 // history API, and it doesn't work properly on Opera 12. |
15 // See http://dartbug.com/5483 | 17 // See http://dartbug.com/5483 |
16 updateFilters(e) { | 18 updateFilters(e) { |
17 viewModel.showIncomplete = window.location.hash != '#/completed'; | 19 viewModel.showIncomplete = window.location.hash != '#/completed'; |
18 viewModel.showDone = window.location.hash != '#/active'; | 20 viewModel.showDone = window.location.hash != '#/active'; |
19 dispatch(); | 21 dispatch(); |
20 } | 22 } |
21 window.onHashChange.listen(updateFilters); | 23 window.onHashChange.listen(updateFilters); |
22 window.onPopState.listen(updateFilters); | 24 window.onPopState.listen(updateFilters); |
23 } | 25 } |
24 | 26 |
25 void addTodo(Event e) { | 27 void addTodo(Event e) { |
26 e.preventDefault(); // don't submit the form | 28 e.preventDefault(); // don't submit the form |
27 var input = query('#new-todo'); | 29 var input = query('#new-todo'); |
28 if (input.value == '') return; | 30 if (input.value == '') return; |
29 app.todos.add(new Todo(input.value)); | 31 app.todos.add(new Todo(input.value)); |
30 input.value = ''; | 32 input.value = ''; |
31 } | 33 } |
OLD | NEW |