Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Unified Diff: chrome/browser/resources/options2/chromeos/set_wallpaper_options.js

Issue 10021066: Replace the index mapping of wallpaper picker UI and hard coded wallpaper index in C++ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
},
/**

Powered by Google App Engine
This is Rietveld 408576698