summaryrefslogtreecommitdiffstats
path: root/WebCore/inspector/front-end/TabbedPane.js
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/inspector/front-end/TabbedPane.js')
-rw-r--r--WebCore/inspector/front-end/TabbedPane.js68
1 files changed, 40 insertions, 28 deletions
diff --git a/WebCore/inspector/front-end/TabbedPane.js b/WebCore/inspector/front-end/TabbedPane.js
index dec3a0b..1ed9725 100644
--- a/WebCore/inspector/front-end/TabbedPane.js
+++ b/WebCore/inspector/front-end/TabbedPane.js
@@ -31,51 +31,63 @@
WebInspector.TabbedPane = function(element)
{
this.element = element || document.createElement("div");
-
- this.tabsElement = document.createElement("div");
- this.tabsElement.className = "tabbed-pane-header";
- this.element.appendChild(this.tabsElement);
+ this.element.addStyleClass("tabbed-pane");
+ this.tabsElement = this.element.createChild("div", "tabbed-pane-header");
+ this.contentElement = this.element.createChild("div", "tabbed-pane-content");
this._tabObjects = {};
}
WebInspector.TabbedPane.prototype = {
- appendTab: function(id, tabTitle, contentElement, tabClickListener)
+ appendTab: function(id, tabTitle, content, tabClickListener)
{
var tabElement = document.createElement("li");
tabElement.textContent = tabTitle;
tabElement.addEventListener("click", tabClickListener, false);
this.tabsElement.appendChild(tabElement);
- this.element.appendChild(contentElement);
- this._tabObjects[id] = {tab: tabElement, content: contentElement};
+ var tabObject = { tab: tabElement };
+ if (content instanceof HTMLElement) {
+ tabObject.element = content;
+ this.contentElement.appendChild(content);
+ }
+ else {
+ this.contentElement.appendChild(content.element);
+ tabObject.view = content;
+ }
+ this._tabObjects[id] = tabObject;
+ },
+
+ hasTab: function(tabId)
+ {
+ return tabId in this._tabObjects;
},
-
- tabObjectForId: function(id)
+
+ selectTabById: function(tabId)
{
- return this._tabObjects[id];
+ for (var id in this._tabObjects) {
+ if (id === tabId)
+ this._showTab(this._tabObjects[id]);
+ else
+ this._hideTab(this._tabObjects[id]);
+ }
+ return this.hasTab(tabId);
},
- hideTab: function(id)
+ _showTab: function(tabObject)
{
- var tabObject = this._tabObjects[id];
- if (tabObject)
- tabObject.tab.addStyleClass("hidden");
+ tabObject.tab.addStyleClass("selected");
+ if (tabObject.element)
+ tabObject.element.removeStyleClass("hidden");
+ else
+ tabObject.view.visible = true;
},
- selectTabById: function(selectId)
+ _hideTab: function(tabObject)
{
- var selected = false;
- for (var id in this._tabObjects) {
- var tabObject = this._tabObjects[id];
- if (id === selectId) {
- selected = true;
- tabObject.tab.addStyleClass("selected");
- tabObject.content.removeStyleClass("hidden");
- } else {
- tabObject.tab.removeStyleClass("selected");
- tabObject.content.addStyleClass("hidden");
- }
- }
- return selected;
+ tabObject.tab.removeStyleClass("selected");
+ if (tabObject.element)
+ tabObject.element.addStyleClass("hidden");
+ else
+ tabObject.view.visible = false;
}
}