| 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.View} | 7 * @extends {WebInspector.View} |
| 8 */ | 8 */ |
| 9 WebInspector.DocumentationView = function() | 9 WebInspector.DocumentationView = function() |
| 10 { | 10 { |
| 11 WebInspector.View.call(this); | 11 WebInspector.View.call(this); |
| 12 this.element.classList.add("documentation-view"); | 12 this.element.classList.add("documentation-view"); |
| 13 this.registerRequiredCSS("documentationView.css"); | 13 this.registerRequiredCSS("documentationView.css"); |
| 14 } | 14 } |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * @param {string} url | 17 * @param {string} url |
| 18 * @param {string} searchItem | 18 * @param {string} searchItem |
| 19 */ | 19 */ |
| 20 WebInspector.DocumentationView.showDocumentationURL = function(url, searchItem) | 20 WebInspector.DocumentationView.showDocumentationURL = function(url, searchItem) |
| 21 { | 21 { |
| 22 if (!WebInspector.DocumentationView._view) | 22 if (!WebInspector.DocumentationView._view) |
| 23 WebInspector.DocumentationView._view = new WebInspector.DocumentationVie
w(); | 23 WebInspector.DocumentationView._view = new WebInspector.DocumentationVie
w(); |
| 24 var view = WebInspector.DocumentationView._view; | 24 var view = WebInspector.DocumentationView._view; |
| 25 WebInspector.inspectorView.showCloseableViewInDrawer("documentation", WebIns
pector.UIString("Documentation"), view); | 25 WebInspector.inspectorView.showCloseableViewInDrawer("documentation", WebIns
pector.UIString("Documentation"), view); |
| 26 view.showDocumentation(url, searchItem); | 26 view.showDocumentation(url, searchItem); |
| 27 } | 27 } |
| 28 | 28 |
| 29 WebInspector.DocumentationView._languageToMimeType = { |
| 30 "javascript": "text/javascript", |
| 31 "html": "text/html" |
| 32 }; |
| 33 |
| 29 WebInspector.DocumentationView.prototype = { | 34 WebInspector.DocumentationView.prototype = { |
| 30 /** | 35 /** |
| 31 * @param {string} url | 36 * @param {string} url |
| 32 * @param {string} searchItem | 37 * @param {string} searchItem |
| 33 */ | 38 */ |
| 34 showDocumentation: function(url, searchItem) | 39 showDocumentation: function(url, searchItem) |
| 35 { | 40 { |
| 36 if (!url) { | 41 if (!url) { |
| 37 this._createEmptyPage(); | 42 this._createEmptyPage(); |
| 38 return; | 43 return; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 var exampleDescription = example.createChild("div", "documentation-e
xample-description-section"); | 211 var exampleDescription = example.createChild("div", "documentation-e
xample-description-section"); |
| 207 if (examples[i].liveUrl) { | 212 if (examples[i].liveUrl) { |
| 208 var liveUrl = exampleDescription.createChild("a", "documentation
-example-link"); | 213 var liveUrl = exampleDescription.createChild("a", "documentation
-example-link"); |
| 209 liveUrl.href = examples[i].liveUrl; | 214 liveUrl.href = examples[i].liveUrl; |
| 210 liveUrl.textContent = WebInspector.UIString("Example"); | 215 liveUrl.textContent = WebInspector.UIString("Example"); |
| 211 } | 216 } |
| 212 exampleDescription.appendChild(this._renderBlock(examples[i].descrip
tion)); | 217 exampleDescription.appendChild(this._renderBlock(examples[i].descrip
tion)); |
| 213 var code = example.createChild("div", "documentation-example-code"); | 218 var code = example.createChild("div", "documentation-example-code"); |
| 214 code.classList.add("source-code"); | 219 code.classList.add("source-code"); |
| 215 code.textContent = examples[i].code; | 220 code.textContent = examples[i].code; |
| 221 if (!examples[i].language) |
| 222 continue; |
| 223 var syntaxHighlighter = new WebInspector.DOMSyntaxHighlighter(WebIns
pector.DocumentationView._languageToMimeType[examples[i].language.toLowerCase()]
, true); |
| 224 syntaxHighlighter.syntaxHighlightNode(code); |
| 216 } | 225 } |
| 217 }, | 226 }, |
| 218 | 227 |
| 219 /** | 228 /** |
| 220 * @param {!WebInspector.WikiParser.ArticleElement} article | 229 * @param {!WebInspector.WikiParser.ArticleElement} article |
| 221 * @return {!Element} | 230 * @return {!Element} |
| 222 */ | 231 */ |
| 223 _renderBlock: function(article) | 232 _renderBlock: function(article) |
| 224 { | 233 { |
| 225 var element; | 234 var element; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 function computeDescriptors(column) | 337 function computeDescriptors(column) |
| 329 { | 338 { |
| 330 var token = textEditor.tokenAtTextPosition(textSelection.startLine,
column); | 339 var token = textEditor.tokenAtTextPosition(textSelection.startLine,
column); |
| 331 if (!token) | 340 if (!token) |
| 332 return []; | 341 return []; |
| 333 var tokenText = textEditor.line(textSelection.startLine).substring(t
oken.startColumn, token.endColumn); | 342 var tokenText = textEditor.line(textSelection.startLine).substring(t
oken.startColumn, token.endColumn); |
| 334 return urlProvider.itemDescriptors(tokenText); | 343 return urlProvider.itemDescriptors(tokenText); |
| 335 } | 344 } |
| 336 } | 345 } |
| 337 } | 346 } |
| OLD | NEW |