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.createNodeForExtension_.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 createNodeForExtension_: function(extension) { |
| 34 var template = $('template-collection-extension-commands').querySelector( |
| 35 '.extension-command-list-extension-item-wrapper'); |
| 36 var node = template.cloneNode(true); |
| 37 |
| 38 var title = node.querySelector('.extension-title'); |
| 39 title.textContent = extension.name; |
| 40 |
| 41 this.appendChild(node); |
| 42 |
| 43 // Iterate over the commands data within the extension and add each item |
| 44 // to the list. |
| 45 extension.commands.forEach(this.createNodeForCommand_.bind(this)); |
| 46 }, |
| 47 |
| 48 /** |
| 49 * Synthesizes and initializes an HTML element for the extension command |
| 50 * metadata given in |command|. |
| 51 * @param {Object} command A dictionary of extension command metadata. |
| 52 * @private |
| 53 */ |
| 54 createNodeForCommand_: function(command) { |
| 55 var template = $('template-collection-extension-commands').querySelector( |
| 56 '.extension-command-list-command-item-wrapper'); |
| 57 var node = template.cloneNode(true); |
| 58 |
| 59 var description = node.querySelector('.command-description'); |
| 60 description.textContent = command.description; |
| 61 |
| 62 var shortcut = node.querySelector('.command-shortcut'); |
| 63 if (!command.active) { |
| 64 shortcut.textContent = |
| 65 loadTimeData.getString('extensionCommandsInactive'); |
| 66 shortcut.classList.add('inactive-keybinding'); |
| 67 } else { |
| 68 shortcut.textContent = command.keybinding; |
| 69 } |
| 70 |
| 71 this.appendChild(node); |
| 72 }, |
| 73 }; |
| 74 |
| 75 return { |
| 76 ExtensionCommandList: ExtensionCommandList |
| 77 }; |
| 78 }); |
OLD | NEW |