2 * Copyright (C) 2007 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * @extends {WebInspector.View}
33 WebInspector.SidebarPane = function(title)
35 WebInspector.View.call(this);
36 this.setMinimumSize(25, 0);
37 this.element.className = "sidebar-pane"; // Override
39 this.titleElement = document.createElementWithClass("div", "sidebar-pane-toolbar");
40 this.bodyElement = this.element.createChild("div", "body");
42 this._expandCallback = null;
45 WebInspector.SidebarPane.EventTypes = {
49 WebInspector.SidebarPane.prototype = {
59 * @param {function()} callback
61 prepareContent: function(callback)
69 this.prepareContent(this.onContentReady.bind(this));
72 onContentReady: function()
74 if (this._expandCallback)
75 this._expandCallback();
77 this._expandPending = true;
81 * @param {function()} callback
83 setExpandCallback: function(callback)
85 this._expandCallback = callback;
86 if (this._expandPending) {
87 delete this._expandPending;
88 this._expandCallback();
94 WebInspector.View.prototype.wasShown.call(this);
95 this.dispatchEventToListeners(WebInspector.SidebarPane.EventTypes.wasShown);
98 __proto__: WebInspector.View.prototype
103 * @param {!Element} container
104 * @param {!WebInspector.SidebarPane} pane
106 WebInspector.SidebarPaneTitle = function(container, pane)
110 this.element = container.createChild("div", "sidebar-pane-title");
111 this.element.textContent = pane.title();
112 this.element.tabIndex = 0;
113 this.element.addEventListener("click", this._toggleExpanded.bind(this), false);
114 this.element.addEventListener("keydown", this._onTitleKeyDown.bind(this), false);
115 this.element.appendChild(this._pane.titleElement);
117 this._pane.setExpandCallback(this._expand.bind(this));
120 WebInspector.SidebarPaneTitle.prototype = {
124 this.element.classList.add("expanded");
125 this._pane.show(this.element.parentElement, /** @type {?Element} */ (this.element.nextSibling));
128 _collapse: function()
130 this.element.classList.remove("expanded");
131 if (this._pane.element.parentNode == this.element.parentNode)
135 _toggleExpanded: function()
137 if (this.element.classList.contains("expanded"))
144 * @param {!Event} event
146 _onTitleKeyDown: function(event)
148 if (isEnterKey(event) || event.keyCode === WebInspector.KeyboardShortcut.Keys.Space.code)
149 this._toggleExpanded();
155 * @extends {WebInspector.View}
157 WebInspector.SidebarPaneStack = function()
159 WebInspector.View.call(this);
160 this.setMinimumSize(25, 0);
161 this.element.className = "sidebar-pane-stack"; // Override
162 /** @type {!Map.<!WebInspector.SidebarPane, !WebInspector.SidebarPaneTitle>} */
163 this._titleByPane = new Map();
166 WebInspector.SidebarPaneStack.prototype = {
168 * @param {!WebInspector.SidebarPane} pane
170 addPane: function(pane)
172 this._titleByPane.put(pane, new WebInspector.SidebarPaneTitle(this.element, pane));
176 * @param {!WebInspector.SidebarPane} pane
177 * @param {boolean} hide
179 togglePaneHidden: function(pane, hide)
181 var title = this._titleByPane.get(pane);
185 title.element.classList.toggle("hidden", hide);
186 pane.element.classList.toggle("hidden", hide);
189 __proto__: WebInspector.View.prototype
194 * @extends {WebInspector.TabbedPane}
196 WebInspector.SidebarTabbedPane = function()
198 WebInspector.TabbedPane.call(this);
199 this.setRetainTabOrder(true);
200 this.element.classList.add("sidebar-tabbed-pane");
203 WebInspector.SidebarTabbedPane.prototype = {
205 * @param {!WebInspector.SidebarPane} pane
207 addPane: function(pane)
209 var title = pane.title();
210 this.appendTab(title, title, pane);
211 pane.element.appendChild(pane.titleElement);
212 pane.setExpandCallback(this.selectTab.bind(this, title));
216 __proto__: WebInspector.TabbedPane.prototype