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);
36 WebInspector.SidebarSectionTreeElement.prototype = {
41 // Should not collapse as it is not selectable.
46 return this._smallChildren;
51 if (this._smallChildren === x)
54 this._smallChildren = x;
56 if (this._smallChildren)
57 this._childrenListNode.classList.add("small");
59 this._childrenListNode.classList.remove("small");
64 this._listItemNode.classList.add("sidebar-tree-section");
69 if (this.listItemElement)
70 this.listItemElement.scrollIntoViewIfNeeded(false);
73 __proto__: TreeElement.prototype
78 * @extends {TreeElement}
79 * @param {string} className
80 * @param {string} title
81 * @param {string=} subtitle
82 * @param {?Object=} representedObject
83 * @param {boolean=} hasChildren
85 WebInspector.SidebarTreeElement = function(className, title, subtitle, representedObject, hasChildren)
87 TreeElement.call(this, "", representedObject, hasChildren);
90 this.disclosureButton = document.createElement("button");
91 this.disclosureButton.className = "disclosure-button";
94 this.iconElement = document.createElementWithClass("img", "icon");
95 this.statusElement = document.createElementWithClass("div", "status");
96 this.titlesElement = document.createElementWithClass("div", "titles");
98 this.titleContainer = this.titlesElement.createChild("span", "title-container");
99 this.titleElement = this.titleContainer.createChild("span", "title");
101 this.subtitleElement = this.titlesElement.createChild("span", "subtitle");
103 this.className = className;
104 this.mainTitle = title;
105 this.subtitle = subtitle;
108 WebInspector.SidebarTreeElement.prototype = {
118 if (this._listItemNode) {
120 this._listItemNode.classList.add("small");
122 this._listItemNode.classList.remove("small");
128 return this._mainTitle;
134 this.refreshTitles();
139 return this._subtitle;
145 this.refreshTitles();
151 this._listItemNode.classList.add("wait");
153 this._listItemNode.classList.remove("wait");
156 refreshTitles: function()
158 var mainTitle = this.mainTitle;
159 if (this.titleElement.textContent !== mainTitle)
160 this.titleElement.textContent = mainTitle;
162 var subtitle = this.subtitle;
164 if (this.subtitleElement.textContent !== subtitle)
165 this.subtitleElement.textContent = subtitle;
166 this.titlesElement.classList.remove("no-subtitle");
168 this.subtitleElement.textContent = "";
169 this.titlesElement.classList.add("no-subtitle");
176 isEventWithinDisclosureTriangle: function(event)
178 return event.target === this.disclosureButton;
183 this._listItemNode.classList.add("sidebar-tree-item");
186 this._listItemNode.classList.add(this.className);
189 this._listItemNode.classList.add("small");
191 if (this.hasChildren && this.disclosureButton)
192 this._listItemNode.appendChild(this.disclosureButton);
194 this._listItemNode.appendChild(this.iconElement);
195 this._listItemNode.appendChild(this.statusElement);
196 this._listItemNode.appendChild(this.titlesElement);
201 if (this._listItemNode)
202 this._listItemNode.scrollIntoViewIfNeeded(false);
205 __proto__: TreeElement.prototype