OLD | NEW |
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 Loading... |
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> |
OLD | NEW |