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

Side by Side Diff: Source/devtools/front_end/documentation/DocumentationView.js

Issue 466743002: DevTools: Show doc context menu items for matching methods on all objects (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Submenu is not created in case of single property variant Created 6 years, 4 months 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
« no previous file with comments | « Source/devtools/front_end/documentation/DocumentationURLProvider.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 * @extends {WebInspector.VBox} 7 * @extends {WebInspector.VBox}
8 */ 8 */
9 WebInspector.DocumentationView = function() 9 WebInspector.DocumentationView = function()
10 { 10 {
11 WebInspector.VBox.call(this); 11 WebInspector.VBox.call(this);
12 } 12 }
13 13
14 /** 14 /**
15 * @param {string} searchTerm 15 * @param {string} url
16 */ 16 */
17 WebInspector.DocumentationView.showSearchTerm = function(searchTerm) 17 WebInspector.DocumentationView.showDocumentationURL = function(url)
18 { 18 {
19 if (!WebInspector.DocumentationView._view) 19 if (!WebInspector.DocumentationView._view)
20 WebInspector.DocumentationView._view = new WebInspector.DocumentationVie w(); 20 WebInspector.DocumentationView._view = new WebInspector.DocumentationVie w();
21 var view = WebInspector.DocumentationView._view; 21 var view = WebInspector.DocumentationView._view;
22 WebInspector.inspectorView.showCloseableViewInDrawer("documentation", WebIns pector.UIString("Documentation"), view); 22 WebInspector.inspectorView.showCloseableViewInDrawer("documentation", WebIns pector.UIString("Documentation"), view);
23 } 23 }
24 24
25 WebInspector.DocumentationView.prototype = { 25 WebInspector.DocumentationView.prototype = {
26 __proto__: WebInspector.VBox.prototype 26 __proto__: WebInspector.VBox.prototype
27 } 27 }
(...skipping 15 matching lines...) Expand all
43 appendApplicableItems: function(event, contextMenu, target) 43 appendApplicableItems: function(event, contextMenu, target)
44 { 44 {
45 if (!(target instanceof WebInspector.CodeMirrorTextEditor)) 45 if (!(target instanceof WebInspector.CodeMirrorTextEditor))
46 return; 46 return;
47 var textEditor = /** @type {!WebInspector.CodeMirrorTextEditor} */ (targ et); 47 var textEditor = /** @type {!WebInspector.CodeMirrorTextEditor} */ (targ et);
48 var selection = textEditor.selection(); 48 var selection = textEditor.selection();
49 if (!selection || selection.isEmpty() || selection.startLine !== selecti on.endLine) 49 if (!selection || selection.isEmpty() || selection.startLine !== selecti on.endLine)
50 return; 50 return;
51 var selectedText = textEditor.copyRange(selection); 51 var selectedText = textEditor.copyRange(selection);
52 var urlProvider = new WebInspector.DocumentationURLProvider(); 52 var urlProvider = new WebInspector.DocumentationURLProvider();
53 var itemPath = urlProvider.itemPath(selectedText); 53 var possibleProperties = urlProvider.itemDescriptors(selectedText);
54 if (!itemPath) 54 if (!possibleProperties.length)
55 return; 55 return;
56 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Show documentation" : "Show Documentation"), WebInspector.Document ationView.showSearchTerm.bind(null, selectedText)); 56 if (possibleProperties.length === 1) {
57 var formatString = WebInspector.useLowerCaseMenuTitles() ? "Show doc umentation for %s.%s" : "Show Documentation for %s.%s";
58 contextMenu.appendItem(String.sprintf(formatString, possibleProperti es[0].name, selectedText), WebInspector.DocumentationView.showDocumentationURL.b ind(null, possibleProperties[0].url));
apavlov 2014/08/12 16:12:09 Since we are dealing with localizable strings ("Sh
59 return;
60 }
61 var subMenuItem = contextMenu.appendSubMenuItem(WebInspector.UIString(We bInspector.useLowerCaseMenuTitles() ? "Show documentation for..." : "Show Docume ntation for..."));
62 for (var i = 0; i < possibleProperties.length; ++i)
63 subMenuItem.appendItem(String.sprintf("%s.%s", possibleProperties[i] .name, selectedText), WebInspector.DocumentationView.showDocumentationURL.bind(n ull, possibleProperties[i].url));
57 } 64 }
58 } 65 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/documentation/DocumentationURLProvider.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698