DOMStorageItemsView.js [plain text]
WebInspector.DOMStorageItemsView = function(domStorage)
{
WebInspector.View.call(this);
this.domStorage = domStorage;
this.element.addStyleClass("storage-view");
this.element.addStyleClass("table");
this.deleteButton = document.createElement("button");
this.deleteButton.title = WebInspector.UIString("Delete");
this.deleteButton.className = "delete-storage-status-bar-item status-bar-item hidden";
this.deleteButton.addEventListener("click", this._deleteButtonClicked.bind(this), false);
this.refreshButton = document.createElement("button");
this.refreshButton.title = WebInspector.UIString("Refresh");
this.refreshButton.className = "refresh-storage-status-bar-item status-bar-item";
this.refreshButton.addEventListener("click", this._refreshButtonClicked.bind(this), false);
}
WebInspector.DOMStorageItemsView.prototype = {
get statusBarItems()
{
return [this.refreshButton, this.deleteButton];
},
show: function(parentElement)
{
WebInspector.View.prototype.show.call(this, parentElement);
this.update();
},
hide: function()
{
WebInspector.View.prototype.hide.call(this);
this.deleteButton.addStyleClass("hidden");
},
update: function()
{
this.element.removeChildren();
var hasDOMStorage = this.domStorage;
if (hasDOMStorage)
hasDOMStorage = this.domStorage.domStorage;
if (hasDOMStorage) {
var dataGrid = WebInspector.panels.databases.dataGridForDOMStorage(this.domStorage.domStorage);
if (!dataGrid)
hasDOMStorage = 0;
else {
this._dataGrid = dataGrid;
this.element.appendChild(dataGrid.element);
this.deleteButton.removeStyleClass("hidden");
}
}
if (!hasDOMStorage) {
var emptyMsgElement = document.createElement("div");
emptyMsgElement.className = "storage-table-empty";
if (this.domStorage)
emptyMsgElement.textContent = WebInspector.UIString("This storage is empty.");
this.element.appendChild(emptyMsgElement);
this._dataGrid = null;
this.deleteButton.addStyleClass("hidden");
}
},
_deleteButtonClicked: function(event)
{
if (this._dataGrid) {
this._dataGrid.deleteSelectedRow();
this.show();
}
},
_refreshButtonClicked: function(event)
{
this.update();
}
}
WebInspector.DOMStorageItemsView.prototype.__proto__ = WebInspector.View.prototype;