| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.DataGrid} | 33 * @extends {WebInspector.SortableDataGrid} |
| 34 */ | 34 */ |
| 35 WebInspector.DirectoryContentView = function() | 35 WebInspector.DirectoryContentView = function() |
| 36 { | 36 { |
| 37 const indexes = WebInspector.DirectoryContentView.columnIndexes; | 37 const indexes = WebInspector.DirectoryContentView.columnIndexes; |
| 38 var columns = [ | 38 var columns = [ |
| 39 {id: indexes.Name, title: WebInspector.UIString("Name"), sortable: true,
sort: WebInspector.DataGrid.Order.Ascending, width: "20%"}, | 39 {id: indexes.Name, title: WebInspector.UIString("Name"), sortable: true,
sort: WebInspector.DataGrid.Order.Ascending, width: "20%"}, |
| 40 {id: indexes.URL, title: WebInspector.UIString("URL"), sortable: true, w
idth: "20%"}, | 40 {id: indexes.URL, title: WebInspector.UIString("URL"), sortable: true, w
idth: "20%"}, |
| 41 {id: indexes.Type, title: WebInspector.UIString("Type"), sortable: true,
width: "15%"}, | 41 {id: indexes.Type, title: WebInspector.UIString("Type"), sortable: true,
width: "15%"}, |
| 42 {id: indexes.Size, title: WebInspector.UIString("Size"), sortable: true,
width: "10%"}, | 42 {id: indexes.Size, title: WebInspector.UIString("Size"), sortable: true,
width: "10%"}, |
| 43 {id: indexes.ModificationTime, title: WebInspector.UIString("Modificatio
n Time"), sortable: true, width: "25%"} | 43 {id: indexes.ModificationTime, title: WebInspector.UIString("Modificatio
n Time"), sortable: true, width: "25%"} |
| 44 ]; | 44 ]; |
| 45 | 45 |
| 46 WebInspector.DataGrid.call(this, columns); | 46 WebInspector.SortableDataGrid.call(this, columns); |
| 47 this.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._sor
t, this); | 47 this.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._sor
t, this); |
| 48 } | 48 } |
| 49 | 49 |
| 50 WebInspector.DirectoryContentView.columnIndexes = { | 50 WebInspector.DirectoryContentView.columnIndexes = { |
| 51 Name: "0", | 51 Name: "0", |
| 52 URL: "1", | 52 URL: "1", |
| 53 Type: "2", | 53 Type: "2", |
| 54 Size: "3", | 54 Size: "3", |
| 55 ModificationTime: "4" | 55 ModificationTime: "4" |
| 56 } | 56 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 68 }, | 68 }, |
| 69 | 69 |
| 70 _sort: function() | 70 _sort: function() |
| 71 { | 71 { |
| 72 var column = this.sortColumnIdentifier(); | 72 var column = this.sortColumnIdentifier(); |
| 73 if (!column) | 73 if (!column) |
| 74 return; | 74 return; |
| 75 this.sortNodes(WebInspector.DirectoryContentView.Node.comparator(column)
, !this.isSortOrderAscending()); | 75 this.sortNodes(WebInspector.DirectoryContentView.Node.comparator(column)
, !this.isSortOrderAscending()); |
| 76 }, | 76 }, |
| 77 | 77 |
| 78 __proto__: WebInspector.DataGrid.prototype | 78 __proto__: WebInspector.SortableDataGrid.prototype |
| 79 } | 79 } |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * @constructor | 82 * @constructor |
| 83 * @extends {WebInspector.DataGridNode} | 83 * @extends {WebInspector.SortableDataGridNode} |
| 84 * @param {!WebInspector.FileSystemModel.Entry} entry | 84 * @param {!WebInspector.FileSystemModel.Entry} entry |
| 85 */ | 85 */ |
| 86 WebInspector.DirectoryContentView.Node = function(entry) | 86 WebInspector.DirectoryContentView.Node = function(entry) |
| 87 { | 87 { |
| 88 const indexes = WebInspector.DirectoryContentView.columnIndexes; | 88 const indexes = WebInspector.DirectoryContentView.columnIndexes; |
| 89 var data = {}; | 89 var data = {}; |
| 90 data[indexes.Name] = entry.name; | 90 data[indexes.Name] = entry.name; |
| 91 data[indexes.URL] = entry.url; | 91 data[indexes.URL] = entry.url; |
| 92 data[indexes.Type] = entry.isDirectory ? WebInspector.UIString("Directory")
: entry.mimeType; | 92 data[indexes.Type] = entry.isDirectory ? WebInspector.UIString("Directory")
: entry.mimeType; |
| 93 data[indexes.Size] = ""; | 93 data[indexes.Size] = ""; |
| 94 data[indexes.ModificationTime] = ""; | 94 data[indexes.ModificationTime] = ""; |
| 95 | 95 |
| 96 WebInspector.DataGridNode.call(this, data); | 96 WebInspector.SortableDataGridNode.call(this, data); |
| 97 this._entry = entry; | 97 this._entry = entry; |
| 98 this._metadata = null; | 98 this._metadata = null; |
| 99 | 99 |
| 100 this._entry.requestMetadata(this._metadataReceived.bind(this)); | 100 this._entry.requestMetadata(this._metadataReceived.bind(this)); |
| 101 } | 101 } |
| 102 | 102 |
| 103 /** | 103 /** |
| 104 * @param {string} column | 104 * @param {string} column |
| 105 * @return {function(!WebInspector.DataGridNode, !WebInspector.DataGridNode):num
ber} | 105 * @return {function(!WebInspector.DataGridNode, !WebInspector.DataGridNode):num
ber} |
| 106 */ | 106 */ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 124 return function(x, y) | 124 return function(x, y) |
| 125 { | 125 { |
| 126 return isDirectoryCompare(x, y) || sizeCompare(x, y) || nameCompare(
x, y); | 126 return isDirectoryCompare(x, y) || sizeCompare(x, y) || nameCompare(
x, y); |
| 127 }; | 127 }; |
| 128 case indexes.ModificationTime: | 128 case indexes.ModificationTime: |
| 129 return function(x, y) | 129 return function(x, y) |
| 130 { | 130 { |
| 131 return isDirectoryCompare(x, y) || modificationTimeCompare(x, y) ||
nameCompare(x, y); | 131 return isDirectoryCompare(x, y) || modificationTimeCompare(x, y) ||
nameCompare(x, y); |
| 132 }; | 132 }; |
| 133 default: | 133 default: |
| 134 return WebInspector.DataGrid.TrivialComparator; | 134 return WebInspector.SortableDataGrid.TrivialComparator; |
| 135 } | 135 } |
| 136 | 136 |
| 137 function isDirectoryCompare(x, y) | 137 function isDirectoryCompare(x, y) |
| 138 { | 138 { |
| 139 if (x._entry.isDirectory != y._entry.isDirectory) | 139 if (x._entry.isDirectory != y._entry.isDirectory) |
| 140 return y._entry.isDirectory ? 1 : -1; | 140 return y._entry.isDirectory ? 1 : -1; |
| 141 return 0; | 141 return 0; |
| 142 } | 142 } |
| 143 | 143 |
| 144 function nameCompare(x, y) | 144 function nameCompare(x, y) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 this._metadata = metadata; | 176 this._metadata = metadata; |
| 177 var data = this.data; | 177 var data = this.data; |
| 178 if (this._entry.isDirectory) | 178 if (this._entry.isDirectory) |
| 179 data[indexes.Size] = WebInspector.UIString("-"); | 179 data[indexes.Size] = WebInspector.UIString("-"); |
| 180 else | 180 else |
| 181 data[indexes.Size] = Number.bytesToString(metadata.size); | 181 data[indexes.Size] = Number.bytesToString(metadata.size); |
| 182 data[indexes.ModificationTime] = new Date(metadata.modificationTime).toI
SOString(); | 182 data[indexes.ModificationTime] = new Date(metadata.modificationTime).toI
SOString(); |
| 183 this.data = data; | 183 this.data = data; |
| 184 }, | 184 }, |
| 185 | 185 |
| 186 __proto__: WebInspector.DataGridNode.prototype | 186 __proto__: WebInspector.SortableDataGridNode.prototype |
| 187 } | 187 } |
| OLD | NEW |