Chromium Code Reviews| 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..ca7b02689fc5fafb359f413c22a549d474c5e4de 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').innerText = this.wallpapers_[i].author; |
| + $('author-website').innerText = this.wallpapers_[i].website; |
| + return; |
| + } |
| + } |
| + $('author-name').innerText = ''; |
| + $('author-website').innerText = ''; |
|
flackr
2012/04/18 20:16:34
Can you use textContent instead of innerText?
bshe
2012/04/19 00:15:57
Done.
|
| + }, |
| + |
| + /** |
| * 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. |
| + * @param {string} url url of the wallpaper thumbnail to select. |
|
flackr
2012/04/18 20:16:34
I believe in the comment parts you should capitali
bshe
2012/04/19 00:15:57
Done.
|
| * @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); |
| }, |
| /** |