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

Side by Side Diff: chrome/browser/resources/extensions/extension_list.js

Issue 11434024: Support extension highlighting on the extensions page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/extensions/extensions.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = parseQueryParams(document.location)['id'];
54 if (id_to_highlight) {
55 // Scroll offset should be calculated slightly higher than the actual
56 // offset of the element being scrolled to, so that it ends up not all
57 // the way at the top. That way it is clear that there are more elements
58 // above the element being scrolled to.
59 var offset = $(id_to_highlight).offsetTop -
60 (1.2 * $(id_to_highlight).clientHeight);
James Hawkins 2012/11/30 20:11:05 nit: Pull 1.2 out into a constant.
Finnur 2012/11/30 21:49:28 const are not allowed in strict mode, but I factor
61 var wrapper = this.parentNode;
62 var list = wrapper.parentNode;
63 list.scrollTop = offset;
64 }
65
53 if (this.data_.extensions.length == 0) 66 if (this.data_.extensions.length == 0)
54 this.classList.add('empty-extension-list'); 67 this.classList.add('empty-extension-list');
55 else 68 else
56 this.classList.remove('empty-extension-list'); 69 this.classList.remove('empty-extension-list');
57 }, 70 },
58 71
59 /** 72 /**
60 * Synthesizes and initializes an HTML element for the extension metadata 73 * Synthesizes and initializes an HTML element for the extension metadata
61 * given in |extension|. 74 * given in |extension|.
62 * @param {Object} extension A dictionary of extension metadata. 75 * @param {Object} extension A dictionary of extension metadata.
63 * @private 76 * @private
64 */ 77 */
65 createNode_: function(extension) { 78 createNode_: function(extension) {
66 var template = $('template-collection').querySelector( 79 var template = $('template-collection').querySelector(
67 '.extension-list-item-wrapper'); 80 '.extension-list-item-wrapper');
68 var node = template.cloneNode(true); 81 var node = template.cloneNode(true);
69 node.id = extension.id; 82 node.id = extension.id;
70 83
71 if (!extension.enabled || extension.terminated) 84 if (!extension.enabled || extension.terminated)
72 node.classList.add('inactive-extension'); 85 node.classList.add('inactive-extension');
73 86
74 if (!extension.userModifiable) 87 if (!extension.userModifiable)
75 node.classList.add('may-not-disable'); 88 node.classList.add('may-not-disable');
76 89
90 var id_to_highlight = parseQueryParams(document.location)['id'];
James Hawkins 2012/11/30 20:11:05 Optional nit: Pull parseQueryParams...; out into a
Finnur 2012/11/30 21:49:28 Done.
91 if (node.id == id_to_highlight)
92 node.classList.add('extension-highlight');
93
77 var item = node.querySelector('.extension-list-item'); 94 var item = node.querySelector('.extension-list-item');
78 item.style.backgroundImage = 'url(' + extension.icon + ')'; 95 item.style.backgroundImage = 'url(' + extension.icon + ')';
79 96
80 var title = node.querySelector('.extension-title'); 97 var title = node.querySelector('.extension-title');
81 title.textContent = extension.name; 98 title.textContent = extension.name;
82 99
83 var version = node.querySelector('.extension-version'); 100 var version = node.querySelector('.extension-version');
84 version.textContent = extension.version; 101 version.textContent = extension.version;
85 102
86 var disableReason = node.querySelector('.extension-disable-reason'); 103 var disableReason = node.querySelector('.extension-disable-reason');
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 297 }
281 298
282 this.appendChild(node); 299 this.appendChild(node);
283 } 300 }
284 }; 301 };
285 302
286 return { 303 return {
287 ExtensionsList: ExtensionsList 304 ExtensionsList: ExtensionsList
288 }; 305 };
289 }); 306 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/extensions/extensions.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698