Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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('extensions', function() { | 5 cr.define('extensions', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Clone a template within the extension error template collection. | 9 * Clone a template within the extension error template collection. |
| 10 * @param {string} templateName The class name of the template to clone. | 10 * @param {string} templateName The class name of the template to clone. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 div.__proto__ = ExtensionError.prototype; | 52 div.__proto__ = ExtensionError.prototype; |
| 53 div.decorateWithError_(error, boundary); | 53 div.decorateWithError_(error, boundary); |
| 54 return div; | 54 return div; |
| 55 } | 55 } |
| 56 | 56 |
| 57 ExtensionError.prototype = { | 57 ExtensionError.prototype = { |
| 58 __proto__: cr.ui.FocusRow.prototype, | 58 __proto__: cr.ui.FocusRow.prototype, |
| 59 | 59 |
| 60 /** @override */ | 60 /** @override */ |
| 61 getEquivalentElement: function(element) { | 61 getEquivalentElement: function(element) { |
| 62 if (element.classList.contains('extension-error-metadata')) | 62 if (element.classList.contains('extension-error-metadata')) |
|
Dan Beam
2015/08/11 01:36:21
as this method would say null.classList
| |
| 63 return this; | 63 return this; |
| 64 if (element.classList.contains('error-delete-button')) { | 64 if (element.classList.contains('error-delete-button')) { |
| 65 return /** @type {!HTMLElement} */ (this.querySelector( | 65 return /** @type {!HTMLElement} */ (this.querySelector( |
| 66 '.error-delete-button')); | 66 '.error-delete-button')); |
| 67 } | 67 } |
| 68 assertNotReached(); | 68 assertNotReached(); |
| 69 return element; | 69 return element; |
| 70 }, | 70 }, |
| 71 | 71 |
| 72 /** | 72 /** |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 * @param {Array<(RuntimeError|ManifestError)>} errors The list of errors. | 169 * @param {Array<(RuntimeError|ManifestError)>} errors The list of errors. |
| 170 */ | 170 */ |
| 171 decorate: function(errors) { | 171 decorate: function(errors) { |
| 172 /** | 172 /** |
| 173 * @private {!Array<(ManifestError|RuntimeError)>} | 173 * @private {!Array<(ManifestError|RuntimeError)>} |
| 174 */ | 174 */ |
| 175 this.errors_ = []; | 175 this.errors_ = []; |
| 176 | 176 |
| 177 this.focusGrid_ = new cr.ui.FocusGrid(); | 177 this.focusGrid_ = new cr.ui.FocusGrid(); |
| 178 this.listContents_ = this.querySelector('.extension-error-list-contents'); | 178 this.listContents_ = this.querySelector('.extension-error-list-contents'); |
| 179 this.listContents_.addEventListener('focus', this.onFocus_.bind(this)); | 179 |
| 180 this.listContents_.addEventListener('focusin', | |
| 181 this.onFocusin_.bind(this)); | |
| 182 errors.forEach(this.addError_, this); | 180 errors.forEach(this.addError_, this); |
| 183 | 181 |
| 184 this.addEventListener('highlightExtensionError', function(e) { | 182 this.addEventListener('highlightExtensionError', function(e) { |
| 185 this.setActiveErrorNode_(e.target); | 183 this.setActiveErrorNode_(e.target); |
| 186 }); | 184 }); |
| 187 this.addEventListener('deleteExtensionError', function(e) { | 185 this.addEventListener('deleteExtensionError', function(e) { |
| 188 this.removeError_(e.detail); | 186 this.removeError_(e.detail); |
| 189 }); | 187 }); |
| 190 | 188 |
| 191 this.querySelector('#extension-error-list-clear').addEventListener( | 189 this.querySelector('#extension-error-list-clear').addEventListener( |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 | 347 |
| 350 if (node) | 348 if (node) |
| 351 node.classList.add('extension-error-active'); | 349 node.classList.add('extension-error-active'); |
| 352 | 350 |
| 353 this.activeError_ = node; | 351 this.activeError_ = node; |
| 354 | 352 |
| 355 this.dispatchEvent( | 353 this.dispatchEvent( |
| 356 new CustomEvent('activeExtensionErrorChanged', | 354 new CustomEvent('activeExtensionErrorChanged', |
| 357 {bubbles: true, detail: node ? node.error : null})); | 355 {bubbles: true, detail: node ? node.error : null})); |
| 358 }, | 356 }, |
| 359 | |
| 360 /** | |
| 361 * The grid should not be focusable once it or an element inside it is | |
| 362 * focused. This is necessary to allow tabbing out of the grid in reverse. | |
| 363 * @private | |
| 364 */ | |
| 365 onFocusin_: function() { | |
| 366 this.listContents_.tabIndex = -1; | |
| 367 }, | |
| 368 | |
| 369 /** | |
| 370 * Focus the first focusable row when tabbing into the grid for the | |
| 371 * first time. | |
| 372 * @private | |
| 373 */ | |
| 374 onFocus_: function() { | |
| 375 var activeRow = this.listContents_.querySelector('.focus-row-active'); | |
| 376 activeRow.getEquivalentElement(null).focus(); | |
|
Dan Beam
2015/08/11 01:36:21
had this code ever worked, this would blow up ;)
hcarmona
2015/08/11 02:03:57
yup
| |
| 377 }, | |
| 378 }; | 357 }; |
| 379 | 358 |
| 380 return { | 359 return { |
| 381 ExtensionErrorList: ExtensionErrorList | 360 ExtensionErrorList: ExtensionErrorList |
| 382 }; | 361 }; |
| 383 }); | 362 }); |
| OLD | NEW |