Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui_lazy/CommandMenu.js

Issue 2440953003: DevTools: use semicolons after each statement. (Closed)
Patch Set: rebaseline Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /** 5 /**
6 * @constructor 6 * @constructor
7 */ 7 */
8 WebInspector.CommandMenu = function() 8 WebInspector.CommandMenu = function()
9 { 9 {
10 this._commands = []; 10 this._commands = [];
11 this._loadCommands(); 11 this._loadCommands();
12 } 12 };
13 13
14 WebInspector.CommandMenu.prototype = { 14 WebInspector.CommandMenu.prototype = {
15 _loadCommands: function() 15 _loadCommands: function()
16 { 16 {
17 // Populate panels. 17 // Populate panels.
18 var panelExtensions = self.runtime.extensions(WebInspector.Panel); 18 var panelExtensions = self.runtime.extensions(WebInspector.Panel);
19 for (var extension of panelExtensions) 19 for (var extension of panelExtensions)
20 this._commands.push(WebInspector.CommandMenu.createRevealPanelComman d(extension)); 20 this._commands.push(WebInspector.CommandMenu.createRevealPanelComman d(extension));
21 21
22 // Populate drawers. 22 // Populate drawers.
(...skipping 15 matching lines...) Expand all
38 } 38 }
39 }, 39 },
40 40
41 /** 41 /**
42 * @return {!Array.<!WebInspector.CommandMenu.Command>} 42 * @return {!Array.<!WebInspector.CommandMenu.Command>}
43 */ 43 */
44 commands: function() 44 commands: function()
45 { 45 {
46 return this._commands; 46 return this._commands;
47 } 47 }
48 } 48 };
49 49
50 /** 50 /**
51 * @constructor 51 * @constructor
52 * @extends {WebInspector.FilteredListWidget.Delegate} 52 * @extends {WebInspector.FilteredListWidget.Delegate}
53 */ 53 */
54 WebInspector.CommandMenuDelegate = function() 54 WebInspector.CommandMenuDelegate = function()
55 { 55 {
56 WebInspector.FilteredListWidget.Delegate.call(this, []); 56 WebInspector.FilteredListWidget.Delegate.call(this, []);
57 this._commands = []; 57 this._commands = [];
58 this._appendAvailableCommands(); 58 this._appendAvailableCommands();
59 } 59 };
60 60
61 WebInspector.CommandMenuDelegate.MaterialPaletteColors = ["#F44336", "#E91E63", "#9C27B0", "#673AB7", "#3F51B5", "#03A9F4", "#00BCD4", "#009688", "#4CAF50", "#8 BC34A", "#CDDC39", "#FFC107", "#FF9800", "#FF5722", "#795548", "#9E9E9E", "#607D 8B"]; 61 WebInspector.CommandMenuDelegate.MaterialPaletteColors = ["#F44336", "#E91E63", "#9C27B0", "#673AB7", "#3F51B5", "#03A9F4", "#00BCD4", "#009688", "#4CAF50", "#8 BC34A", "#CDDC39", "#FFC107", "#FF9800", "#FF5722", "#795548", "#9E9E9E", "#607D 8B"];
62 62
63 WebInspector.CommandMenuDelegate.prototype = { 63 WebInspector.CommandMenuDelegate.prototype = {
64 _appendAvailableCommands: function() 64 _appendAvailableCommands: function()
65 { 65 {
66 var allCommands = WebInspector.commandMenu.commands(); 66 var allCommands = WebInspector.commandMenu.commands();
67 67
68 // Populate whitelisted actions. 68 // Populate whitelisted actions.
69 var actions = WebInspector.actionRegistry.availableActions(); 69 var actions = WebInspector.actionRegistry.availableActions();
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 /** 178 /**
179 * @override 179 * @override
180 * @return {boolean} 180 * @return {boolean}
181 */ 181 */
182 renderMonospace: function() 182 renderMonospace: function()
183 { 183 {
184 return false; 184 return false;
185 }, 185 },
186 186
187 __proto__: WebInspector.FilteredListWidget.Delegate.prototype 187 __proto__: WebInspector.FilteredListWidget.Delegate.prototype
188 } 188 };
189 189
190 /** 190 /**
191 * @constructor 191 * @constructor
192 * @param {string} category 192 * @param {string} category
193 * @param {string} title 193 * @param {string} title
194 * @param {string} key 194 * @param {string} key
195 * @param {string} shortcut 195 * @param {string} shortcut
196 * @param {function()} executeHandler 196 * @param {function()} executeHandler
197 * @param {function()=} availableHandler 197 * @param {function()=} availableHandler
198 */ 198 */
199 WebInspector.CommandMenu.Command = function(category, title, key, shortcut, exec uteHandler, availableHandler) 199 WebInspector.CommandMenu.Command = function(category, title, key, shortcut, exec uteHandler, availableHandler)
200 { 200 {
201 this._category = category; 201 this._category = category;
202 this._title = title; 202 this._title = title;
203 this._key = category + "\0" + title + "\0" + key; 203 this._key = category + "\0" + title + "\0" + key;
204 this._shortcut = shortcut; 204 this._shortcut = shortcut;
205 this._executeHandler = executeHandler; 205 this._executeHandler = executeHandler;
206 this._availableHandler = availableHandler; 206 this._availableHandler = availableHandler;
207 } 207 };
208 208
209 WebInspector.CommandMenu.Command.prototype = { 209 WebInspector.CommandMenu.Command.prototype = {
210 /** 210 /**
211 * @return {string} 211 * @return {string}
212 */ 212 */
213 category: function() 213 category: function()
214 { 214 {
215 return this._category; 215 return this._category;
216 }, 216 },
217 217
(...skipping 26 matching lines...) Expand all
244 */ 244 */
245 available: function() 245 available: function()
246 { 246 {
247 return this._availableHandler ? this._availableHandler() : true; 247 return this._availableHandler ? this._availableHandler() : true;
248 }, 248 },
249 249
250 execute: function() 250 execute: function()
251 { 251 {
252 this._executeHandler(); 252 this._executeHandler();
253 } 253 }
254 } 254 };
255 255
256 /** 256 /**
257 * @param {string} category 257 * @param {string} category
258 * @param {string} keys 258 * @param {string} keys
259 * @param {string} title 259 * @param {string} title
260 * @param {string} shortcut 260 * @param {string} shortcut
261 * @param {function()} executeHandler 261 * @param {function()} executeHandler
262 * @param {function()=} availableHandler 262 * @param {function()=} availableHandler
263 * @return {!WebInspector.CommandMenu.Command} 263 * @return {!WebInspector.CommandMenu.Command}
264 */ 264 */
265 WebInspector.CommandMenu.createCommand = function(category, keys, title, shortcu t, executeHandler, availableHandler) 265 WebInspector.CommandMenu.createCommand = function(category, keys, title, shortcu t, executeHandler, availableHandler)
266 { 266 {
267 // Separate keys by null character, to prevent fuzzy matching from matching across them. 267 // Separate keys by null character, to prevent fuzzy matching from matching across them.
268 var key = keys.replace(/,/g, "\0"); 268 var key = keys.replace(/,/g, "\0");
269 return new WebInspector.CommandMenu.Command(category, title, key, shortcut, executeHandler, availableHandler); 269 return new WebInspector.CommandMenu.Command(category, title, key, shortcut, executeHandler, availableHandler);
270 } 270 };
271 271
272 /** 272 /**
273 * @param {!Runtime.Extension} extension 273 * @param {!Runtime.Extension} extension
274 * @param {string} title 274 * @param {string} title
275 * @param {V} value 275 * @param {V} value
276 * @return {!WebInspector.CommandMenu.Command} 276 * @return {!WebInspector.CommandMenu.Command}
277 * @template V 277 * @template V
278 */ 278 */
279 WebInspector.CommandMenu.createSettingCommand = function(extension, title, value ) 279 WebInspector.CommandMenu.createSettingCommand = function(extension, title, value )
280 { 280 {
281 var category = extension.descriptor()["category"] || ""; 281 var category = extension.descriptor()["category"] || "";
282 var tags = extension.descriptor()["tags"] || ""; 282 var tags = extension.descriptor()["tags"] || "";
283 var setting = WebInspector.settings.moduleSetting(extension.descriptor()["se ttingName"]); 283 var setting = WebInspector.settings.moduleSetting(extension.descriptor()["se ttingName"]);
284 return WebInspector.CommandMenu.createCommand(category, tags, title, "", set ting.set.bind(setting, value), availableHandler); 284 return WebInspector.CommandMenu.createCommand(category, tags, title, "", set ting.set.bind(setting, value), availableHandler);
285 285
286 /** 286 /**
287 * @return {boolean} 287 * @return {boolean}
288 */ 288 */
289 function availableHandler() 289 function availableHandler()
290 { 290 {
291 return setting.get() !== value; 291 return setting.get() !== value;
292 } 292 }
293 } 293 };
294 294
295 /** 295 /**
296 * @param {!WebInspector.Action} action 296 * @param {!WebInspector.Action} action
297 * @return {!WebInspector.CommandMenu.Command} 297 * @return {!WebInspector.CommandMenu.Command}
298 */ 298 */
299 WebInspector.CommandMenu.createActionCommand = function(action) 299 WebInspector.CommandMenu.createActionCommand = function(action)
300 { 300 {
301 var shortcut = WebInspector.shortcutRegistry.shortcutTitleForAction(action.i d()) || ""; 301 var shortcut = WebInspector.shortcutRegistry.shortcutTitleForAction(action.i d()) || "";
302 return WebInspector.CommandMenu.createCommand(action.category(), action.tags (), action.title(), shortcut, action.execute.bind(action)); 302 return WebInspector.CommandMenu.createCommand(action.category(), action.tags (), action.title(), shortcut, action.execute.bind(action));
303 } 303 };
304 304
305 /** 305 /**
306 * @param {!Runtime.Extension} extension 306 * @param {!Runtime.Extension} extension
307 * @return {!WebInspector.CommandMenu.Command} 307 * @return {!WebInspector.CommandMenu.Command}
308 */ 308 */
309 WebInspector.CommandMenu.createRevealPanelCommand = function(extension) 309 WebInspector.CommandMenu.createRevealPanelCommand = function(extension)
310 { 310 {
311 var panelName = extension.descriptor()["name"]; 311 var panelName = extension.descriptor()["name"];
312 var tags = extension.descriptor()["tags"] || ""; 312 var tags = extension.descriptor()["tags"] || "";
313 return WebInspector.CommandMenu.createCommand(WebInspector.UIString("Panel") , tags, WebInspector.UIString("Show %s", extension.title()), "", executeHandler, availableHandler); 313 return WebInspector.CommandMenu.createCommand(WebInspector.UIString("Panel") , tags, WebInspector.UIString("Show %s", extension.title()), "", executeHandler, availableHandler);
314 314
315 /** 315 /**
316 * @return {boolean} 316 * @return {boolean}
317 */ 317 */
318 function availableHandler() 318 function availableHandler()
319 { 319 {
320 return true; 320 return true;
321 } 321 }
322 322
323 function executeHandler() 323 function executeHandler()
324 { 324 {
325 WebInspector.viewManager.showView(panelName); 325 WebInspector.viewManager.showView(panelName);
326 } 326 }
327 } 327 };
328 328
329 /** 329 /**
330 * @param {!Runtime.Extension} extension 330 * @param {!Runtime.Extension} extension
331 * @return {!WebInspector.CommandMenu.Command} 331 * @return {!WebInspector.CommandMenu.Command}
332 */ 332 */
333 WebInspector.CommandMenu.createRevealDrawerCommand = function(extension) 333 WebInspector.CommandMenu.createRevealDrawerCommand = function(extension)
334 { 334 {
335 var drawerId = extension.descriptor()["id"]; 335 var drawerId = extension.descriptor()["id"];
336 var executeHandler = WebInspector.viewManager.showView.bind(WebInspector.vie wManager, drawerId); 336 var executeHandler = WebInspector.viewManager.showView.bind(WebInspector.vie wManager, drawerId);
337 var tags = extension.descriptor()["tags"] || ""; 337 var tags = extension.descriptor()["tags"] || "";
338 return WebInspector.CommandMenu.createCommand(WebInspector.UIString("Drawer" ), tags, WebInspector.UIString("Show %s", extension.title()), "", executeHandler ); 338 return WebInspector.CommandMenu.createCommand(WebInspector.UIString("Drawer" ), tags, WebInspector.UIString("Show %s", extension.title()), "", executeHandler );
339 } 339 };
340 340
341 /** @type {!WebInspector.CommandMenu} */ 341 /** @type {!WebInspector.CommandMenu} */
342 WebInspector.commandMenu = new WebInspector.CommandMenu(); 342 WebInspector.commandMenu = new WebInspector.CommandMenu();
343 343
344 /** 344 /**
345 * @constructor 345 * @constructor
346 * @implements {WebInspector.ActionDelegate} 346 * @implements {WebInspector.ActionDelegate}
347 */ 347 */
348 WebInspector.CommandMenu.ShowActionDelegate = function() 348 WebInspector.CommandMenu.ShowActionDelegate = function()
349 { 349 {
350 } 350 };
351 351
352 WebInspector.CommandMenu.ShowActionDelegate.prototype = { 352 WebInspector.CommandMenu.ShowActionDelegate.prototype = {
353 /** 353 /**
354 * @override 354 * @override
355 * @param {!WebInspector.Context} context 355 * @param {!WebInspector.Context} context
356 * @param {string} actionId 356 * @param {string} actionId
357 * @return {boolean} 357 * @return {boolean}
358 */ 358 */
359 handleAction: function(context, actionId) 359 handleAction: function(context, actionId)
360 { 360 {
361 new WebInspector.FilteredListWidget(new WebInspector.CommandMenuDelegate ()).showAsDialog(); 361 new WebInspector.FilteredListWidget(new WebInspector.CommandMenuDelegate ()).showAsDialog();
362 InspectorFrontendHost.bringToFront(); 362 InspectorFrontendHost.bringToFront();
363 return true; 363 return true;
364 } 364 }
365 } 365 };
366 366
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698