| 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 /** |
| 6 * @typedef {{afterHighlight: string, |
| 7 * beforeHighlight: string, |
| 8 * highlight: string, |
| 9 * title: string}} |
| 10 */ |
| 11 var ExtensionHighlight; |
| 12 |
| 5 cr.define('extensions', function() { | 13 cr.define('extensions', function() { |
| 6 'use strict'; | 14 'use strict'; |
| 7 | 15 |
| 8 /** | 16 /** |
| 9 * ExtensionCode is an element which displays code in a styled div, and is | 17 * ExtensionCode is an element which displays code in a styled div, and is |
| 10 * designed to highlight errors. | 18 * designed to highlight errors. |
| 19 * @constructor |
| 20 * @extends {HTMLDivElement} |
| 11 */ | 21 */ |
| 12 function ExtensionCode(div) { | 22 function ExtensionCode(div) { |
| 13 div.__proto__ = ExtensionCode.prototype; | 23 div.__proto__ = ExtensionCode.prototype; |
| 14 return div; | 24 return div; |
| 15 } | 25 } |
| 16 | 26 |
| 17 ExtensionCode.prototype = { | 27 ExtensionCode.prototype = { |
| 18 __proto__: HTMLDivElement.prototype, | 28 __proto__: HTMLDivElement.prototype, |
| 19 | 29 |
| 20 /** | 30 /** |
| 21 * Populate the content area of the code div with the given code. This will | 31 * Populate the content area of the code div with the given code. This will |
| 22 * highlight the erroneous section (if any). | 32 * highlight the erroneous section (if any). |
| 23 * @param {Object} code An object with four strings: beforeHighlight, | 33 * @param {ExtensionHighlight} code The 'highlight' strings represent the |
| 24 * afterHighlight, highlight, and the message. The 'highlight' strings | 34 * three portions of the file's content to display - the portion which |
| 25 * represent the three portions of the file's content to display - the | 35 * is most relevant and should be emphasized (highlight), and the parts |
| 26 * portion which is most relevant and should be emphasized (highlight), | 36 * both before and after this portion. The title is the error message, |
| 27 * and the parts both before and after this portion. The message is the | 37 * which will be the mouseover hint for the highlighted region. These |
| 28 * error message, which will be the mouseover hint for the highlighted | 38 * may be empty. |
| 29 * region. These may be empty. | |
| 30 * @param {string} emptyMessage The message to display if the code | 39 * @param {string} emptyMessage The message to display if the code |
| 31 * object is empty (e.g., 'could not load code'). | 40 * object is empty (e.g., 'could not load code'). |
| 32 */ | 41 */ |
| 33 populate: function(code, emptyMessage) { | 42 populate: function(code, emptyMessage) { |
| 34 // Clear any remnant content, so we don't have multiple code listed. | 43 // Clear any remnant content, so we don't have multiple code listed. |
| 35 this.clear(); | 44 this.clear(); |
| 36 | 45 |
| 37 var sourceDiv = document.createElement('div'); | 46 var sourceDiv = document.createElement('div'); |
| 38 sourceDiv.classList.add('extension-code-source'); | 47 sourceDiv.classList.add('extension-code-source'); |
| 39 this.appendChild(sourceDiv); | 48 this.appendChild(sourceDiv); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 if (errorSpan) | 109 if (errorSpan) |
| 101 this.scrollTop = errorSpan.offsetTop - this.clientHeight / 2; | 110 this.scrollTop = errorSpan.offsetTop - this.clientHeight / 2; |
| 102 } | 111 } |
| 103 }; | 112 }; |
| 104 | 113 |
| 105 // Export | 114 // Export |
| 106 return { | 115 return { |
| 107 ExtensionCode: ExtensionCode | 116 ExtensionCode: ExtensionCode |
| 108 }; | 117 }; |
| 109 }); | 118 }); |
| OLD | NEW |