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 /** @const */ var DeletableItem = options.DeletableItem; | 6 /** @const */ var DeletableItem = options.DeletableItem; |
7 /** @const */ var DeletableItemList = options.DeletableItemList; | 7 /** @const */ var 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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
644 element.focusedColumnIndex = focusedColumnIndex; | 644 element.focusedColumnIndex = focusedColumnIndex; |
645 element.updateLeadState(); | 645 element.updateLeadState(); |
646 } | 646 } |
647 } | 647 } |
648 }, | 648 }, |
649 | 649 |
650 /** @override */ | 650 /** @override */ |
651 onSetDataModelComplete: function() { | 651 onSetDataModelComplete: function() { |
652 DeletableItemList.prototype.onSetDataModelComplete.call(this); | 652 DeletableItemList.prototype.onSetDataModelComplete.call(this); |
653 | 653 |
654 var firstItem = this.getListItemByIndex(0); | 654 var item = this.getInitialFocusableItem(); |
655 if (firstItem) { | 655 if (item) { |
656 firstItem.setStaticValuesFocusable(true); | 656 item.setStaticValuesFocusable(true); |
657 firstItem.setCloseButtonFocusable(true); | 657 item.setCloseButtonFocusable(true); |
658 if (firstItem.isPlaceholder) | 658 if (item.isPlaceholder) |
659 firstItem.setEditableValuesFocusable(true); | 659 item.setEditableValuesFocusable(true); |
660 } | 660 } |
661 }, | 661 }, |
662 | 662 |
663 /** | 663 /** |
664 * May be overridden by subclasses to disable focusing the placeholder. | 664 * May be overridden by subclasses to disable focusing the placeholder. |
665 * @return {boolean} True if the placeholder element should be focused on | 665 * @return {boolean} True if the placeholder element should be focused on |
666 * edit commit. | 666 * edit commit. |
667 */ | 667 */ |
668 shouldFocusPlaceholder: function() { | 668 shouldFocusPlaceholder: function() { |
669 return true; | 669 return true; |
670 }, | 670 }, |
671 | |
672 /** | |
673 * Override to change which item is initially focusable. | |
674 * @return {options.InlineEditableItem} Initially focusable item or null. | |
675 * @protected | |
676 */ | |
677 getInitialFocusableItem: function() { | |
bondd
2014/12/02 20:35:02
I made this a regular method instead of an ECMA 5
Dan Beam
2014/12/03 01:40:33
Acknowledged.
| |
678 return this.getListItemByIndex(0); | |
679 }, | |
671 }; | 680 }; |
672 | 681 |
673 // Export | 682 // Export |
674 return { | 683 return { |
675 InlineEditableItem: InlineEditableItem, | 684 InlineEditableItem: InlineEditableItem, |
676 InlineEditableItemList: InlineEditableItemList, | 685 InlineEditableItemList: InlineEditableItemList, |
677 }; | 686 }; |
678 }); | 687 }); |
OLD | NEW |