| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 const DeletableItem = options.DeletableItem; | 6 const DeletableItem = options.DeletableItem; |
| 7 const DeletableItemList = options.DeletableItemList; | 7 const DeletableItemList = options.DeletableItemList; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Creates a new list item with support for inline editing. | 10 * Creates a new list item with support for inline editing. |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 /** | 298 /** |
| 299 * Called a key is pressed. Handles committing and cancelling edits. | 299 * Called a key is pressed. Handles committing and cancelling edits. |
| 300 * @param {Event} e The key down event. | 300 * @param {Event} e The key down event. |
| 301 * @private | 301 * @private |
| 302 */ | 302 */ |
| 303 handleKeyDown_: function(e) { | 303 handleKeyDown_: function(e) { |
| 304 if (!this.editing) | 304 if (!this.editing) |
| 305 return; | 305 return; |
| 306 | 306 |
| 307 var endEdit = false; | 307 var endEdit = false; |
| 308 switch (e.keyIdentifier) { | 308 switch (e.key) { |
| 309 case 'U+001B': // Esc | 309 case 'Escape': |
| 310 this.editCancelled_ = true; | 310 this.editCancelled_ = true; |
| 311 endEdit = true; | 311 endEdit = true; |
| 312 break; | 312 break; |
| 313 case 'Enter': | 313 case 'Enter': |
| 314 if (this.currentInputIsValid) | 314 if (this.currentInputIsValid) |
| 315 endEdit = true; | 315 endEdit = true; |
| 316 break; | 316 break; |
| 317 } | 317 } |
| 318 | 318 |
| 319 if (endEdit) { | 319 if (endEdit) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 return true; | 405 return true; |
| 406 }, | 406 }, |
| 407 }; | 407 }; |
| 408 | 408 |
| 409 // Export | 409 // Export |
| 410 return { | 410 return { |
| 411 InlineEditableItem: InlineEditableItem, | 411 InlineEditableItem: InlineEditableItem, |
| 412 InlineEditableItemList: InlineEditableItemList, | 412 InlineEditableItemList: InlineEditableItemList, |
| 413 }; | 413 }; |
| 414 }); | 414 }); |
| OLD | NEW |