OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('downloads', function() { | 5 cr.define('downloads', function() { |
6 /** | 6 /** |
7 * Class to own and manage download items. | 7 * Class to own and manage download items. |
8 * @constructor | 8 * @constructor |
9 */ | 9 */ |
10 function Manager() {} | 10 function Manager() {} |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 * @private | 126 * @private |
127 */ | 127 */ |
128 updateItem_: function(data) { | 128 updateItem_: function(data) { |
129 var activeElement = document.activeElement; | 129 var activeElement = document.activeElement; |
130 | 130 |
131 var item = this.idMap_[data.id]; | 131 var item = this.idMap_[data.id]; |
132 item.update(data); | 132 item.update(data); |
133 var focusRow = this.decorateItem_(item); | 133 var focusRow = this.decorateItem_(item); |
134 | 134 |
135 if (focusRow.contains(activeElement) && | 135 if (focusRow.contains(activeElement) && |
136 !downloads.FocusRow.shouldFocus(activeElement)) { | 136 !cr.ui.FocusRow.isFocusable(activeElement)) { |
137 focusRow.getEquivalentElement(activeElement).focus(); | 137 focusRow.getEquivalentElement(activeElement).focus(); |
138 } | 138 } |
139 }, | 139 }, |
140 | 140 |
141 /** | 141 /** |
142 * Rebuild the focusGrid_ using the elements that each download will have. | 142 * Rebuild the focusGrid_ using the elements that each download will have. |
143 * @private | 143 * @private |
144 */ | 144 */ |
145 rebuildFocusGrid_: function() { | 145 rebuildFocusGrid_: function() { |
146 var activeElement = document.activeElement; | 146 var activeElement = document.activeElement; |
147 | 147 |
148 /** @private {!cr.ui.FocusGrid} */ | 148 /** @private {!cr.ui.FocusGrid} */ |
149 this.focusGrid_ = this.focusGrid_ || new cr.ui.FocusGrid(); | 149 this.focusGrid_ = this.focusGrid_ || new cr.ui.FocusGrid(); |
150 this.focusGrid_.destroy(); | 150 this.focusGrid_.destroy(); |
151 | 151 |
152 this.items_.forEach(function(item) { | 152 this.items_.forEach(function(item) { |
153 var focusRow = this.decorateItem_(item); | 153 var focusRow = this.decorateItem_(item); |
154 this.focusGrid_.addRow(focusRow); | 154 this.focusGrid_.addRow(focusRow); |
155 | 155 |
156 if (focusRow.contains(activeElement) && | 156 if (focusRow.contains(activeElement) && |
157 !downloads.FocusRow.shouldFocus(activeElement)) { | 157 !cr.ui.FocusRow.isFocusable(activeElement)) { |
158 focusRow.getEquivalentElement(activeElement).focus(); | 158 focusRow.getEquivalentElement(activeElement).focus(); |
159 } | 159 } |
160 }, this); | 160 }, this); |
161 this.focusGrid_.ensureRowActive(); | 161 this.focusGrid_.ensureRowActive(); |
162 }, | 162 }, |
163 | 163 |
164 /** | 164 /** |
165 * @param {!downloads.ItemView} item An item to decorate as a FocusRow. | 165 * @param {!downloads.ItemView} item An item to decorate as a FocusRow. |
166 * @return {!downloads.FocusRow} |item| decorated as a FocusRow. | 166 * @return {!downloads.FocusRow} |item| decorated as a FocusRow. |
167 * @private | 167 * @private |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 }; | 255 }; |
256 | 256 |
257 Manager.size = function() { | 257 Manager.size = function() { |
258 return Manager.getInstance().size_(); | 258 return Manager.getInstance().size_(); |
259 }; | 259 }; |
260 | 260 |
261 return {Manager: Manager}; | 261 return {Manager: Manager}; |
262 }); | 262 }); |
263 | 263 |
264 window.addEventListener('DOMContentLoaded', downloads.Manager.onLoad); | 264 window.addEventListener('DOMContentLoaded', downloads.Manager.onLoad); |
OLD | NEW |