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 QuickOpen.CommandMenu = class { | 7 QuickOpen.CommandMenu = class { |
8 constructor() { | 8 constructor() { |
9 this._commands = []; | 9 this._commands = []; |
10 this._loadCommands(); | 10 this._loadCommands(); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 * @param {!Element} subtitleElement | 213 * @param {!Element} subtitleElement |
214 */ | 214 */ |
215 renderItem(itemIndex, query, titleElement, subtitleElement) { | 215 renderItem(itemIndex, query, titleElement, subtitleElement) { |
216 var command = this._commands[itemIndex]; | 216 var command = this._commands[itemIndex]; |
217 titleElement.removeChildren(); | 217 titleElement.removeChildren(); |
218 var tagElement = titleElement.createChild('span', 'tag'); | 218 var tagElement = titleElement.createChild('span', 'tag'); |
219 var index = String.hashCode(command.category()) % QuickOpen.CommandMenuDeleg
ate.MaterialPaletteColors.length; | 219 var index = String.hashCode(command.category()) % QuickOpen.CommandMenuDeleg
ate.MaterialPaletteColors.length; |
220 tagElement.style.backgroundColor = QuickOpen.CommandMenuDelegate.MaterialPal
etteColors[index]; | 220 tagElement.style.backgroundColor = QuickOpen.CommandMenuDelegate.MaterialPal
etteColors[index]; |
221 tagElement.textContent = command.category(); | 221 tagElement.textContent = command.category(); |
222 titleElement.createTextChild(command.title()); | 222 titleElement.createTextChild(command.title()); |
223 this.highlightRanges(titleElement, query); | 223 QuickOpen.FilteredListWidget.highlightRanges(titleElement, query, true); |
224 subtitleElement.textContent = command.shortcut(); | 224 subtitleElement.textContent = command.shortcut(); |
225 } | 225 } |
226 | 226 |
227 /** | 227 /** |
228 * @override | 228 * @override |
229 * @param {?number} itemIndex | 229 * @param {?number} itemIndex |
230 * @param {string} promptValue | 230 * @param {string} promptValue |
231 */ | 231 */ |
232 selectItem(itemIndex, promptValue) { | 232 selectItem(itemIndex, promptValue) { |
233 if (itemIndex === null) | 233 if (itemIndex === null) |
234 return; | 234 return; |
235 this._commands[itemIndex].execute(); | 235 this._commands[itemIndex].execute(); |
236 } | 236 } |
237 | 237 |
238 /** | 238 /** |
239 * @override | 239 * @override |
240 * @return {boolean} | 240 * @return {boolean} |
241 */ | 241 */ |
242 caseSensitive() { | |
243 return false; | |
244 } | |
245 | |
246 /** | |
247 * @override | |
248 * @return {boolean} | |
249 */ | |
250 renderMonospace() { | 242 renderMonospace() { |
251 return false; | 243 return false; |
252 } | 244 } |
253 }; | 245 }; |
254 | 246 |
255 QuickOpen.CommandMenuDelegate.MaterialPaletteColors = [ | 247 QuickOpen.CommandMenuDelegate.MaterialPaletteColors = [ |
256 '#F44336', '#E91E63', '#9C27B0', '#673AB7', '#3F51B5', '#03A9F4', '#00BCD4', '
#009688', '#4CAF50', '#8BC34A', | 248 '#F44336', '#E91E63', '#9C27B0', '#673AB7', '#3F51B5', '#03A9F4', '#00BCD4', '
#009688', '#4CAF50', '#8BC34A', |
257 '#CDDC39', '#FFC107', '#FF9800', '#FF5722', '#795548', '#9E9E9E', '#607D8B' | 249 '#CDDC39', '#FFC107', '#FF9800', '#FF5722', '#795548', '#9E9E9E', '#607D8B' |
258 ]; | 250 ]; |
259 | 251 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 * @param {!UI.Context} context | 324 * @param {!UI.Context} context |
333 * @param {string} actionId | 325 * @param {string} actionId |
334 * @return {boolean} | 326 * @return {boolean} |
335 */ | 327 */ |
336 handleAction(context, actionId) { | 328 handleAction(context, actionId) { |
337 new QuickOpen.FilteredListWidget(new QuickOpen.CommandMenuDelegate()).showAs
Dialog(); | 329 new QuickOpen.FilteredListWidget(new QuickOpen.CommandMenuDelegate()).showAs
Dialog(); |
338 InspectorFrontendHost.bringToFront(); | 330 InspectorFrontendHost.bringToFront(); |
339 return true; | 331 return true; |
340 } | 332 } |
341 }; | 333 }; |
OLD | NEW |