| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 wasShown: function() | 49 wasShown: function() |
| 50 { | 50 { |
| 51 this._createContentIfNeeded(); | 51 this._createContentIfNeeded(); |
| 52 }, | 52 }, |
| 53 | 53 |
| 54 _createContentIfNeeded: function() | 54 _createContentIfNeeded: function() |
| 55 { | 55 { |
| 56 if (this._container) | 56 if (this._container) |
| 57 return; | 57 return; |
| 58 | 58 |
| 59 var imageContainer = document.createElement("div"); | 59 var imageContainer = this.element.createChild("div", "image"); |
| 60 imageContainer.className = "image"; | 60 var imagePreviewElement = imageContainer.createChild("img", "resource-im
age-view"); |
| 61 this.element.appendChild(imageContainer); | |
| 62 | |
| 63 var imagePreviewElement = document.createElement("img"); | |
| 64 imagePreviewElement.classList.add("resource-image-view"); | |
| 65 imageContainer.appendChild(imagePreviewElement); | |
| 66 imagePreviewElement.addEventListener("contextmenu", this._contextMenu.bi
nd(this), true); | 61 imagePreviewElement.addEventListener("contextmenu", this._contextMenu.bi
nd(this), true); |
| 67 | 62 |
| 68 this._container = document.createElement("div"); | 63 this._container = this.element.createChild("div", "info"); |
| 69 this._container.className = "info"; | 64 this._container.createChild("h1", "title").textContent = this.resource.d
isplayName; |
| 70 this.element.appendChild(this._container); | |
| 71 | 65 |
| 72 var imageNameElement = document.createElement("h1"); | 66 var infoListElement = document.createElementWithClass("dl", "infoList"); |
| 73 imageNameElement.className = "title"; | |
| 74 imageNameElement.textContent = this.resource.displayName; | |
| 75 this._container.appendChild(imageNameElement); | |
| 76 | |
| 77 var infoListElement = document.createElement("dl"); | |
| 78 infoListElement.className = "infoList"; | |
| 79 | 67 |
| 80 this.resource.populateImageSource(imagePreviewElement); | 68 this.resource.populateImageSource(imagePreviewElement); |
| 81 | 69 |
| 82 /** | 70 /** |
| 83 * @this {WebInspector.ImageView} | 71 * @this {WebInspector.ImageView} |
| 84 */ | 72 */ |
| 85 function onImageLoad() | 73 function onImageLoad() |
| 86 { | 74 { |
| 87 var content = this.resource.content; | 75 var content = this.resource.content; |
| 88 if (content) | 76 if (content) |
| 89 var resourceSize = this._base64ToSize(content); | 77 var resourceSize = this._base64ToSize(content); |
| 90 else | 78 else |
| 91 var resourceSize = this.resource.resourceSize; | 79 var resourceSize = this.resource.resourceSize; |
| 92 | 80 |
| 93 var imageProperties = [ | 81 var imageProperties = [ |
| 94 { name: WebInspector.UIString("Dimensions"), value: WebInspector
.UIString("%d × %d", imagePreviewElement.naturalWidth, imagePreviewElement.natur
alHeight) }, | 82 { name: WebInspector.UIString("Dimensions"), value: WebInspector
.UIString("%d × %d", imagePreviewElement.naturalWidth, imagePreviewElement.natur
alHeight) }, |
| 95 { name: WebInspector.UIString("File size"), value: Number.bytesT
oString(resourceSize) }, | 83 { name: WebInspector.UIString("File size"), value: Number.bytesT
oString(resourceSize) }, |
| 96 { name: WebInspector.UIString("MIME type"), value: this.resource
.mimeType } | 84 { name: WebInspector.UIString("MIME type"), value: this.resource
.mimeType } |
| 97 ]; | 85 ]; |
| 98 | 86 |
| 99 infoListElement.removeChildren(); | 87 infoListElement.removeChildren(); |
| 100 for (var i = 0; i < imageProperties.length; ++i) { | 88 for (var i = 0; i < imageProperties.length; ++i) { |
| 101 var dt = document.createElement("dt"); | 89 infoListElement.createChild("dt").textContent = imageProperties[
i].name; |
| 102 dt.textContent = imageProperties[i].name; | 90 infoListElement.createChild("dd").textContent = imageProperties[
i].value; |
| 103 infoListElement.appendChild(dt); | |
| 104 var dd = document.createElement("dd"); | |
| 105 dd.textContent = imageProperties[i].value; | |
| 106 infoListElement.appendChild(dd); | |
| 107 } | 91 } |
| 108 var dt = document.createElement("dt"); | 92 infoListElement.createChild("dt").textContent = WebInspector.UIStrin
g("URL"); |
| 109 dt.textContent = WebInspector.UIString("URL"); | 93 infoListElement.createChild("dd").appendChild(WebInspector.linkifyUR
LAsNode(this.resource.url, undefined, undefined, true /* externalResource */)); |
| 110 infoListElement.appendChild(dt); | |
| 111 var dd = document.createElement("dd"); | |
| 112 var externalResource = true; | |
| 113 dd.appendChild(WebInspector.linkifyURLAsNode(this.resource.url, unde
fined, undefined, externalResource)); | |
| 114 infoListElement.appendChild(dd); | |
| 115 | |
| 116 this._container.appendChild(infoListElement); | 94 this._container.appendChild(infoListElement); |
| 117 } | 95 } |
| 118 imagePreviewElement.addEventListener("load", onImageLoad.bind(this), fal
se); | 96 imagePreviewElement.addEventListener("load", onImageLoad.bind(this), fal
se); |
| 119 this._imagePreviewElement = imagePreviewElement; | 97 this._imagePreviewElement = imagePreviewElement; |
| 120 }, | 98 }, |
| 121 | 99 |
| 122 _base64ToSize: function(content) | 100 _base64ToSize: function(content) |
| 123 { | 101 { |
| 124 if (!content.length) | 102 if (!content.length) |
| 125 return 0; | 103 return 0; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 151 InspectorFrontendHost.copyText(this.resource.url); | 129 InspectorFrontendHost.copyText(this.resource.url); |
| 152 }, | 130 }, |
| 153 | 131 |
| 154 _openInNewTab: function() | 132 _openInNewTab: function() |
| 155 { | 133 { |
| 156 InspectorFrontendHost.openInNewTab(this.resource.url); | 134 InspectorFrontendHost.openInNewTab(this.resource.url); |
| 157 }, | 135 }, |
| 158 | 136 |
| 159 __proto__: WebInspector.ResourceView.prototype | 137 __proto__: WebInspector.ResourceView.prototype |
| 160 } | 138 } |
| OLD | NEW |