2 * Copyright (C) 2007, 2008 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.
30 * @extends {WebInspector.View}
33 WebInspector.Panel = function(name)
35 WebInspector.View.call(this);
37 this.element.addStyleClass("panel");
38 this.element.addStyleClass(name);
39 this._panelName = name;
43 WebInspector.settings[this._sidebarWidthSettingName()] = WebInspector.settings.createSetting(this._sidebarWidthSettingName(), undefined);
46 // Should by in sync with style declarations.
47 WebInspector.Panel.counterRightMargin = 25;
49 WebInspector.Panel.prototype = {
52 if (this._toolbarItem)
53 return this._toolbarItem;
55 this._toolbarItem = WebInspector.Toolbar.createPanelToolbarItem(this);
56 return this._toolbarItem;
61 return this._panelName;
66 WebInspector.View.prototype.show.call(this, WebInspector.inspectorView.element);
71 var statusBarItems = this.statusBarItems;
73 this._statusBarItemContainer = document.createElement("div");
74 for (var i = 0; i < statusBarItems.length; ++i)
75 this._statusBarItemContainer.appendChild(statusBarItems[i]);
76 document.getElementById("main-status-bar").appendChild(this._statusBarItemContainer);
79 if ("_toolbarItem" in this)
80 this._toolbarItem.addStyleClass("toggled-on");
82 WebInspector.setCurrentFocusElement(this.defaultFocusedElement);
87 if (this._statusBarItemContainer && this._statusBarItemContainer.parentNode)
88 this._statusBarItemContainer.parentNode.removeChild(this._statusBarItemContainer);
89 delete this._statusBarItemContainer;
90 if ("_toolbarItem" in this)
91 this._toolbarItem.removeStyleClass("toggled-on");
96 this.searchCanceled();
99 get defaultFocusedElement()
101 return this.sidebarTreeElement || this.element;
104 searchCanceled: function()
106 WebInspector.searchController.updateSearchMatchesCount(0, this);
109 performSearch: function(query)
111 // Call searchCanceled since it will reset everything we need before doing a new search.
112 this.searchCanceled();
115 jumpToNextSearchResult: function()
119 jumpToPreviousSearchResult: function()
124 * @param {Element=} parentElement
125 * @param {string=} position
126 * @param {number=} defaultWidth
128 createSplitView: function(parentElement, position, defaultWidth)
134 parentElement = this.element;
136 this.splitView = new WebInspector.SplitView(position || WebInspector.SplitView.SidebarPosition.Left, this._sidebarWidthSettingName(), defaultWidth);
137 this.splitView.show(parentElement);
138 this.splitView.addEventListener(WebInspector.SplitView.EventTypes.Resized, this.sidebarResized.bind(this));
140 this.sidebarElement = this.splitView.sidebarElement;
144 * @param {Element=} parentElement
145 * @param {string=} position
146 * @param {number=} defaultWidth
148 createSplitViewWithSidebarTree: function(parentElement, position, defaultWidth)
153 this.createSplitView(parentElement, position);
155 this.sidebarTreeElement = document.createElement("ol");
156 this.sidebarTreeElement.className = "sidebar-tree";
157 this.splitView.sidebarElement.appendChild(this.sidebarTreeElement);
158 this.splitView.sidebarElement.addStyleClass("sidebar");
160 this.sidebarTree = new TreeOutline(this.sidebarTreeElement);
161 this.sidebarTree.panel = this;
164 _sidebarWidthSettingName: function()
166 return this._panelName + "SidebarWidth";
169 // Should be implemented by ancestors.
171 get toolbarItemLabel()
179 sidebarResized: function(width)
183 statusBarResized: function()
187 canShowAnchorLocation: function(anchor)
192 showAnchorLocation: function(anchor)
197 elementsToRestoreScrollPositionsFor: function()
202 handleShortcut: function(event)
204 var shortcutKey = WebInspector.KeyboardShortcut.makeKeyFromEvent(event);
205 var handler = this._shortcuts[shortcutKey];
208 event.handled = true;
212 registerShortcut: function(key, handler)
214 this._shortcuts[key] = handler;
218 WebInspector.Panel.prototype.__proto__ = WebInspector.View.prototype;