PropertiesSection.js [plain text]
WebInspector.PropertiesSection = function(title, subtitle)
{
this.element = document.createElement("div");
this.element.className = "section";
this.headerElement = document.createElement("div");
this.headerElement.className = "header";
this.titleElement = document.createElement("div");
this.titleElement.className = "title";
this.subtitleElement = document.createElement("div");
this.subtitleElement.className = "subtitle";
this.headerElement.appendChild(this.titleElement);
this.headerElement.appendChild(this.subtitleElement);
this.headerElement.addEventListener("click", this.toggleExpanded.bind(this), false);
this.propertiesElement = document.createElement("ol");
this.propertiesElement.className = "properties";
this.propertiesTreeOutline = new TreeOutline(this.propertiesElement);
this.propertiesTreeOutline.section = this;
this.element.appendChild(this.headerElement);
this.element.appendChild(this.propertiesElement);
this.title = title;
this.subtitle = subtitle;
this.expanded = false;
}
WebInspector.PropertiesSection.prototype = {
get title()
{
return this._title;
},
set title(x)
{
if (this._title === x)
return;
this._title = x;
this.titleElement.textContent = x;
},
get subtitle()
{
return this._subtitle;
},
set subtitle(x)
{
if (this._subtitle === x)
return;
this._subtitle = x;
this.subtitleElement.innerHTML = x;
},
get expanded()
{
return this._expanded;
},
set expanded(x)
{
if (x)
this.expand();
else
this.collapse();
},
get populated()
{
return this._populated;
},
set populated(x)
{
this._populated = x;
if (!x && this.onpopulate && this._expanded) {
this.onpopulate(this);
this._populated = true;
}
},
expand: function()
{
if (this._expanded)
return;
this._expanded = true;
this.element.addStyleClass("expanded");
if (!this._populated && this.onpopulate) {
this.onpopulate(this);
this._populated = true;
}
},
collapse: function()
{
if (!this._expanded)
return;
this._expanded = false;
this.element.removeStyleClass("expanded");
},
toggleExpanded: function()
{
this.expanded = !this.expanded;
}
}