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

Unified Diff: samples/third_party/todomvc/web/elements/td_item.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: fix pubspecs 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 side-by-side diff with in-line comments
Download patch
Index: samples/third_party/todomvc/web/elements/td_item.dart
diff --git a/samples/third_party/todomvc/web/elements/td_item.dart b/samples/third_party/todomvc/web/elements/td_item.dart
new file mode 100644
index 0000000000000000000000000000000000000000..854a3fb0c050dbcb32093cf364e5292771fe59e9
--- /dev/null
+++ b/samples/third_party/todomvc/web/elements/td_item.dart
@@ -0,0 +1,45 @@
+library todomvc.web.elements.td_item;
+
+import 'dart:html';
+import 'package:polymer/polymer.dart';
+import 'td_model.dart';
+
+@CustomTag('td-item')
+class TodoItem extends LIElement with Polymer, Observable {
+ @observable bool editing = false;
+ @observable Todo item;
+
+ factory TodoItem() => new Element.tag('li', 'td-item');
+ TodoItem.created() : super.created() { polymerCreated(); }
+
+ editAction() {
+ editing = true;
+ // schedule focus for the end of microtask, when the input will be visible
+ async((_) => $['edit'].focus());
+ }
+
+ commitAction() {
+ if (editing) {
+ editing = false;
+ item.title = item.title.trim();
+ if (item.title == '') {
+ destroyAction();
+ }
+ fire('td-item-changed');
+ }
+ }
+
+ cancelAction() {
+ editing = false;
+ }
+
+ itemChangeAction() {
+ // TODO(jmesserly): asyncFire is needed because "click" fires before
+ // "item.checked" is updated on Firefox. Need to check Polymer.js.
+ asyncFire('td-item-changed');
+ }
+
+ destroyAction() {
+ fire('td-destroy-item', detail: item);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698