|
OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 cr.define('options', function() { | |
6 'use strict'; | |
7 | |
8 /** | |
9 * Creates a new list of extension commands. | |
10 * @param {Object=} opt_propertyBag Optional properties. | |
11 * @constructor | |
12 * @extends {cr.ui.div} | |
13 */ | |
14 var ExtensionCommandList = cr.ui.define('div'); | |
15 | |
16 ExtensionCommandList.prototype = { | |
17 __proto__: HTMLDivElement.prototype, | |
18 | |
19 /** @inheritDoc */ | |
20 decorate: function() { | |
21 this.textContent = ''; | |
22 | |
23 // Iterate over the extension data and add each item to the list. | |
24 this.data_.commands.forEach(this.createExtensionNode_.bind(this)); | |
25 }, | |
26 | |
27 /** | |
28 * Synthesizes and initializes an HTML element for the extension command | |
29 * metadata given in |extension|. | |
30 * @param {Object} extension A dictionary of extension metadata. | |
31 * @private | |
32 */ | |
33 createExtensionNode_: function(extension) { | |
Evan Stade
2012/05/18 21:08:26
createNodeForExtension is more apt
Finnur
2012/05/18 22:02:04
Done.
| |
34 var template = $('template-collection-extension-commands').querySelector( | |
35 '.extension-command-list-extension-item-wrapper'); | |
Evan Stade
2012/05/18 21:08:26
too much indent
Finnur
2012/05/18 22:02:04
Wait... Continuations from previous lines have alw
Evan Stade
2012/05/18 22:14:23
oh, I guess this one is actually 4
| |
36 var node = template.cloneNode(true); | |
37 node.id = extension.id; | |
Evan Stade
2012/05/18 21:08:26
if this is the same as the extension id, I think i
Finnur
2012/05/18 22:02:04
This isn't used at the moment so I just removed it
| |
38 | |
39 var title = node.querySelector('.extension-title'); | |
40 title.textContent = extension.name; | |
41 | |
42 this.appendChild(node); | |
43 | |
44 // Iterate over the commands data within the extension and add each item | |
45 // to the list. | |
46 extension.commands.forEach(this.createCommandNode_.bind(this)); | |
47 }, | |
48 | |
49 /** | |
50 * Synthesizes and initializes an HTML element for the extension command | |
51 * metadata given in |command|. | |
52 * @param {Object} command A dictionary of extension command metadata. | |
53 * @private | |
54 */ | |
55 createCommandNode_: function(command) { | |
56 var template = $('template-collection-extension-commands').querySelector( | |
57 '.extension-command-list-command-item-wrapper'); | |
Evan Stade
2012/05/18 21:08:26
too much indent.
Finnur
2012/05/18 22:02:04
Same question here.
On 2012/05/18 21:08:26, Evan
Evan Stade
2012/05/18 22:14:23
yea but this is 6 not 4
| |
58 var node = template.cloneNode(true); | |
59 | |
60 var description = node.querySelector('.command-description'); | |
61 description.textContent = command.description; | |
62 | |
63 var shortcut = node.querySelector('.command-shortcut'); | |
64 if (!command.active) { | |
65 shortcut.textContent = | |
66 loadTimeData.getString('extensionCommandsInactive'); | |
67 shortcut.classList.add('inactive-keybinding'); | |
68 } else { | |
69 shortcut.textContent = command.keybinding; | |
70 } | |
71 | |
72 this.appendChild(node); | |
73 }, | |
74 }; | |
75 | |
76 return { | |
77 ExtensionCommandList: ExtensionCommandList | |
78 }; | |
79 }); | |
OLD | NEW |