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 * @unrestricted | 5 * @unrestricted |
6 */ | 6 */ |
7 UI.CommandMenu = class { | 7 UI.CommandMenu = class { |
8 constructor() { | 8 constructor() { |
9 this._commands = []; | 9 this._commands = []; |
10 this._loadCommands(); | 10 this._loadCommands(); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 var index = String.hashCode(command.category()) % UI.CommandMenuDelegate.Mat
erialPaletteColors.length; | 218 var index = String.hashCode(command.category()) % UI.CommandMenuDelegate.Mat
erialPaletteColors.length; |
219 tagElement.style.backgroundColor = UI.CommandMenuDelegate.MaterialPaletteCol
ors[index]; | 219 tagElement.style.backgroundColor = UI.CommandMenuDelegate.MaterialPaletteCol
ors[index]; |
220 tagElement.textContent = command.category(); | 220 tagElement.textContent = command.category(); |
221 titleElement.createTextChild(command.title()); | 221 titleElement.createTextChild(command.title()); |
222 this.highlightRanges(titleElement, query); | 222 this.highlightRanges(titleElement, query); |
223 subtitleElement.textContent = command.shortcut(); | 223 subtitleElement.textContent = command.shortcut(); |
224 } | 224 } |
225 | 225 |
226 /** | 226 /** |
227 * @override | 227 * @override |
228 * @param {number} itemIndex | 228 * @param {?number} itemIndex |
229 * @param {string} promptValue | 229 * @param {string} promptValue |
230 */ | 230 */ |
231 selectItem(itemIndex, promptValue) { | 231 selectItem(itemIndex, promptValue) { |
| 232 if (itemIndex === null) |
| 233 return; |
232 this._commands[itemIndex].execute(); | 234 this._commands[itemIndex].execute(); |
233 } | 235 } |
234 | 236 |
235 /** | 237 /** |
236 * @override | 238 * @override |
237 * @return {boolean} | 239 * @return {boolean} |
238 */ | 240 */ |
239 caseSensitive() { | 241 caseSensitive() { |
240 return false; | 242 return false; |
241 } | 243 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 * @param {!UI.Context} context | 331 * @param {!UI.Context} context |
330 * @param {string} actionId | 332 * @param {string} actionId |
331 * @return {boolean} | 333 * @return {boolean} |
332 */ | 334 */ |
333 handleAction(context, actionId) { | 335 handleAction(context, actionId) { |
334 new UI.FilteredListWidget(new UI.CommandMenuDelegate()).showAsDialog(); | 336 new UI.FilteredListWidget(new UI.CommandMenuDelegate()).showAsDialog(); |
335 InspectorFrontendHost.bringToFront(); | 337 InspectorFrontendHost.bringToFront(); |
336 return true; | 338 return true; |
337 } | 339 } |
338 }; | 340 }; |
OLD | NEW |