Index: chrome/browser/resources/options2/chromeos/set_wallpaper_options.js |
diff --git a/chrome/browser/resources/options2/chromeos/set_wallpaper_options.js b/chrome/browser/resources/options2/chromeos/set_wallpaper_options.js |
index ed621c0750b81bd603fbf3af12dc2c186c37a57c..aa02567551c5390af3f41644b567cc51717c030b 100644 |
--- a/chrome/browser/resources/options2/chromeos/set_wallpaper_options.js |
+++ b/chrome/browser/resources/options2/chromeos/set_wallpaper_options.js |
@@ -77,20 +77,33 @@ cr.define('options', function() { |
}, |
/** |
+ * Set attributions of wallpaper with given url. |
+ * @param {string} url url of the selected wallpaper. |
+ * @private |
+ */ |
+ setWallpaperAttribution_: function(url) { |
+ for (var i = 0; i < this.wallpapers_.length; i++) { |
+ if (this.wallpapers_[i].url == url) { |
+ $('author-name').textContent = this.wallpapers_[i].author; |
+ $('author-website').textContent = this.wallpapers_[i].website; |
+ return; |
+ } |
+ } |
+ $('author-name').textContent = ''; |
+ $('author-website').textContent = ''; |
+ }, |
+ |
+ /** |
* Handles image selection change. |
* @private |
*/ |
handleImageSelected_: function() { |
var wallpaperGrid = $('wallpaper-grid'); |
- var index = wallpaperGrid.selectionModel.selectedIndex; |
- $('author-name').innerText = this.wallpapers_[index].author; |
- $('author-website').innerText = this.wallpapers_[index].website; |
- |
- // Ignore deselection, selection change caused by program itself and |
- // selection of one of the action buttons. |
- if (index != -1 && |
+ var url = wallpaperGrid.selectedItemUrl; |
+ if (url && |
!wallpaperGrid.inProgramSelection) { |
- chrome.send('selectWallpaper', [index.toString()]); |
+ this.setWallpaperAttribution_(url); |
+ chrome.send('selectWallpaper', [url]); |
} |
}, |
@@ -105,15 +118,13 @@ cr.define('options', function() { |
}, |
/** |
- * Selects user image with the given index. |
- * @param {int} index index of the image to select. |
+ * Selects corresponding wallpaper thumbnail with the given url. |
flackr
2012/04/19 20:13:07
Here too
bshe
2012/04/19 21:05:25
Done.
|
+ * @param {string} url URL of the wallpaper thumbnail to select. |
* @private |
*/ |
- setSelectedImage_: function(index) { |
- var wallpaperGrid = $('wallpaper-grid'); |
- wallpaperGrid.selectedItemIndex = index; |
- $('author-name').innerText = this.wallpapers_[index].author; |
- $('author-website').innerText = this.wallpapers_[index].website; |
+ setSelectedImage_: function(url) { |
+ $('wallpaper-grid').selectedItemUrl = url; |
+ this.setWallpaperAttribution_(url); |
}, |
/** |