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.personal_options', function() { | 5 cr.define('options.personal_options', function() { |
6 const DeletableItem = options.DeletableItem; | 6 const DeletableItem = options.DeletableItem; |
7 const DeletableItemList = options.DeletableItemList; | 7 const DeletableItemList = options.DeletableItemList; |
8 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | 8 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; |
9 | 9 |
10 var localStrings = new LocalStrings(); | 10 var localStrings = new LocalStrings(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 nameEl.className = 'profile-item'; | 52 nameEl.className = 'profile-item'; |
53 if (profileInfo.isCurrentProfile) | 53 if (profileInfo.isCurrentProfile) |
54 nameEl.classList.add('profile-item-current'); | 54 nameEl.classList.add('profile-item-current'); |
55 | 55 |
56 var displayName = profileInfo.name; | 56 var displayName = profileInfo.name; |
57 if (profileInfo.isCurrentProfile) | 57 if (profileInfo.isCurrentProfile) |
58 displayName = localStrings.getStringF( | 58 displayName = localStrings.getStringF( |
59 'profilesListItemCurrent', | 59 'profilesListItemCurrent', |
60 profileInfo.name) | 60 profileInfo.name) |
61 nameEl.textContent = displayName; | 61 nameEl.textContent = displayName; |
62 }, | 62 } |
James Hawkins
2011/10/14 20:51:24
Why did you remove the comma?
binji
2011/10/14 21:17:14
Strange, I thought it complained about it once.
| |
63 }; | 63 }; |
64 | 64 |
65 var ProfileList = cr.ui.define('list'); | 65 var ProfileList = cr.ui.define('list'); |
66 | 66 |
67 ProfileList.prototype = { | 67 ProfileList.prototype = { |
68 __proto__: DeletableItemList.prototype, | 68 __proto__: DeletableItemList.prototype, |
69 | 69 |
70 /** @inheritDoc */ | 70 /** @inheritDoc */ |
71 decorate: function() { | 71 decorate: function() { |
72 DeletableItemList.prototype.decorate.call(this); | 72 DeletableItemList.prototype.decorate.call(this); |
73 this.selectionModel = new ListSingleSelectionModel(); | 73 this.selectionModel = new ListSingleSelectionModel(); |
74 | |
75 this.addEventListener('dblclick', this.handleDoubleClick_); | |
74 }, | 76 }, |
75 | 77 |
76 /** @inheritDoc */ | 78 /** @inheritDoc */ |
77 createItem: function(pageInfo) { | 79 createItem: function(pageInfo) { |
78 var item = new ProfileListItem(pageInfo); | 80 var item = new ProfileListItem(pageInfo); |
79 return item; | 81 return item; |
80 }, | 82 }, |
81 | 83 |
82 /** @inheritDoc */ | 84 /** @inheritDoc */ |
83 deleteItemAtIndex: function(index) { | 85 deleteItemAtIndex: function(index) { |
84 ManageProfileOverlay.showDeleteDialog(this.dataModel.item(index)); | 86 ManageProfileOverlay.showDeleteDialog(this.dataModel.item(index)); |
85 }, | 87 }, |
88 | |
89 /** | |
90 * Callback for the double click event. | |
91 * @param {Event} e The mouse event object. | |
92 * @private | |
93 */ | |
94 handleDoubleClick_: function(e) { | |
James Hawkins
2011/10/14 20:51:24
Hmm, logic for double clicking used to be handled
binji
2011/10/14 21:17:14
Done.
| |
95 var target = this.getListItemAncestor(e.target); | |
96 if (target) | |
97 this.activateItemAtIndex(this.getIndexOfListItem(target)); | |
98 }, | |
99 | |
100 /** | |
101 * Called when a list item is activated, currently only by a double click | |
102 * event. | |
103 * @param {number} index The index of the activated item. | |
104 */ | |
105 activateItemAtIndex: function(index) { | |
106 ManageProfileOverlay.showManageDialog(this.dataModel.item(index)); | |
107 } | |
86 }; | 108 }; |
87 | 109 |
88 return { | 110 return { |
89 ProfileList: ProfileList | 111 ProfileList: ProfileList |
90 }; | 112 }; |
91 }); | 113 }); |
92 | 114 |
OLD | NEW |