OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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('options', function() { | 5 cr.define('options', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * A lookup helper function to find the first node that has an id (starting | 9 * A lookup helper function to find the first node that has an id (starting |
10 * at |node| and going up the parent chain). | 10 * at |node| and going up the parent chain). |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 }, | 43 }, |
44 | 44 |
45 /** | 45 /** |
46 * Creates all extension items from scratch. | 46 * Creates all extension items from scratch. |
47 * @private | 47 * @private |
48 */ | 48 */ |
49 showExtensionNodes_: function() { | 49 showExtensionNodes_: function() { |
50 // Iterate over the extension data and add each item to the list. | 50 // Iterate over the extension data and add each item to the list. |
51 this.data_.extensions.forEach(this.createNode_, this); | 51 this.data_.extensions.forEach(this.createNode_, this); |
52 | 52 |
53 var id_to_highlight = this.extensionIdToHighlight(); | |
54 if (id_to_highlight) | |
55 $(id_to_highlight).scrollIntoView(); | |
Finnur
2012/11/29 04:07:34
After fighting with this for a while I'm ready to
Aaron Boodman
2012/11/29 21:39:40
Is it because of the heading layer? You can get th
| |
56 | |
53 if (this.data_.extensions.length == 0) | 57 if (this.data_.extensions.length == 0) |
54 this.classList.add('empty-extension-list'); | 58 this.classList.add('empty-extension-list'); |
55 else | 59 else |
56 this.classList.remove('empty-extension-list'); | 60 this.classList.remove('empty-extension-list'); |
57 }, | 61 }, |
58 | 62 |
59 /** | 63 /** |
60 * Synthesizes and initializes an HTML element for the extension metadata | 64 * Synthesizes and initializes an HTML element for the extension metadata |
61 * given in |extension|. | 65 * given in |extension|. |
62 * @param {Object} extension A dictionary of extension metadata. | 66 * @param {Object} extension A dictionary of extension metadata. |
63 * @private | 67 * @private |
64 */ | 68 */ |
65 createNode_: function(extension) { | 69 createNode_: function(extension) { |
66 var template = $('template-collection').querySelector( | 70 var template = $('template-collection').querySelector( |
67 '.extension-list-item-wrapper'); | 71 '.extension-list-item-wrapper'); |
68 var node = template.cloneNode(true); | 72 var node = template.cloneNode(true); |
69 node.id = extension.id; | 73 node.id = extension.id; |
70 | 74 |
71 if (!extension.enabled || extension.terminated) | 75 if (!extension.enabled || extension.terminated) |
72 node.classList.add('inactive-extension'); | 76 node.classList.add('inactive-extension'); |
73 | 77 |
74 if (!extension.userModifiable) | 78 if (!extension.userModifiable) |
75 node.classList.add('may-not-disable'); | 79 node.classList.add('may-not-disable'); |
76 | 80 |
81 if (node.id == this.extensionIdToHighlight()) | |
82 node.classList.add('extension-highlight'); | |
83 | |
77 var item = node.querySelector('.extension-list-item'); | 84 var item = node.querySelector('.extension-list-item'); |
78 item.style.backgroundImage = 'url(' + extension.icon + ')'; | 85 item.style.backgroundImage = 'url(' + extension.icon + ')'; |
79 | 86 |
80 var title = node.querySelector('.extension-title'); | 87 var title = node.querySelector('.extension-title'); |
81 title.textContent = extension.name; | 88 title.textContent = extension.name; |
82 | 89 |
83 var version = node.querySelector('.extension-version'); | 90 var version = node.querySelector('.extension-version'); |
84 version.textContent = extension.version; | 91 version.textContent = extension.version; |
85 | 92 |
86 var disableReason = node.querySelector('.extension-disable-reason'); | 93 var disableReason = node.querySelector('.extension-disable-reason'); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 panel.hidden = false; | 280 panel.hidden = false; |
274 var list = panel.querySelector('ul'); | 281 var list = panel.querySelector('ul'); |
275 extension.installWarnings.forEach(function(warning) { | 282 extension.installWarnings.forEach(function(warning) { |
276 var li = document.createElement('li'); | 283 var li = document.createElement('li'); |
277 li[warning.isHTML ? 'innerHTML' : 'innerText'] = warning.message; | 284 li[warning.isHTML ? 'innerHTML' : 'innerText'] = warning.message; |
278 list.appendChild(li); | 285 list.appendChild(li); |
279 }); | 286 }); |
280 } | 287 } |
281 | 288 |
282 this.appendChild(node); | 289 this.appendChild(node); |
290 }, | |
291 | |
292 /** | |
293 * Returns the extension id of the extension to highlight, if any. | |
294 * @private | |
295 */ | |
296 extensionIdToHighlight: function() { | |
Aaron Boodman
2012/11/29 21:39:40
See parseQueryParams() in browser/resources/shared
| |
297 var queryString = location.search.substring(1).split('&'); | |
298 for (var i = 0; i < queryString.length; ++i) { | |
299 var param = queryString[i].split('='); | |
300 if (param[0] == 'id' && param.length > 1) | |
301 return param[1]; | |
302 } | |
303 return ''; | |
283 } | 304 } |
284 }; | 305 }; |
285 | 306 |
286 return { | 307 return { |
287 ExtensionsList: ExtensionsList | 308 ExtensionsList: ExtensionsList |
288 }; | 309 }; |
289 }); | 310 }); |
OLD | NEW |