WebInspector.SidebarPane = function(title)
{
WebInspector.View.call(this);
this.element.className = "sidebar-pane";
this.titleElement = document.createElement("div");
this.titleElement.className = "sidebar-pane-toolbar";
this.bodyElement = this.element.createChild("div", "body");
this._title = title;
this._expandCallback = null;
}
WebInspector.SidebarPane.EventTypes = {
wasShown: "wasShown"
}
WebInspector.SidebarPane.prototype = {
title: function()
{
return this._title;
},
prepareContent: function(callback)
{
if (callback)
callback();
},
expand: function()
{
this.prepareContent(this.onContentReady.bind(this));
},
onContentReady: function()
{
if (this._expandCallback)
this._expandCallback();
else
this._expandPending = true;
},
setExpandCallback: function(callback)
{
this._expandCallback = callback;
if (this._expandPending) {
delete this._expandPending;
this._expandCallback();
}
},
wasShown: function()
{
WebInspector.View.prototype.wasShown.call(this);
this.dispatchEventToListeners(WebInspector.SidebarPane.EventTypes.wasShown);
},
__proto__: WebInspector.View.prototype
}
WebInspector.SidebarPaneTitle = function(container, pane)
{
this._pane = pane;
this.element = container.createChild("div", "sidebar-pane-title");
this.element.textContent = pane.title();
this.element.tabIndex = 0;
this.element.addEventListener("click", this._toggleExpanded.bind(this), false);
this.element.addEventListener("keydown", this._onTitleKeyDown.bind(this), false);
this.element.appendChild(this._pane.titleElement);
this._pane.setExpandCallback(this._expand.bind(this));
}
WebInspector.SidebarPaneTitle.prototype = {
_expand: function()
{
this.element.addStyleClass("expanded");
this._pane.show(this.element.parentNode, this.element.nextSibling);
},
_collapse: function()
{
this.element.removeStyleClass("expanded");
if (this._pane.element.parentNode == this.element.parentNode)
this._pane.detach();
},
_toggleExpanded: function()
{
if (this.element.hasStyleClass("expanded"))
this._collapse();
else
this._pane.expand();
},
_onTitleKeyDown: function(event)
{
if (isEnterKey(event) || event.keyCode === WebInspector.KeyboardShortcut.Keys.Space.code)
this._toggleExpanded();
}
}
WebInspector.SidebarPaneStack = function()
{
WebInspector.View.call(this);
this.element.className = "sidebar-pane-stack fill";
this.registerRequiredCSS("sidebarPane.css");
}
WebInspector.SidebarPaneStack.prototype = {
addPane: function(pane)
{
new WebInspector.SidebarPaneTitle(this.element, pane);
},
__proto__: WebInspector.View.prototype
}
WebInspector.SidebarTabbedPane = function()
{
WebInspector.TabbedPane.call(this);
this.element.addStyleClass("sidebar-tabbed-pane");
this.registerRequiredCSS("sidebarPane.css");
}
WebInspector.SidebarTabbedPane.prototype = {
addPane: function(pane)
{
var title = pane.title();
this.appendTab(title, title, pane);
pane.element.appendChild(pane.titleElement);
pane.setExpandCallback(this.selectTab.bind(this, title));
},
__proto__: WebInspector.TabbedPane.prototype
}