Index: third_party/WebKit/Source/devtools/front_end/resources/ApplicationCacheItemsView.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/resources/ApplicationCacheItemsView.js b/third_party/WebKit/Source/devtools/front_end/resources/ApplicationCacheItemsView.js |
index 873d565e156b96a517f866ea2f063bc44bc3d073..bf373c59b0bf6cb5ce549ae8a3c208ee40275c11 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/resources/ApplicationCacheItemsView.js |
+++ b/third_party/WebKit/Source/devtools/front_end/resources/ApplicationCacheItemsView.js |
@@ -22,31 +22,30 @@ |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
* THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
- |
/** |
- * @constructor |
- * @extends {WebInspector.SimpleView} |
+ * @unrestricted |
*/ |
-WebInspector.ApplicationCacheItemsView = function(model, frameId) |
-{ |
- WebInspector.SimpleView.call(this, WebInspector.UIString("AppCache")); |
+WebInspector.ApplicationCacheItemsView = class extends WebInspector.SimpleView { |
+ constructor(model, frameId) { |
+ super(WebInspector.UIString('AppCache')); |
this._model = model; |
- this.element.classList.add("storage-view", "table"); |
+ this.element.classList.add('storage-view', 'table'); |
- this._deleteButton = new WebInspector.ToolbarButton(WebInspector.UIString("Delete"), "delete-toolbar-item"); |
+ this._deleteButton = new WebInspector.ToolbarButton(WebInspector.UIString('Delete'), 'delete-toolbar-item'); |
this._deleteButton.setVisible(false); |
- this._deleteButton.addEventListener("click", this._deleteButtonClicked, this); |
+ this._deleteButton.addEventListener('click', this._deleteButtonClicked, this); |
- this._connectivityIcon = createElement("label", "dt-icon-label"); |
- this._connectivityIcon.style.margin = "0 2px 0 5px"; |
- this._statusIcon = createElement("label", "dt-icon-label"); |
- this._statusIcon.style.margin = "0 2px 0 5px"; |
+ this._connectivityIcon = createElement('label', 'dt-icon-label'); |
+ this._connectivityIcon.style.margin = '0 2px 0 5px'; |
+ this._statusIcon = createElement('label', 'dt-icon-label'); |
+ this._statusIcon.style.margin = '0 2px 0 5px'; |
this._frameId = frameId; |
- this._emptyWidget = new WebInspector.EmptyWidget(WebInspector.UIString("No Application Cache information available.")); |
+ this._emptyWidget = |
+ new WebInspector.EmptyWidget(WebInspector.UIString('No Application Cache information available.')); |
this._emptyWidget.show(this.element); |
this._markDirty(); |
@@ -57,207 +56,205 @@ WebInspector.ApplicationCacheItemsView = function(model, frameId) |
// FIXME: Status bar items don't work well enough yet, so they are being hidden. |
// http://webkit.org/b/41637 Web Inspector: Give Semantics to "Refresh" and "Delete" Buttons in ApplicationCache DataGrid |
- this._deleteButton.element.style.display = "none"; |
-}; |
- |
-WebInspector.ApplicationCacheItemsView.prototype = { |
- /** |
- * @override |
- * @return {!Array.<!WebInspector.ToolbarItem>} |
- */ |
- syncToolbarItems: function() |
- { |
- return [ |
- this._deleteButton, |
- new WebInspector.ToolbarItem(this._connectivityIcon), |
- new WebInspector.ToolbarSeparator(), |
- new WebInspector.ToolbarItem(this._statusIcon) |
- ]; |
- }, |
- |
- wasShown: function() |
- { |
- this._maybeUpdate(); |
- }, |
- |
- willHide: function() |
- { |
- this._deleteButton.setVisible(false); |
- }, |
- |
- _maybeUpdate: function() |
- { |
- if (!this.isShowing() || !this._viewDirty) |
- return; |
- |
- this._update(); |
- this._viewDirty = false; |
- }, |
- |
- _markDirty: function() |
- { |
- this._viewDirty = true; |
- }, |
- |
- /** |
- * @param {number} status |
- */ |
- updateStatus: function(status) |
- { |
- var oldStatus = this._status; |
- this._status = status; |
- |
- var statusInformation = {}; |
- // We should never have UNCACHED status, since we remove frames with UNCACHED application cache status from the tree. |
- statusInformation[applicationCache.UNCACHED] = { type: "red-ball", text: "UNCACHED" }; |
- statusInformation[applicationCache.IDLE] = { type: "green-ball", text: "IDLE" }; |
- statusInformation[applicationCache.CHECKING] = { type: "orange-ball", text: "CHECKING" }; |
- statusInformation[applicationCache.DOWNLOADING] = { type: "orange-ball", text: "DOWNLOADING" }; |
- statusInformation[applicationCache.UPDATEREADY] = { type: "green-ball", text: "UPDATEREADY" }; |
- statusInformation[applicationCache.OBSOLETE] = { type: "red-ball", text: "OBSOLETE" }; |
- |
- var info = statusInformation[status] || statusInformation[applicationCache.UNCACHED]; |
- |
- this._statusIcon.type = info.type; |
- this._statusIcon.textContent = info.text; |
- |
- if (this.isShowing() && this._status === applicationCache.IDLE && (oldStatus === applicationCache.UPDATEREADY || !this._resources)) |
- this._markDirty(); |
- this._maybeUpdate(); |
- }, |
- |
- /** |
- * @param {boolean} isNowOnline |
- */ |
- updateNetworkState: function(isNowOnline) |
- { |
- if (isNowOnline) { |
- this._connectivityIcon.type = "green-ball"; |
- this._connectivityIcon.textContent = WebInspector.UIString("Online"); |
- } else { |
- this._connectivityIcon.type = "red-ball"; |
- this._connectivityIcon.textContent = WebInspector.UIString("Offline"); |
- } |
- }, |
- |
- _update: function() |
- { |
- this._model.requestApplicationCache(this._frameId, this._updateCallback.bind(this)); |
- }, |
- |
- /** |
- * @param {?ApplicationCacheAgent.ApplicationCache} applicationCache |
- */ |
- _updateCallback: function(applicationCache) |
- { |
- if (!applicationCache || !applicationCache.manifestURL) { |
- delete this._manifest; |
- delete this._creationTime; |
- delete this._updateTime; |
- delete this._size; |
- delete this._resources; |
- |
- this._emptyWidget.show(this.element); |
- this._deleteButton.setVisible(false); |
- if (this._dataGrid) |
- this._dataGrid.element.classList.add("hidden"); |
- return; |
- } |
- // FIXME: are these variables needed anywhere else? |
- this._manifest = applicationCache.manifestURL; |
- this._creationTime = applicationCache.creationTime; |
- this._updateTime = applicationCache.updateTime; |
- this._size = applicationCache.size; |
- this._resources = applicationCache.resources; |
- |
- if (!this._dataGrid) |
- this._createDataGrid(); |
- |
- this._populateDataGrid(); |
- this._dataGrid.autoSizeColumns(20, 80); |
- this._dataGrid.element.classList.remove("hidden"); |
- this._emptyWidget.detach(); |
- this._deleteButton.setVisible(true); |
- |
- // FIXME: For Chrome, put creationTime and updateTime somewhere. |
- // NOTE: localizedString has not yet been added. |
- // WebInspector.UIString("(%s) Created: %s Updated: %s", this._size, this._creationTime, this._updateTime); |
- }, |
- |
- _createDataGrid: function() |
- { |
- var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor>} */ ([ |
- {id: "resource", title: WebInspector.UIString("Resource"), sort: WebInspector.DataGrid.Order.Ascending, sortable: true}, |
- {id: "type", title: WebInspector.UIString("Type"), sortable: true}, |
- {id: "size", title: WebInspector.UIString("Size"), align: WebInspector.DataGrid.Align.Right, sortable: true} |
- ]); |
- this._dataGrid = new WebInspector.DataGrid(columns); |
- this._dataGrid.asWidget().show(this.element); |
- this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._populateDataGrid, this); |
- }, |
- |
- _populateDataGrid: function() |
- { |
- var selectedResource = this._dataGrid.selectedNode ? this._dataGrid.selectedNode.resource : null; |
- var sortDirection = this._dataGrid.isSortOrderAscending() ? 1 : -1; |
- |
- function numberCompare(field, resource1, resource2) |
- { |
- return sortDirection * (resource1[field] - resource2[field]); |
- } |
- function localeCompare(field, resource1, resource2) |
- { |
- return sortDirection * (resource1[field] + "").localeCompare(resource2[field] + ""); |
- } |
- |
- var comparator; |
- switch (this._dataGrid.sortColumnId()) { |
- case "resource": comparator = localeCompare.bind(null, "url"); break; |
- case "type": comparator = localeCompare.bind(null, "type"); break; |
- case "size": comparator = numberCompare.bind(null, "size"); break; |
- default: localeCompare.bind(null, "resource"); // FIXME: comparator = ? |
- } |
- |
- this._resources.sort(comparator); |
- this._dataGrid.rootNode().removeChildren(); |
- |
- var nodeToSelect; |
- for (var i = 0; i < this._resources.length; ++i) { |
- var data = {}; |
- var resource = this._resources[i]; |
- data.resource = resource.url; |
- data.type = resource.type; |
- data.size = Number.bytesToString(resource.size); |
- var node = new WebInspector.DataGridNode(data); |
- node.resource = resource; |
- node.selectable = true; |
- this._dataGrid.rootNode().appendChild(node); |
- if (resource === selectedResource) { |
- nodeToSelect = node; |
- nodeToSelect.selected = true; |
- } |
- } |
- |
- if (!nodeToSelect && this._dataGrid.rootNode().children.length) |
- this._dataGrid.rootNode().children[0].selected = true; |
- }, |
- |
- _deleteButtonClicked: function(event) |
- { |
- if (!this._dataGrid || !this._dataGrid.selectedNode) |
- return; |
- |
- // FIXME: Delete Button semantics are not yet defined. (Delete a single, or all?) |
- this._deleteCallback(this._dataGrid.selectedNode); |
- }, |
- |
- _deleteCallback: function(node) |
- { |
- // FIXME: Should we delete a single (selected) resource or all resources? |
- // InspectorBackend.deleteCachedResource(...) |
- // this._update(); |
- }, |
- |
- __proto__: WebInspector.SimpleView.prototype |
+ this._deleteButton.element.style.display = 'none'; |
+ } |
+ |
+ /** |
+ * @override |
+ * @return {!Array.<!WebInspector.ToolbarItem>} |
+ */ |
+ syncToolbarItems() { |
+ return [ |
+ this._deleteButton, new WebInspector.ToolbarItem(this._connectivityIcon), new WebInspector.ToolbarSeparator(), |
+ new WebInspector.ToolbarItem(this._statusIcon) |
+ ]; |
+ } |
+ |
+ /** |
+ * @override |
+ */ |
+ wasShown() { |
+ this._maybeUpdate(); |
+ } |
+ |
+ /** |
+ * @override |
+ */ |
+ willHide() { |
+ this._deleteButton.setVisible(false); |
+ } |
+ |
+ _maybeUpdate() { |
+ if (!this.isShowing() || !this._viewDirty) |
+ return; |
+ |
+ this._update(); |
+ this._viewDirty = false; |
+ } |
+ |
+ _markDirty() { |
+ this._viewDirty = true; |
+ } |
+ |
+ /** |
+ * @param {number} status |
+ */ |
+ updateStatus(status) { |
+ var oldStatus = this._status; |
+ this._status = status; |
+ |
+ var statusInformation = {}; |
+ // We should never have UNCACHED status, since we remove frames with UNCACHED application cache status from the tree. |
+ statusInformation[applicationCache.UNCACHED] = {type: 'red-ball', text: 'UNCACHED'}; |
+ statusInformation[applicationCache.IDLE] = {type: 'green-ball', text: 'IDLE'}; |
+ statusInformation[applicationCache.CHECKING] = {type: 'orange-ball', text: 'CHECKING'}; |
+ statusInformation[applicationCache.DOWNLOADING] = {type: 'orange-ball', text: 'DOWNLOADING'}; |
+ statusInformation[applicationCache.UPDATEREADY] = {type: 'green-ball', text: 'UPDATEREADY'}; |
+ statusInformation[applicationCache.OBSOLETE] = {type: 'red-ball', text: 'OBSOLETE'}; |
+ |
+ var info = statusInformation[status] || statusInformation[applicationCache.UNCACHED]; |
+ |
+ this._statusIcon.type = info.type; |
+ this._statusIcon.textContent = info.text; |
+ |
+ if (this.isShowing() && this._status === applicationCache.IDLE && |
+ (oldStatus === applicationCache.UPDATEREADY || !this._resources)) |
+ this._markDirty(); |
+ this._maybeUpdate(); |
+ } |
+ |
+ /** |
+ * @param {boolean} isNowOnline |
+ */ |
+ updateNetworkState(isNowOnline) { |
+ if (isNowOnline) { |
+ this._connectivityIcon.type = 'green-ball'; |
+ this._connectivityIcon.textContent = WebInspector.UIString('Online'); |
+ } else { |
+ this._connectivityIcon.type = 'red-ball'; |
+ this._connectivityIcon.textContent = WebInspector.UIString('Offline'); |
+ } |
+ } |
+ |
+ _update() { |
+ this._model.requestApplicationCache(this._frameId, this._updateCallback.bind(this)); |
+ } |
+ |
+ /** |
+ * @param {?ApplicationCacheAgent.ApplicationCache} applicationCache |
+ */ |
+ _updateCallback(applicationCache) { |
+ if (!applicationCache || !applicationCache.manifestURL) { |
+ delete this._manifest; |
+ delete this._creationTime; |
+ delete this._updateTime; |
+ delete this._size; |
+ delete this._resources; |
+ |
+ this._emptyWidget.show(this.element); |
+ this._deleteButton.setVisible(false); |
+ if (this._dataGrid) |
+ this._dataGrid.element.classList.add('hidden'); |
+ return; |
+ } |
+ // FIXME: are these variables needed anywhere else? |
+ this._manifest = applicationCache.manifestURL; |
+ this._creationTime = applicationCache.creationTime; |
+ this._updateTime = applicationCache.updateTime; |
+ this._size = applicationCache.size; |
+ this._resources = applicationCache.resources; |
+ |
+ if (!this._dataGrid) |
+ this._createDataGrid(); |
+ |
+ this._populateDataGrid(); |
+ this._dataGrid.autoSizeColumns(20, 80); |
+ this._dataGrid.element.classList.remove('hidden'); |
+ this._emptyWidget.detach(); |
+ this._deleteButton.setVisible(true); |
+ |
+ // FIXME: For Chrome, put creationTime and updateTime somewhere. |
+ // NOTE: localizedString has not yet been added. |
+ // WebInspector.UIString("(%s) Created: %s Updated: %s", this._size, this._creationTime, this._updateTime); |
+ } |
+ |
+ _createDataGrid() { |
+ var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor>} */ ([ |
+ { |
+ id: 'resource', |
+ title: WebInspector.UIString('Resource'), |
+ sort: WebInspector.DataGrid.Order.Ascending, |
+ sortable: true |
+ }, |
+ {id: 'type', title: WebInspector.UIString('Type'), sortable: true}, |
+ {id: 'size', title: WebInspector.UIString('Size'), align: WebInspector.DataGrid.Align.Right, sortable: true} |
+ ]); |
+ this._dataGrid = new WebInspector.DataGrid(columns); |
+ this._dataGrid.asWidget().show(this.element); |
+ this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._populateDataGrid, this); |
+ } |
+ |
+ _populateDataGrid() { |
+ var selectedResource = this._dataGrid.selectedNode ? this._dataGrid.selectedNode.resource : null; |
+ var sortDirection = this._dataGrid.isSortOrderAscending() ? 1 : -1; |
+ |
+ function numberCompare(field, resource1, resource2) { |
+ return sortDirection * (resource1[field] - resource2[field]); |
+ } |
+ function localeCompare(field, resource1, resource2) { |
+ return sortDirection * (resource1[field] + '').localeCompare(resource2[field] + ''); |
+ } |
+ |
+ var comparator; |
+ switch (this._dataGrid.sortColumnId()) { |
+ case 'resource': |
+ comparator = localeCompare.bind(null, 'url'); |
+ break; |
+ case 'type': |
+ comparator = localeCompare.bind(null, 'type'); |
+ break; |
+ case 'size': |
+ comparator = numberCompare.bind(null, 'size'); |
+ break; |
+ default: |
+ localeCompare.bind(null, 'resource'); // FIXME: comparator = ? |
+ } |
+ |
+ this._resources.sort(comparator); |
+ this._dataGrid.rootNode().removeChildren(); |
+ |
+ var nodeToSelect; |
+ for (var i = 0; i < this._resources.length; ++i) { |
+ var data = {}; |
+ var resource = this._resources[i]; |
+ data.resource = resource.url; |
+ data.type = resource.type; |
+ data.size = Number.bytesToString(resource.size); |
+ var node = new WebInspector.DataGridNode(data); |
+ node.resource = resource; |
+ node.selectable = true; |
+ this._dataGrid.rootNode().appendChild(node); |
+ if (resource === selectedResource) { |
+ nodeToSelect = node; |
+ nodeToSelect.selected = true; |
+ } |
+ } |
+ |
+ if (!nodeToSelect && this._dataGrid.rootNode().children.length) |
+ this._dataGrid.rootNode().children[0].selected = true; |
+ } |
+ |
+ _deleteButtonClicked(event) { |
+ if (!this._dataGrid || !this._dataGrid.selectedNode) |
+ return; |
+ |
+ // FIXME: Delete Button semantics are not yet defined. (Delete a single, or all?) |
+ this._deleteCallback(this._dataGrid.selectedNode); |
+ } |
+ |
+ _deleteCallback(node) { |
+ // FIXME: Should we delete a single (selected) resource or all resources? |
+ // InspectorBackend.deleteCachedResource(...) |
+ // this._update(); |
+ } |
}; |
- |