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