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

Side by Side Diff: example/todomvc/editable_label.html

Issue 12225039: Support for observable models, fixes #259 (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: Round 2, Fight! Created 7 years, 10 months 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
« no previous file with comments | « no previous file | example/todomvc/main.dart » ('j') | lib/observe.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 3 Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
4 for details. All rights reserved. Use of this source code is governed by a 4 for details. All rights reserved. Use of this source code is governed by a
5 BSD-style license that can be found in the LICENSE file. 5 BSD-style license that can be found in the LICENSE file.
6 --> 6 -->
7 <html> 7 <html>
8 <body> 8 <body>
9 <element name="x-editable-label" extends="div" apply-author-styles> 9 <element name="x-editable-label" extends="div" apply-author-styles>
10 <template> 10 <template>
(...skipping 27 matching lines...) Expand all
38 InputElement get _editBox => _root.query('#edit'); 38 InputElement get _editBox => _root.query('#edit');
39 39
40 void created() { 40 void created() {
41 super.created(); 41 super.created();
42 editing = false; 42 editing = false;
43 value = ''; 43 value = '';
44 } 44 }
45 45
46 void edit() { 46 void edit() {
47 editing = true; 47 editing = true;
48 dispatch(); 48
49 // This causes _editBox to be inserted.
50 deliverChangesSync();
49 51
50 // For IE and Firefox: use .focus(), then reset the value to move the 52 // For IE and Firefox: use .focus(), then reset the value to move the
51 // cursor to the end. 53 // cursor to the end.
52 _editBox.focus(); 54 _editBox.focus();
53 _editBox.value = ''; 55 _editBox.value = '';
54 _editBox.value = value; 56 _editBox.value = value;
55 } 57 }
56 58
57 void update(Event e) { 59 void update(Event e) {
58 e.preventDefault(); // don't submit the form 60 e.preventDefault(); // don't submit the form
59 if (!editing) return; // bail if user canceled 61 if (!editing) return; // bail if user canceled
60 value = _editBox.value; 62 value = _editBox.value;
61 editing = false; 63 editing = false;
62 } 64 }
63 65
64 void maybeCancel(KeyboardEvent e) { 66 void maybeCancel(KeyboardEvent e) {
65 if (e.keyCode == KeyCode.ESC) { 67 if (e.keyCode == KeyCode.ESC) {
66 editing = false; 68 editing = false;
67 } 69 }
68 } 70 }
69 } 71 }
70 </script> 72 </script>
71 </element> 73 </element>
72 </body> 74 </body>
73 </html> 75 </html>
OLDNEW
« no previous file with comments | « no previous file | example/todomvc/main.dart » ('j') | lib/observe.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698