| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * @unrestricted | 27 * @unrestricted |
| 28 */ | 28 */ |
| 29 WebInspector.ApplicationCacheItemsView = class extends WebInspector.SimpleView { | 29 Resources.ApplicationCacheItemsView = class extends UI.SimpleView { |
| 30 constructor(model, frameId) { | 30 constructor(model, frameId) { |
| 31 super(WebInspector.UIString('AppCache')); | 31 super(Common.UIString('AppCache')); |
| 32 | 32 |
| 33 this._model = model; | 33 this._model = model; |
| 34 | 34 |
| 35 this.element.classList.add('storage-view', 'table'); | 35 this.element.classList.add('storage-view', 'table'); |
| 36 | 36 |
| 37 this._deleteButton = new WebInspector.ToolbarButton(WebInspector.UIString('D
elete'), 'largeicon-delete'); | 37 this._deleteButton = new UI.ToolbarButton(Common.UIString('Delete'), 'largei
con-delete'); |
| 38 this._deleteButton.setVisible(false); | 38 this._deleteButton.setVisible(false); |
| 39 this._deleteButton.addEventListener('click', this._deleteButtonClicked, this
); | 39 this._deleteButton.addEventListener('click', this._deleteButtonClicked, this
); |
| 40 | 40 |
| 41 this._connectivityIcon = createElement('label', 'dt-icon-label'); | 41 this._connectivityIcon = createElement('label', 'dt-icon-label'); |
| 42 this._connectivityIcon.style.margin = '0 2px 0 5px'; | 42 this._connectivityIcon.style.margin = '0 2px 0 5px'; |
| 43 this._statusIcon = createElement('label', 'dt-icon-label'); | 43 this._statusIcon = createElement('label', 'dt-icon-label'); |
| 44 this._statusIcon.style.margin = '0 2px 0 5px'; | 44 this._statusIcon.style.margin = '0 2px 0 5px'; |
| 45 | 45 |
| 46 this._frameId = frameId; | 46 this._frameId = frameId; |
| 47 | 47 |
| 48 this._emptyWidget = | 48 this._emptyWidget = |
| 49 new WebInspector.EmptyWidget(WebInspector.UIString('No Application Cache
information available.')); | 49 new UI.EmptyWidget(Common.UIString('No Application Cache information ava
ilable.')); |
| 50 this._emptyWidget.show(this.element); | 50 this._emptyWidget.show(this.element); |
| 51 | 51 |
| 52 this._markDirty(); | 52 this._markDirty(); |
| 53 | 53 |
| 54 var status = this._model.frameManifestStatus(frameId); | 54 var status = this._model.frameManifestStatus(frameId); |
| 55 this.updateStatus(status); | 55 this.updateStatus(status); |
| 56 this.updateNetworkState(this._model.onLine); | 56 this.updateNetworkState(this._model.onLine); |
| 57 | 57 |
| 58 // FIXME: Status bar items don't work well enough yet, so they are being hid
den. | 58 // FIXME: Status bar items don't work well enough yet, so they are being hid
den. |
| 59 // http://webkit.org/b/41637 Web Inspector: Give Semantics to "Refresh" and
"Delete" Buttons in ApplicationCache DataGrid | 59 // http://webkit.org/b/41637 Web Inspector: Give Semantics to "Refresh" and
"Delete" Buttons in ApplicationCache DataGrid |
| 60 this._deleteButton.element.style.display = 'none'; | 60 this._deleteButton.element.style.display = 'none'; |
| 61 } | 61 } |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * @override | 64 * @override |
| 65 * @return {!Array.<!WebInspector.ToolbarItem>} | 65 * @return {!Array.<!UI.ToolbarItem>} |
| 66 */ | 66 */ |
| 67 syncToolbarItems() { | 67 syncToolbarItems() { |
| 68 return [ | 68 return [ |
| 69 this._deleteButton, new WebInspector.ToolbarItem(this._connectivityIcon),
new WebInspector.ToolbarSeparator(), | 69 this._deleteButton, new UI.ToolbarItem(this._connectivityIcon), new UI.Too
lbarSeparator(), |
| 70 new WebInspector.ToolbarItem(this._statusIcon) | 70 new UI.ToolbarItem(this._statusIcon) |
| 71 ]; | 71 ]; |
| 72 } | 72 } |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * @override | 75 * @override |
| 76 */ | 76 */ |
| 77 wasShown() { | 77 wasShown() { |
| 78 this._maybeUpdate(); | 78 this._maybeUpdate(); |
| 79 } | 79 } |
| 80 | 80 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 this._markDirty(); | 123 this._markDirty(); |
| 124 this._maybeUpdate(); | 124 this._maybeUpdate(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 /** | 127 /** |
| 128 * @param {boolean} isNowOnline | 128 * @param {boolean} isNowOnline |
| 129 */ | 129 */ |
| 130 updateNetworkState(isNowOnline) { | 130 updateNetworkState(isNowOnline) { |
| 131 if (isNowOnline) { | 131 if (isNowOnline) { |
| 132 this._connectivityIcon.type = 'smallicon-green-ball'; | 132 this._connectivityIcon.type = 'smallicon-green-ball'; |
| 133 this._connectivityIcon.textContent = WebInspector.UIString('Online'); | 133 this._connectivityIcon.textContent = Common.UIString('Online'); |
| 134 } else { | 134 } else { |
| 135 this._connectivityIcon.type = 'smallicon-red-ball'; | 135 this._connectivityIcon.type = 'smallicon-red-ball'; |
| 136 this._connectivityIcon.textContent = WebInspector.UIString('Offline'); | 136 this._connectivityIcon.textContent = Common.UIString('Offline'); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 _update() { | 140 _update() { |
| 141 this._model.requestApplicationCache(this._frameId, this._updateCallback.bind
(this)); | 141 this._model.requestApplicationCache(this._frameId, this._updateCallback.bind
(this)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 /** | 144 /** |
| 145 * @param {?Protocol.ApplicationCache.ApplicationCache} applicationCache | 145 * @param {?Protocol.ApplicationCache.ApplicationCache} applicationCache |
| 146 */ | 146 */ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 169 this._createDataGrid(); | 169 this._createDataGrid(); |
| 170 | 170 |
| 171 this._populateDataGrid(); | 171 this._populateDataGrid(); |
| 172 this._dataGrid.autoSizeColumns(20, 80); | 172 this._dataGrid.autoSizeColumns(20, 80); |
| 173 this._dataGrid.element.classList.remove('hidden'); | 173 this._dataGrid.element.classList.remove('hidden'); |
| 174 this._emptyWidget.detach(); | 174 this._emptyWidget.detach(); |
| 175 this._deleteButton.setVisible(true); | 175 this._deleteButton.setVisible(true); |
| 176 | 176 |
| 177 // FIXME: For Chrome, put creationTime and updateTime somewhere. | 177 // FIXME: For Chrome, put creationTime and updateTime somewhere. |
| 178 // NOTE: localizedString has not yet been added. | 178 // NOTE: localizedString has not yet been added. |
| 179 // WebInspector.UIString("(%s) Created: %s Updated: %s", this._size, this._c
reationTime, this._updateTime); | 179 // Common.UIString("(%s) Created: %s Updated: %s", this._size, this._creatio
nTime, this._updateTime); |
| 180 } | 180 } |
| 181 | 181 |
| 182 _createDataGrid() { | 182 _createDataGrid() { |
| 183 var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor>} */
([ | 183 var columns = /** @type {!Array<!UI.DataGrid.ColumnDescriptor>} */ ([ |
| 184 { | 184 { |
| 185 id: 'resource', | 185 id: 'resource', |
| 186 title: WebInspector.UIString('Resource'), | 186 title: Common.UIString('Resource'), |
| 187 sort: WebInspector.DataGrid.Order.Ascending, | 187 sort: UI.DataGrid.Order.Ascending, |
| 188 sortable: true | 188 sortable: true |
| 189 }, | 189 }, |
| 190 {id: 'type', title: WebInspector.UIString('Type'), sortable: true}, | 190 {id: 'type', title: Common.UIString('Type'), sortable: true}, |
| 191 {id: 'size', title: WebInspector.UIString('Size'), align: WebInspector.Dat
aGrid.Align.Right, sortable: true} | 191 {id: 'size', title: Common.UIString('Size'), align: UI.DataGrid.Align.Righ
t, sortable: true} |
| 192 ]); | 192 ]); |
| 193 this._dataGrid = new WebInspector.DataGrid(columns); | 193 this._dataGrid = new UI.DataGrid(columns); |
| 194 this._dataGrid.asWidget().show(this.element); | 194 this._dataGrid.asWidget().show(this.element); |
| 195 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged,
this._populateDataGrid, this); | 195 this._dataGrid.addEventListener(UI.DataGrid.Events.SortingChanged, this._pop
ulateDataGrid, this); |
| 196 } | 196 } |
| 197 | 197 |
| 198 _populateDataGrid() { | 198 _populateDataGrid() { |
| 199 var selectedResource = this._dataGrid.selectedNode ? this._dataGrid.selected
Node.resource : null; | 199 var selectedResource = this._dataGrid.selectedNode ? this._dataGrid.selected
Node.resource : null; |
| 200 var sortDirection = this._dataGrid.isSortOrderAscending() ? 1 : -1; | 200 var sortDirection = this._dataGrid.isSortOrderAscending() ? 1 : -1; |
| 201 | 201 |
| 202 function numberCompare(field, resource1, resource2) { | 202 function numberCompare(field, resource1, resource2) { |
| 203 return sortDirection * (resource1[field] - resource2[field]); | 203 return sortDirection * (resource1[field] - resource2[field]); |
| 204 } | 204 } |
| 205 function localeCompare(field, resource1, resource2) { | 205 function localeCompare(field, resource1, resource2) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 224 this._resources.sort(comparator); | 224 this._resources.sort(comparator); |
| 225 this._dataGrid.rootNode().removeChildren(); | 225 this._dataGrid.rootNode().removeChildren(); |
| 226 | 226 |
| 227 var nodeToSelect; | 227 var nodeToSelect; |
| 228 for (var i = 0; i < this._resources.length; ++i) { | 228 for (var i = 0; i < this._resources.length; ++i) { |
| 229 var data = {}; | 229 var data = {}; |
| 230 var resource = this._resources[i]; | 230 var resource = this._resources[i]; |
| 231 data.resource = resource.url; | 231 data.resource = resource.url; |
| 232 data.type = resource.type; | 232 data.type = resource.type; |
| 233 data.size = Number.bytesToString(resource.size); | 233 data.size = Number.bytesToString(resource.size); |
| 234 var node = new WebInspector.DataGridNode(data); | 234 var node = new UI.DataGridNode(data); |
| 235 node.resource = resource; | 235 node.resource = resource; |
| 236 node.selectable = true; | 236 node.selectable = true; |
| 237 this._dataGrid.rootNode().appendChild(node); | 237 this._dataGrid.rootNode().appendChild(node); |
| 238 if (resource === selectedResource) { | 238 if (resource === selectedResource) { |
| 239 nodeToSelect = node; | 239 nodeToSelect = node; |
| 240 nodeToSelect.selected = true; | 240 nodeToSelect.selected = true; |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 | 243 |
| 244 if (!nodeToSelect && this._dataGrid.rootNode().children.length) | 244 if (!nodeToSelect && this._dataGrid.rootNode().children.length) |
| 245 this._dataGrid.rootNode().children[0].selected = true; | 245 this._dataGrid.rootNode().children[0].selected = true; |
| 246 } | 246 } |
| 247 | 247 |
| 248 _deleteButtonClicked(event) { | 248 _deleteButtonClicked(event) { |
| 249 if (!this._dataGrid || !this._dataGrid.selectedNode) | 249 if (!this._dataGrid || !this._dataGrid.selectedNode) |
| 250 return; | 250 return; |
| 251 | 251 |
| 252 // FIXME: Delete Button semantics are not yet defined. (Delete a single, or
all?) | 252 // FIXME: Delete Button semantics are not yet defined. (Delete a single, or
all?) |
| 253 this._deleteCallback(this._dataGrid.selectedNode); | 253 this._deleteCallback(this._dataGrid.selectedNode); |
| 254 } | 254 } |
| 255 | 255 |
| 256 _deleteCallback(node) { | 256 _deleteCallback(node) { |
| 257 // FIXME: Should we delete a single (selected) resource or all resources? | 257 // FIXME: Should we delete a single (selected) resource or all resources? |
| 258 // InspectorBackend.deleteCachedResource(...) | 258 // InspectorBackend.deleteCachedResource(...) |
| 259 // this._update(); | 259 // this._update(); |
| 260 } | 260 } |
| 261 }; | 261 }; |
| OLD | NEW |