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 */ | 196 */ |
197 WallpaperManager.prototype.toggleSurpriseMe_ = function() { | 197 WallpaperManager.prototype.toggleSurpriseMe_ = function() { |
198 var self = this; | 198 var self = this; |
199 var checkbox = $('surprise-me').querySelector('#checkbox'); | 199 var checkbox = $('surprise-me').querySelector('#checkbox'); |
200 var shouldEnable = !checkbox.classList.contains('checked'); | 200 var shouldEnable = !checkbox.classList.contains('checked'); |
201 WallpaperUtil.saveToStorage(Constants.AccessSurpriseMeEnabledKey, | 201 WallpaperUtil.saveToStorage(Constants.AccessSurpriseMeEnabledKey, |
202 shouldEnable, true, function() { | 202 shouldEnable, true, 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 // Hides the wallpaper set by message if there is any. | |
207 $('wallpaper-set-by-message').textContent = ''; | |
bshe
2015/03/13 21:02:44
I think we should display wallpaper set by message
| |
206 } else { | 208 } else { |
207 // Unchecking the "Surprise me" checkbox falls back to the previous | 209 // Unchecking the "Surprise me" checkbox falls back to the previous |
208 // wallpaper before "Surprise me" was turned on. | 210 // wallpaper before "Surprise me" was turned on. |
209 self.setSelectedWallpaper_(self.wallpaperGrid_.activeItem_); | 211 if (self.wallpaperGrid_.activeItem) { |
210 self.onWallpaperChanged_(self.wallpaperGrid_.activeItem_, | 212 self.setSelectedWallpaper_(self.wallpaperGrid_.activeItem); |
211 self.currentWallpaper_); | 213 self.onWallpaperChanged_(self.wallpaperGrid_.activeItem, |
214 self.currentWallpaper_); | |
215 } | |
212 checkbox.classList.remove('checked'); | 216 checkbox.classList.remove('checked'); |
213 } | 217 } |
214 $('categories-list').disabled = shouldEnable; | 218 $('categories-list').disabled = shouldEnable; |
215 $('wallpaper-grid').disabled = shouldEnable; | 219 $('wallpaper-grid').disabled = shouldEnable; |
216 } else { | 220 } else { |
217 // TODO(bshe): show error message to user. | 221 // TODO(bshe): show error message to user. |
218 console.error('Failed to save surprise me option to chrome storage.'); | 222 console.error('Failed to save surprise me option to chrome storage.'); |
219 } | 223 } |
220 }); | 224 }); |
221 }; | 225 }; |
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1093 } | 1097 } |
1094 this.wallpaperGrid_.dataModel = wallpapersDataModel; | 1098 this.wallpaperGrid_.dataModel = wallpapersDataModel; |
1095 if (selectedItem) { | 1099 if (selectedItem) { |
1096 this.wallpaperGrid_.selectedItem = selectedItem; | 1100 this.wallpaperGrid_.selectedItem = selectedItem; |
1097 this.wallpaperGrid_.activeItem = selectedItem; | 1101 this.wallpaperGrid_.activeItem = selectedItem; |
1098 } | 1102 } |
1099 } | 1103 } |
1100 }; | 1104 }; |
1101 | 1105 |
1102 })(); | 1106 })(); |
OLD | NEW |