Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: samples/third_party/todomvc/web/elements/td_todos.dart

Issue 60353013: Update TodoMVC based on https://github.com/polymer/todomvc (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « samples/third_party/todomvc/web/elements/td_todos.css ('k') | samples/third_party/todomvc/web/elements/td_todos.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698