| OLD | NEW |
| 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 { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 possibleProperties = urlProvider.itemDescriptors(selectedText); | 53 var descriptors = urlProvider.itemDescriptors(selectedText); |
| 54 if (!possibleProperties.length) | 54 if (!descriptors.length) |
| 55 return; | 55 return; |
| 56 if (possibleProperties.length === 1) { | 56 if (descriptors.length === 1) { |
| 57 var formatString = WebInspector.useLowerCaseMenuTitles() ? "Show doc
umentation for %s.%s" : "Show Documentation for %s.%s"; | 57 var formatString = WebInspector.useLowerCaseMenuTitles() ? "Show doc
umentation for %s.%s" : "Show Documentation for %s.%s"; |
| 58 contextMenu.appendItem(WebInspector.UIString(formatString, possibleP
roperties[0].name, selectedText), WebInspector.DocumentationView.showDocumentati
onURL.bind(null, possibleProperties[0].url)); | 58 contextMenu.appendItem(WebInspector.UIString(formatString, descripto
rs[0].name, selectedText), WebInspector.DocumentationView.showDocumentationURL.b
ind(null, descriptors[0].url)); |
| 59 return; | 59 return; |
| 60 } | 60 } |
| 61 var subMenuItem = contextMenu.appendSubMenuItem(WebInspector.UIString(We
bInspector.useLowerCaseMenuTitles() ? "Show documentation for..." : "Show Docume
ntation for...")); | 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) | 62 for (var i = 0; i < descriptors.length; ++i) |
| 63 subMenuItem.appendItem(String.sprintf("%s.%s", possibleProperties[i]
.name, selectedText), WebInspector.DocumentationView.showDocumentationURL.bind(n
ull, possibleProperties[i].url)); | 63 subMenuItem.appendItem(String.sprintf("%s.%s", descriptors[i].name,
selectedText), WebInspector.DocumentationView.showDocumentationURL.bind(null, de
scriptors[i].url)); |
| 64 } | 64 } |
| 65 } | 65 } |
| OLD | NEW |