| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 6 /** |
| 7 * @constructor | 7 * @constructor |
| 8 * @extends {HTMLDivElement} | 8 * @extends {HTMLDivElement} |
| 9 */ | 9 */ |
| 10 var EditableTextField = cr.ui.define('div'); | 10 var EditableTextField = cr.ui.define('div'); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 /** | 326 /** |
| 327 * Called when a key is pressed. Handles committing and canceling edits. | 327 * Called when a key is pressed. Handles committing and canceling edits. |
| 328 * @param {Event} e The key down event. | 328 * @param {Event} e The key down event. |
| 329 * @private | 329 * @private |
| 330 */ | 330 */ |
| 331 handleKeyDown_: function(e) { | 331 handleKeyDown_: function(e) { |
| 332 if (!this.editing) | 332 if (!this.editing) |
| 333 return; | 333 return; |
| 334 | 334 |
| 335 var endEdit; | 335 var endEdit; |
| 336 switch (e.keyIdentifier) { | 336 switch (e.key) { |
| 337 case 'U+001B': // Esc | 337 case 'Escape': |
| 338 this.editCanceled_ = true; | 338 this.editCanceled_ = true; |
| 339 endEdit = true; | 339 endEdit = true; |
| 340 break; | 340 break; |
| 341 case 'Enter': | 341 case 'Enter': |
| 342 if (this.currentInputIsValid) | 342 if (this.currentInputIsValid) |
| 343 endEdit = true; | 343 endEdit = true; |
| 344 break; | 344 break; |
| 345 } | 345 } |
| 346 | 346 |
| 347 if (endEdit) { | 347 if (endEdit) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 363 return node instanceof EditableTextField; | 363 return node instanceof EditableTextField; |
| 364 }); | 364 }); |
| 365 if (itemAncestor) | 365 if (itemAncestor) |
| 366 document.activeElement.blur(); | 366 document.activeElement.blur(); |
| 367 }); | 367 }); |
| 368 | 368 |
| 369 return { | 369 return { |
| 370 EditableTextField: EditableTextField, | 370 EditableTextField: EditableTextField, |
| 371 }; | 371 }; |
| 372 }); | 372 }); |
| OLD | NEW |