| OLD | NEW |
| (Empty) | |
| 1 library todomvc.web.elements.td_todos; |
| 2 |
| 3 import 'dart:html'; |
| 4 import 'package:polymer/polymer.dart'; |
| 5 import 'td_input.dart'; |
| 6 import 'td_model.dart'; |
| 7 |
| 8 @CustomTag('td-todos') |
| 9 class TodoList extends PolymerElement { |
| 10 @published String modelId; |
| 11 |
| 12 @observable TodoModel model; |
| 13 @observable String activeRoute; |
| 14 |
| 15 factory TodoList() => new Element.tag('td-todos'); |
| 16 TodoList.created() : super.created(); |
| 17 |
| 18 TodoInput get _newTodo => $['new-todo']; |
| 19 |
| 20 void modelIdChanged() { |
| 21 model = document.querySelector('#$modelId'); |
| 22 } |
| 23 |
| 24 void routeAction(e, route) { |
| 25 if (model != null) model.filter = route; |
| 26 |
| 27 // TODO(jmesserly): polymer_expressions lacks boolean conversions. |
| 28 activeRoute = (route != null && route != '') ? route : 'all'; |
| 29 } |
| 30 |
| 31 void addTodoAction() { |
| 32 model.newItem(_newTodo.value); |
| 33 // when polyfilling Object.observe, make sure we update immediately |
| 34 Observable.dirtyCheck(); |
| 35 _newTodo.value = ''; |
| 36 } |
| 37 |
| 38 void cancelAddTodoAction() { |
| 39 _newTodo.value = ''; |
| 40 } |
| 41 |
| 42 void itemChangedAction() { |
| 43 if (model != null) model.itemsChanged(); |
| 44 } |
| 45 |
| 46 void destroyItemAction(e, detail) { |
| 47 model.destroyItem(detail); |
| 48 } |
| 49 |
| 50 void toggleAllCompletedAction(e, detail, sender) { |
| 51 model.setItemsCompleted(sender.checked); |
| 52 } |
| 53 |
| 54 void clearCompletedAction() { |
| 55 model.clearItems(); |
| 56 } |
| 57 |
| 58 // TODO(jmesserly): workaround for HTML Imports not setting correct baseURI |
| 59 String get baseUri => declaration.ownerDocument == document ? '../' : ''; |
| 60 } |
| OLD | NEW |