Chromium Code Reviews| 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 ArrayDataModel = cr.ui.ArrayDataModel; | 6 const ArrayDataModel = cr.ui.ArrayDataModel; |
| 7 const Grid = cr.ui.Grid; | 7 const Grid = cr.ui.Grid; |
| 8 const GridItem = cr.ui.GridItem; | 8 const GridItem = cr.ui.GridItem; |
| 9 const GridSelectionController = cr.ui.GridSelectionController; | 9 const GridSelectionController = cr.ui.GridSelectionController; |
| 10 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | 10 const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 * URL of the image selected. | 121 * URL of the image selected. |
| 122 * @type {string?} | 122 * @type {string?} |
| 123 */ | 123 */ |
| 124 get selectedItemUrl() { | 124 get selectedItemUrl() { |
| 125 var selectedItem = this.selectedItem; | 125 var selectedItem = this.selectedItem; |
| 126 return selectedItem ? selectedItem.url : null; | 126 return selectedItem ? selectedItem.url : null; |
| 127 }, | 127 }, |
| 128 set selectedItemUrl(url) { | 128 set selectedItemUrl(url) { |
| 129 for (var i = 0, el; el = this.dataModel.item(i); i++) { | 129 for (var i = 0, el; el = this.dataModel.item(i); i++) { |
| 130 if (el.url === url) { | 130 if (el.url === url) { |
| 131 this.inProgramSelection_ = true; | 131 this.inProgramSelection_ = true; |
|
Ivan Korotkov
2012/03/26 20:52:13
Can you replace this with this.selectedItemIndex =
bshe
2012/03/26 21:02:21
Done.
| |
| 132 this.selectionModel.selectedIndex = i; | 132 this.selectionModel.selectedIndex = i; |
| 133 this.selectionModel.leadIndex = i; | 133 this.selectionModel.leadIndex = i; |
| 134 this.inProgramSelection_ = false; | 134 this.inProgramSelection_ = false; |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 }, | 137 }, |
| 138 | 138 |
| 139 /** | |
| 140 * Set index to the image selected. | |
| 141 * @type {number} index The index of selected image. | |
| 142 */ | |
| 143 set selectedItemIndex(index) { | |
| 144 this.inProgramSelection_ = true; | |
| 145 this.selectionModel.selectedIndex = index; | |
|
Ivan Korotkov
2012/03/26 20:52:13
I guess you should be updating leadIndex here as w
bshe
2012/03/26 21:02:21
It seems set selectedIndex also changes lead and a
Ivan Korotkov
2012/03/26 21:05:30
Right, must be a recent change to ListSelectionMod
| |
| 146 this.inProgramSelection_ = false; | |
| 147 }, | |
| 148 | |
| 139 /** @inheritDoc */ | 149 /** @inheritDoc */ |
| 140 get selectedItem() { | 150 get selectedItem() { |
| 141 var index = this.selectionModel.selectedIndex; | 151 var index = this.selectionModel.selectedIndex; |
| 142 return index != -1 ? this.dataModel.item(index) : null; | 152 return index != -1 ? this.dataModel.item(index) : null; |
| 143 }, | 153 }, |
| 144 set selectedItem(selectedItem) { | 154 set selectedItem(selectedItem) { |
| 145 var index = this.indexOf(selectedItem); | 155 var index = this.indexOf(selectedItem); |
| 146 this.inProgramSelection_ = true; | 156 this.inProgramSelection_ = true; |
| 147 this.selectionModel.selectedIndex = index; | 157 this.selectionModel.selectedIndex = index; |
| 148 this.selectionModel.leadIndex = index; | 158 this.selectionModel.leadIndex = index; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 UserImagesGrid.ButtonImages = { | 252 UserImagesGrid.ButtonImages = { |
| 243 TAKE_PHOTO: 'chrome://theme/IDR_BUTTON_USER_IMAGE_TAKE_PHOTO', | 253 TAKE_PHOTO: 'chrome://theme/IDR_BUTTON_USER_IMAGE_TAKE_PHOTO', |
| 244 CHOOSE_FILE: 'chrome://theme/IDR_BUTTON_USER_IMAGE_CHOOSE_FILE', | 254 CHOOSE_FILE: 'chrome://theme/IDR_BUTTON_USER_IMAGE_CHOOSE_FILE', |
| 245 PROFILE_PICTURE: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING' | 255 PROFILE_PICTURE: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING' |
| 246 }; | 256 }; |
| 247 | 257 |
| 248 return { | 258 return { |
| 249 UserImagesGrid: UserImagesGrid | 259 UserImagesGrid: UserImagesGrid |
| 250 }; | 260 }; |
| 251 }); | 261 }); |
| OLD | NEW |