| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 this._emptyWidget.detach(); | 179 this._emptyWidget.detach(); |
| 180 this._deleteButton.setVisible(true); | 180 this._deleteButton.setVisible(true); |
| 181 | 181 |
| 182 // FIXME: For Chrome, put creationTime and updateTime somewhere. | 182 // FIXME: For Chrome, put creationTime and updateTime somewhere. |
| 183 // NOTE: localizedString has not yet been added. | 183 // NOTE: localizedString has not yet been added. |
| 184 // WebInspector.UIString("(%s) Created: %s Updated: %s", this._size, thi
s._creationTime, this._updateTime); | 184 // WebInspector.UIString("(%s) Created: %s Updated: %s", this._size, thi
s._creationTime, this._updateTime); |
| 185 }, | 185 }, |
| 186 | 186 |
| 187 _createDataGrid: function() | 187 _createDataGrid: function() |
| 188 { | 188 { |
| 189 var columns = [ | 189 var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor>
} */ ([ |
| 190 {title: WebInspector.UIString("Resource"), sort: WebInspector.DataGr
id.Order.Ascending, sortable: true}, | 190 {id: "resource", title: WebInspector.UIString("Resource"), sort: Web
Inspector.DataGrid.Order.Ascending, sortable: true}, |
| 191 {title: WebInspector.UIString("Type"), sortable: true}, | 191 {id: "type", title: WebInspector.UIString("Type"), sortable: true}, |
| 192 {title: WebInspector.UIString("Size"), align: WebInspector.DataGrid.
Align.Right, sortable: true} | 192 {id: "size", title: WebInspector.UIString("Size"), align: WebInspect
or.DataGrid.Align.Right, sortable: true} |
| 193 ]; | 193 ]); |
| 194 this._dataGrid = new WebInspector.DataGrid(columns); | 194 this._dataGrid = new WebInspector.DataGrid(columns); |
| 195 this._dataGrid.asWidget().show(this.element); | 195 this._dataGrid.asWidget().show(this.element); |
| 196 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan
ged, this._populateDataGrid, this); | 196 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan
ged, this._populateDataGrid, this); |
| 197 }, | 197 }, |
| 198 | 198 |
| 199 _populateDataGrid: function() | 199 _populateDataGrid: function() |
| 200 { | 200 { |
| 201 var selectedResource = this._dataGrid.selectedNode ? this._dataGrid.sele
ctedNode.resource : null; | 201 var selectedResource = this._dataGrid.selectedNode ? this._dataGrid.sele
ctedNode.resource : null; |
| 202 var sortDirection = this._dataGrid.isSortOrderAscending() ? 1 : -1; | 202 var sortDirection = this._dataGrid.isSortOrderAscending() ? 1 : -1; |
| 203 | 203 |
| 204 function numberCompare(field, resource1, resource2) | 204 function numberCompare(field, resource1, resource2) |
| 205 { | 205 { |
| 206 return sortDirection * (resource1[field] - resource2[field]); | 206 return sortDirection * (resource1[field] - resource2[field]); |
| 207 } | 207 } |
| 208 function localeCompare(field, resource1, resource2) | 208 function localeCompare(field, resource1, resource2) |
| 209 { | 209 { |
| 210 return sortDirection * (resource1[field] + "").localeCompare(resourc
e2[field] + ""); | 210 return sortDirection * (resource1[field] + "").localeCompare(resourc
e2[field] + ""); |
| 211 } | 211 } |
| 212 | 212 |
| 213 var comparator; | 213 var comparator; |
| 214 switch (parseInt(this._dataGrid.sortColumnIdentifier(), 10)) { | 214 switch (this._dataGrid.sortColumnId()) { |
| 215 case 0: comparator = localeCompare.bind(null, "name"); break; | 215 case "resource": comparator = localeCompare.bind(null, "url"); break; |
| 216 case 1: comparator = localeCompare.bind(null, "type"); break; | 216 case "type": comparator = localeCompare.bind(null, "type"); break; |
| 217 case 2: comparator = numberCompare.bind(null, "size"); break; | 217 case "size": comparator = numberCompare.bind(null, "size"); break; |
| 218 default: localeCompare.bind(null, "resource"); // FIXME: comparator = ? | 218 default: localeCompare.bind(null, "resource"); // FIXME: comparator = ? |
| 219 } | 219 } |
| 220 | 220 |
| 221 this._resources.sort(comparator); | 221 this._resources.sort(comparator); |
| 222 this._dataGrid.rootNode().removeChildren(); | 222 this._dataGrid.rootNode().removeChildren(); |
| 223 | 223 |
| 224 var nodeToSelect; | 224 var nodeToSelect; |
| 225 for (var i = 0; i < this._resources.length; ++i) { | 225 for (var i = 0; i < this._resources.length; ++i) { |
| 226 var data = {}; | 226 var data = {}; |
| 227 var resource = this._resources[i]; | 227 var resource = this._resources[i]; |
| 228 data[0] = resource.url; | 228 data.resource = resource.url; |
| 229 data[1] = resource.type; | 229 data.type = resource.type; |
| 230 data[2] = Number.bytesToString(resource.size); | 230 data.size = Number.bytesToString(resource.size); |
| 231 var node = new WebInspector.DataGridNode(data); | 231 var node = new WebInspector.DataGridNode(data); |
| 232 node.resource = resource; | 232 node.resource = resource; |
| 233 node.selectable = true; | 233 node.selectable = true; |
| 234 this._dataGrid.rootNode().appendChild(node); | 234 this._dataGrid.rootNode().appendChild(node); |
| 235 if (resource === selectedResource) { | 235 if (resource === selectedResource) { |
| 236 nodeToSelect = node; | 236 nodeToSelect = node; |
| 237 nodeToSelect.selected = true; | 237 nodeToSelect.selected = true; |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 | 240 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 254 _deleteCallback: function(node) | 254 _deleteCallback: function(node) |
| 255 { | 255 { |
| 256 // FIXME: Should we delete a single (selected) resource or all resources
? | 256 // FIXME: Should we delete a single (selected) resource or all resources
? |
| 257 // InspectorBackend.deleteCachedResource(...) | 257 // InspectorBackend.deleteCachedResource(...) |
| 258 // this._update(); | 258 // this._update(); |
| 259 }, | 259 }, |
| 260 | 260 |
| 261 __proto__: WebInspector.SimpleView.prototype | 261 __proto__: WebInspector.SimpleView.prototype |
| 262 }; | 262 }; |
| 263 | 263 |
| OLD | NEW |