Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 /** | 5 /** |
| 6 * WallpaperManager constructor. | 6 * WallpaperManager constructor. |
| 7 * | 7 * |
| 8 * WallpaperManager objects encapsulate the functionality of the wallpaper | 8 * WallpaperManager objects encapsulate the functionality of the wallpaper |
| 9 * manager extension. | 9 * manager extension. |
| 10 * | 10 * |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 * @private | 196 * @private |
| 197 */ | 197 */ |
| 198 WallpaperManager.prototype.toggleSurpriseMe_ = function() { | 198 WallpaperManager.prototype.toggleSurpriseMe_ = function() { |
| 199 var self = this; | 199 var self = this; |
| 200 var checkbox = $('surprise-me').querySelector('#checkbox'); | 200 var checkbox = $('surprise-me').querySelector('#checkbox'); |
| 201 var shouldEnable = !checkbox.classList.contains('checked'); | 201 var shouldEnable = !checkbox.classList.contains('checked'); |
| 202 var onSuccess = function() { | 202 var onSuccess = function() { |
| 203 if (chrome.runtime.lastError == null) { | 203 if (chrome.runtime.lastError == null) { |
| 204 if (shouldEnable) { | 204 if (shouldEnable) { |
| 205 checkbox.classList.add('checked'); | 205 checkbox.classList.add('checked'); |
| 206 if (self.document_.body.hasAttribute('custom')) | |
| 207 self.document_.body.removeAttribute('custom'); | |
|
bshe
2015/07/15 18:40:49
custom should only be used to indicate if we are a
| |
| 206 // Hides the wallpaper set by message if there is any. | 208 // Hides the wallpaper set by message if there is any. |
| 207 $('wallpaper-set-by-message').textContent = ''; | 209 $('wallpaper-set-by-message').textContent = ''; |
| 208 } else { | 210 } else { |
| 209 // Unchecking the "Surprise me" checkbox falls back to the previous | 211 // Unchecking the "Surprise me" checkbox falls back to the previous |
| 210 // wallpaper before "Surprise me" was turned on. | 212 // wallpaper before "Surprise me" was turned on. |
| 211 if (self.wallpaperGrid_.activeItem) { | 213 if (self.wallpaperGrid_.activeItem) { |
| 212 self.setSelectedWallpaper_(self.wallpaperGrid_.activeItem); | 214 self.setSelectedWallpaper_(self.wallpaperGrid_.activeItem); |
| 213 self.onWallpaperChanged_(self.wallpaperGrid_.activeItem, | 215 self.onWallpaperChanged_(self.wallpaperGrid_.activeItem, |
| 214 self.currentWallpaper_); | 216 self.currentWallpaper_); |
| 215 } | 217 } |
| 218 var selectedIndex = self.categoriesList_.selectionModel.selectedIndex; | |
| 219 if (selectedIndex == self.categoriesList_.dataModel.length - 1) | |
| 220 self.document_.body.setAttribute('custom', ''); | |
| 216 checkbox.classList.remove('checked'); | 221 checkbox.classList.remove('checked'); |
| 217 } | 222 } |
| 218 $('categories-list').disabled = shouldEnable; | 223 $('categories-list').disabled = shouldEnable; |
| 219 $('wallpaper-grid').disabled = shouldEnable; | 224 $('wallpaper-grid').disabled = shouldEnable; |
| 220 } else { | 225 } else { |
| 221 // TODO(bshe): show error message to user. | 226 // TODO(bshe): show error message to user. |
| 222 console.error('Failed to save surprise me option to chrome storage.'); | 227 console.error('Failed to save surprise me option to chrome storage.'); |
| 223 } | 228 } |
| 224 }; | 229 }; |
| 225 | 230 |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1106 } | 1111 } |
| 1107 this.wallpaperGrid_.dataModel = wallpapersDataModel; | 1112 this.wallpaperGrid_.dataModel = wallpapersDataModel; |
| 1108 if (selectedItem) { | 1113 if (selectedItem) { |
| 1109 this.wallpaperGrid_.selectedItem = selectedItem; | 1114 this.wallpaperGrid_.selectedItem = selectedItem; |
| 1110 this.wallpaperGrid_.activeItem = selectedItem; | 1115 this.wallpaperGrid_.activeItem = selectedItem; |
| 1111 } | 1116 } |
| 1112 } | 1117 } |
| 1113 }; | 1118 }; |
| 1114 | 1119 |
| 1115 })(); | 1120 })(); |
| OLD | NEW |