| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library editable_label; | 5 library editable_label; |
| 6 | 6 |
| 7 import 'dart:html'; | 7 import 'dart:html'; |
| 8 import 'package:observe/observe.dart'; | 8 import 'package:observe/observe.dart'; |
| 9 import 'package:polymer/polymer.dart'; | 9 import 'package:polymer/polymer.dart'; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * Label whose [value] can be edited by double clicking. When editing, it | 12 * Label whose [value] can be edited by double clicking. When editing, it |
| 13 * displays a form and input element, otherwise it displays the label. | 13 * displays a form and input element, otherwise it displays the label. |
| 14 */ | 14 */ |
| 15 class EditableLabel extends PolymerElement with ObservableMixin { | 15 class EditableLabel extends PolymerElement with ObservableMixin { |
| 16 @observable bool editing = false; | 16 @observable bool editing = false; |
| 17 @observable String value = ''; | 17 @observable String value = ''; |
| 18 bool get applyAuthorStyles => true; |
| 18 | 19 |
| 19 // TODO(jmesserly): replace this with allowing not-operator in templates. | 20 // TODO(jmesserly): replace this with allowing not-operator in templates. |
| 20 bool get notEditing => !editing; | 21 bool get notEditing => !editing; |
| 21 | 22 |
| 22 InputElement get _editBox => getShadowRoot("editable-label").query('#edit'); | 23 InputElement get _editBox => getShadowRoot("editable-label").query('#edit'); |
| 23 | 24 |
| 24 void created() { | 25 void created() { |
| 25 super.created(); | 26 super.created(); |
| 26 | 27 |
| 27 bindProperty(this, const Symbol('editing'), | 28 bindProperty(this, const Symbol('editing'), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 47 value = _editBox.value; | 48 value = _editBox.value; |
| 48 editing = false; | 49 editing = false; |
| 49 } | 50 } |
| 50 | 51 |
| 51 void maybeCancel(KeyboardEvent e) { | 52 void maybeCancel(KeyboardEvent e) { |
| 52 if (e.keyCode == KeyCode.ESC) { | 53 if (e.keyCode == KeyCode.ESC) { |
| 53 editing = false; | 54 editing = false; |
| 54 } | 55 } |
| 55 } | 56 } |
| 56 } | 57 } |
| OLD | NEW |