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 importScript("WikiParser.js"); | 5 importScript("WikiParser.js"); |
6 importScript("JSArticle.js"); | 6 importScript("JSArticle.js"); |
7 importScript("CSSArticle.js"); | 7 importScript("CSSArticle.js"); |
8 importScript("DocumentationURLProvider.js"); | 8 importScript("DocumentationURLProvider.js"); |
| 9 |
| 10 /** |
| 11 * @constructor |
| 12 * @extends {WebInspector.VBox} |
| 13 */ |
| 14 WebInspector.DocumentationView = function() |
| 15 { |
| 16 WebInspector.VBox.call(this); |
| 17 } |
| 18 |
| 19 /** |
| 20 * @param {string} searchTerm |
| 21 */ |
| 22 WebInspector.DocumentationView.showSearchTerm = function(searchTerm) |
| 23 { |
| 24 if (!WebInspector.DocumentationView._view) |
| 25 WebInspector.DocumentationView._view = new WebInspector.DocumentationVie
w(); |
| 26 var view = WebInspector.DocumentationView._view; |
| 27 WebInspector.inspectorView.showCloseableViewInDrawer("documentation", WebIns
pector.UIString("Documentation"), view); |
| 28 } |
| 29 |
| 30 WebInspector.DocumentationView.prototype = { |
| 31 __proto__: WebInspector.VBox.prototype |
| 32 } |
| 33 |
| 34 /** |
| 35 * @constructor |
| 36 * @implements {WebInspector.ContextMenu.Provider} |
| 37 */ |
| 38 WebInspector.DocumentationView.ContextMenuProvider = function() |
| 39 { |
| 40 } |
| 41 |
| 42 WebInspector.DocumentationView.ContextMenuProvider.prototype = { |
| 43 /** |
| 44 * @param {!Event} event |
| 45 * @param {!WebInspector.ContextMenu} contextMenu |
| 46 * @param {!Object} target |
| 47 */ |
| 48 appendApplicableItems: function(event, contextMenu, target) |
| 49 { |
| 50 if (!(target instanceof WebInspector.CodeMirrorTextEditor)) |
| 51 return; |
| 52 var textEditor = /** @type {!WebInspector.CodeMirrorTextEditor} */ (targ
et); |
| 53 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe
nuTitles() ? "Show documentation" : "Show Documentation"), this._showDocumentati
on.bind(this, textEditor)); |
| 54 }, |
| 55 |
| 56 /** |
| 57 * @param {!WebInspector.CodeMirrorTextEditor} textEditor |
| 58 */ |
| 59 _showDocumentation: function(textEditor) |
| 60 { |
| 61 var selection = textEditor.selection(); |
| 62 if (!selection || selection.isEmpty()) |
| 63 return; |
| 64 var selectedText = textEditor.copyRange(selection); |
| 65 WebInspector.DocumentationView.showSearchTerm(selectedText); |
| 66 } |
| 67 } |
OLD | NEW |