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

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') | ui/webui/resources/js/cr/ui/focus_grid.js » ('j') | 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..36b2fa0a3ebef299b60d85110ddf07c0b2719a98 100644
--- a/chrome/browser/resources/downloads/manager.js
+++ b/chrome/browser/resources/downloads/manager.js
@@ -102,7 +102,14 @@ cr.define('downloads', function() {
/** @param {!downloads.Data} data Info about the item to update. */
updateItem: function(data) {
- this.idMap_[data.id].render(data);
+ var activeElement = document.activeElement;
+
+ var item = this.idMap_[data.id];
+ item.render(data);
+ var focusRow = this.decorateItem_(item);
+
+ if (activeElement != document.activeElement)
+ focusRow.getEquivalentElement(activeElement).focus();
},
/**
@@ -117,17 +124,25 @@ cr.define('downloads', function() {
this.focusGrid_.destroy();
this.items_.forEach(function(item) {
- downloads.FocusRow.decorate(item.view.node, item.view, this.node_);
- var focusRow = assertInstanceof(item.view.node, downloads.FocusRow);
+ var focusRow = this.decorateItem_(item);
this.focusGrid_.addRow(focusRow);
- // Focus the equivalent element in the focusRow because the active
- // element may no longer be visible.
- if (focusRow.contains(activeElement))
+ if (activeElement != document.activeElement &&
+ focusRow.contains(activeElement)) {
focusRow.getEquivalentElement(activeElement).focus();
+ }
}, this);
},
+ /**
+ * @param {!downloads.Item} item An item to decorate as a FocusRow.
+ * @return {!downloads.FocusRow} |item| decorated as a FocusRow.
+ */
+ decorateItem_: function(item) {
+ downloads.FocusRow.decorate(item.view.node, item.view, this.node_);
+ return assertInstanceof(item.view.node, downloads.FocusRow);
+ },
+
/** @return {number} The number of downloads shown on the page. */
size: function() {
return this.items_.length;
« no previous file with comments | « chrome/browser/resources/downloads/item_view.js ('k') | ui/webui/resources/js/cr/ui/focus_grid.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698