OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // The UI to display and manage keyboard shortcuts set for extension commands. | 8 // The UI to display and manage keyboard shortcuts set for extension commands. |
9 var KeyboardShortcuts = Polymer({ | 9 var KeyboardShortcuts = Polymer({ |
10 is: 'extensions-keyboard-shortcuts', | 10 is: 'extensions-keyboard-shortcuts', |
11 | 11 |
12 behaviors: [Polymer.NeonAnimatableBehavior], | 12 behaviors: [Polymer.NeonAnimatableBehavior], |
13 | 13 |
14 properties: { | 14 properties: { |
15 /** @type {Array<!chrome.developerPrivate.ExtensionInfo>} */ | 15 /** @type {Array<!chrome.developerPrivate.ExtensionInfo>} */ |
16 items: Array, | 16 items: Array, |
| 17 |
| 18 /** |
| 19 * Proxying the enum to be used easily by the html template. |
| 20 * @private |
| 21 */ |
| 22 CommandScope_: { |
| 23 type: Object, |
| 24 value: chrome.developerPrivate.CommandScope |
| 25 }, |
17 }, | 26 }, |
18 | 27 |
19 ready: function() { | 28 ready: function() { |
20 /** @type {!extensions.AnimationHelper} */ | 29 /** @type {!extensions.AnimationHelper} */ |
21 this.animationHelper = new extensions.AnimationHelper(this, this.$.main); | 30 this.animationHelper = new extensions.AnimationHelper(this, this.$.main); |
22 this.animationHelper.setEntryAnimations([extensions.Animation.FADE_IN]); | 31 this.animationHelper.setEntryAnimations([extensions.Animation.FADE_IN]); |
23 this.animationHelper.setExitAnimations([extensions.Animation.SCALE_DOWN]); | 32 this.animationHelper.setExitAnimations([extensions.Animation.SCALE_DOWN]); |
24 this.sharedElements = {hero: this.$.main}; | 33 this.sharedElements = {hero: this.$.main}; |
25 }, | 34 }, |
26 | 35 |
(...skipping 23 matching lines...) Expand all Loading... |
50 * Determines whether to disable the dropdown menu for the command's scope. | 59 * Determines whether to disable the dropdown menu for the command's scope. |
51 * @param {!chrome.developerPrivate.Command} command | 60 * @param {!chrome.developerPrivate.Command} command |
52 * @return {boolean} | 61 * @return {boolean} |
53 * @private | 62 * @private |
54 */ | 63 */ |
55 computeScopeDisabled_: function(command) { | 64 computeScopeDisabled_: function(command) { |
56 return command.isExtensionAction || !command.isActive; | 65 return command.isExtensionAction || !command.isActive; |
57 }, | 66 }, |
58 | 67 |
59 /** | 68 /** |
60 * Returns the scope index in the dropdown menu for the command's scope. | 69 * This function exists to force trigger an update when CommandScope_ |
61 * @param {chrome.developerPrivate.Command} command | 70 * becomes available. |
62 * @return {number} | 71 * @param {string} scope |
63 * @private | 72 * @return {string} |
64 */ | 73 */ |
65 computeSelectedScope_: function(command) { | 74 triggerScopeChange_: function(scope) { |
66 // These numbers match the indexes in the dropdown menu in the html. | 75 return scope; |
67 switch (command.scope) { | |
68 case chrome.developerPrivate.CommandScope.CHROME: | |
69 return 0; | |
70 case chrome.developerPrivate.CommandScope.GLOBAL: | |
71 return 1; | |
72 } | |
73 assertNotReached(); | |
74 }, | 76 }, |
75 | 77 |
76 /** @private */ | 78 /** @private */ |
77 onCloseButtonClick_: function() { | 79 onCloseButtonClick_: function() { |
78 this.fire('close'); | 80 this.fire('close'); |
79 }, | 81 }, |
| 82 |
| 83 /** |
| 84 * @param {!{target: HTMLSelectElement, model: Object}} event |
| 85 * @private |
| 86 */ |
| 87 onScopeChanged_: function(event) { |
| 88 event.model.set('command.scope', event.target.value); |
| 89 }, |
80 }); | 90 }); |
81 | 91 |
82 return {KeyboardShortcuts: KeyboardShortcuts}; | 92 return {KeyboardShortcuts: KeyboardShortcuts}; |
83 }); | 93 }); |
OLD | NEW |