| OLD | NEW |
| 1 // Copyright (c) 2011 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 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; |
| 11 | 11 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 /** | 120 /** |
| 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.selectedItemIndex = i; |
| 132 this.selectionModel.selectedIndex = i; | |
| 133 this.selectionModel.leadIndex = i; | |
| 134 this.inProgramSelection_ = false; | |
| 135 } | |
| 136 } | 132 } |
| 137 }, | 133 }, |
| 138 | 134 |
| 135 /** |
| 136 * Set index to the image selected. |
| 137 * @type {number} index The index of selected image. |
| 138 */ |
| 139 set selectedItemIndex(index) { |
| 140 this.inProgramSelection_ = true; |
| 141 this.selectionModel.selectedIndex = index; |
| 142 this.inProgramSelection_ = false; |
| 143 }, |
| 144 |
| 139 /** @inheritDoc */ | 145 /** @inheritDoc */ |
| 140 get selectedItem() { | 146 get selectedItem() { |
| 141 var index = this.selectionModel.selectedIndex; | 147 var index = this.selectionModel.selectedIndex; |
| 142 return index != -1 ? this.dataModel.item(index) : null; | 148 return index != -1 ? this.dataModel.item(index) : null; |
| 143 }, | 149 }, |
| 144 set selectedItem(selectedItem) { | 150 set selectedItem(selectedItem) { |
| 145 var index = this.indexOf(selectedItem); | 151 var index = this.indexOf(selectedItem); |
| 146 this.inProgramSelection_ = true; | 152 this.inProgramSelection_ = true; |
| 147 this.selectionModel.selectedIndex = index; | 153 this.selectionModel.selectedIndex = index; |
| 148 this.selectionModel.leadIndex = index; | 154 this.selectionModel.leadIndex = index; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 UserImagesGrid.ButtonImages = { | 248 UserImagesGrid.ButtonImages = { |
| 243 TAKE_PHOTO: 'chrome://theme/IDR_BUTTON_USER_IMAGE_TAKE_PHOTO', | 249 TAKE_PHOTO: 'chrome://theme/IDR_BUTTON_USER_IMAGE_TAKE_PHOTO', |
| 244 CHOOSE_FILE: 'chrome://theme/IDR_BUTTON_USER_IMAGE_CHOOSE_FILE', | 250 CHOOSE_FILE: 'chrome://theme/IDR_BUTTON_USER_IMAGE_CHOOSE_FILE', |
| 245 PROFILE_PICTURE: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING' | 251 PROFILE_PICTURE: 'chrome://theme/IDR_PROFILE_PICTURE_LOADING' |
| 246 }; | 252 }; |
| 247 | 253 |
| 248 return { | 254 return { |
| 249 UserImagesGrid: UserImagesGrid | 255 UserImagesGrid: UserImagesGrid |
| 250 }; | 256 }; |
| 251 }); | 257 }); |
| OLD | NEW |