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