2 * Copyright (C) 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
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * @extends {TreeElement}
30 WebInspector.SidebarSectionTreeElement = function(title, representedObject, hasChildren)
32 TreeElement.call(this, title.escapeHTML(), representedObject || {}, hasChildren);
35 WebInspector.SidebarSectionTreeElement.prototype = {
40 return this._smallChildren;
45 if (this._smallChildren === x)
48 this._smallChildren = x;
50 if (this._smallChildren)
51 this._childrenListNode.addStyleClass("small");
53 this._childrenListNode.removeStyleClass("small");
58 this._listItemNode.addStyleClass("sidebar-tree-section");
63 if (this.listItemElement)
64 this.listItemElement.scrollIntoViewIfNeeded(false);
68 WebInspector.SidebarSectionTreeElement.prototype.__proto__ = TreeElement.prototype;
72 * @extends {TreeElement}
73 * @param {string=} subtitle
74 * @param {Object=} representedObject
75 * @param {boolean=} hasChildren
77 WebInspector.SidebarTreeElement = function(className, title, subtitle, representedObject, hasChildren)
79 TreeElement.call(this, "", representedObject, hasChildren);
82 this.disclosureButton = document.createElement("button");
83 this.disclosureButton.className = "disclosure-button";
86 if (!this.iconElement) {
87 this.iconElement = document.createElement("img");
88 this.iconElement.className = "icon";
91 this.statusElement = document.createElement("div");
92 this.statusElement.className = "status";
94 this.titlesElement = document.createElement("div");
95 this.titlesElement.className = "titles";
97 this.titleElement = document.createElement("span");
98 this.titleElement.className = "title";
99 this.titlesElement.appendChild(this.titleElement);
101 this.subtitleElement = document.createElement("span");
102 this.subtitleElement.className = "subtitle";
103 this.titlesElement.appendChild(this.subtitleElement);
105 this.className = className;
106 this.mainTitle = title;
107 this.subtitle = subtitle;
110 WebInspector.SidebarTreeElement.prototype = {
120 if (this._listItemNode) {
122 this._listItemNode.addStyleClass("small");
124 this._listItemNode.removeStyleClass("small");
130 return this._mainTitle;
136 this.refreshTitles();
141 return this._subtitle;
147 this.refreshTitles();
152 return this._bubbleText;
157 if (!this.bubbleElement) {
158 this.bubbleElement = document.createElement("div");
159 this.bubbleElement.className = "bubble";
160 this.statusElement.appendChild(this.bubbleElement);
163 this._bubbleText = x;
164 this.bubbleElement.textContent = x;
170 this._listItemNode.addStyleClass("wait");
172 this._listItemNode.removeStyleClass("wait");
175 refreshTitles: function()
177 var mainTitle = this.mainTitle;
178 if (this.titleElement.textContent !== mainTitle)
179 this.titleElement.textContent = mainTitle;
181 var subtitle = this.subtitle;
183 if (this.subtitleElement.textContent !== subtitle)
184 this.subtitleElement.textContent = subtitle;
185 this.titlesElement.removeStyleClass("no-subtitle");
187 this.subtitleElement.textContent = "";
188 this.titlesElement.addStyleClass("no-subtitle");
192 isEventWithinDisclosureTriangle: function(event)
194 return event.target === this.disclosureButton;
199 this._listItemNode.addStyleClass("sidebar-tree-item");
202 this._listItemNode.addStyleClass(this.className);
205 this._listItemNode.addStyleClass("small");
207 if (this.hasChildren && this.disclosureButton)
208 this._listItemNode.appendChild(this.disclosureButton);
210 this._listItemNode.appendChild(this.iconElement);
211 this._listItemNode.appendChild(this.statusElement);
212 this._listItemNode.appendChild(this.titlesElement);
217 if (this._listItemNode)
218 this._listItemNode.scrollIntoViewIfNeeded(false);
222 WebInspector.SidebarTreeElement.prototype.__proto__ = TreeElement.prototype;