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

Unified Diff: chrome/browser/resources/downloads/manager.js

Issue 1000163002: downloads: put [column-type] in HTML template instead of JS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@undo-order
Patch Set: hcarmona@ review Created 5 years, 9 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
« no previous file with comments | « chrome/browser/resources/downloads/item_view.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/downloads/manager.js
diff --git a/chrome/browser/resources/downloads/manager.js b/chrome/browser/resources/downloads/manager.js
index 89a5aac0a88e7bfd1d37c5124b81f955ec92e433..7d18e571c326be800ad7fcdd98ff2051144eabce 100644
--- a/chrome/browser/resources/downloads/manager.js
+++ b/chrome/browser/resources/downloads/manager.js
@@ -102,7 +102,9 @@ cr.define('downloads', function() {
/** @param {!downloads.Data} data Info about the item to update. */
updateItem: function(data) {
- this.idMap_[data.id].render(data);
+ var item = this.idMap_[data.id];
+ item.render(data);
+ this.decorateItem_(item);
},
/**
@@ -110,22 +112,30 @@ cr.define('downloads', function() {
* @private
*/
rebuildFocusGrid_: function() {
- var activeElement = document.activeElement;
-
/** @private {!cr.ui.FocusGrid} */
this.focusGrid_ = this.focusGrid_ || new cr.ui.FocusGrid();
this.focusGrid_.destroy();
+ this.items_.forEach(this.decorateItem_, this);
+ },
- this.items_.forEach(function(item) {
- downloads.FocusRow.decorate(item.view.node, item.view, this.node_);
- var focusRow = assertInstanceof(item.view.node, downloads.FocusRow);
+ /**
+ * @param {!download.Item} item An item to decorate as a downloads.FocusRow.
+ */
+ decorateItem_: function(item) {
+ var activeElement = document.activeElement;
+
+ downloads.FocusRow.decorate(item.view.node, item.view, this.node_);
+ var focusRow = assertInstanceof(item.view.node, downloads.FocusRow);
+
+ if (this.focusGrid_.rows.indexOf(focusRow) < 0)
this.focusGrid_.addRow(focusRow);
- // Focus the equivalent element in the focusRow because the active
- // element may no longer be visible.
- if (focusRow.contains(activeElement))
- focusRow.getEquivalentElement(activeElement).focus();
- }, this);
+ // Focus the equivalent element in the focusRow because the active
+ // element may no longer be visible.
+ if (focusRow.focusableElements.indexOf(activeElement) >= 0 &&
hcarmona 2015/03/12 19:12:52 This should stay "if (focusRow.contains(activeElem
Dan Beam 2015/03/12 20:19:03 Fixed (differently though, see updated code)
+ activeElement != document.activeElement) {
+ focusRow.getEquivalentElement(activeElement).focus();
+ }
},
/** @return {number} The number of downloads shown on the page. */
« no previous file with comments | « chrome/browser/resources/downloads/item_view.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698