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 this._childrenListNode.classList.toggle("small", this._smallChildren);
61 this.listItemElement.classList.add("sidebar-tree-section");
66 if (this.listItemElement)
67 this.listItemElement.scrollIntoViewIfNeeded(false);
70 __proto__: TreeElement.prototype
75 * @extends {TreeElement}
76 * @param {string} className
77 * @param {string} title
78 * @param {string=} subtitle
79 * @param {?Object=} representedObject
80 * @param {boolean=} hasChildren
82 WebInspector.SidebarTreeElement = function(className, title, subtitle, representedObject, hasChildren)
84 TreeElement.call(this, "", representedObject, hasChildren);
87 this.disclosureButton = createElementWithClass("button", "disclosure-button");
89 this.iconElement = createElementWithClass("div", "icon");
90 this.statusElement = createElementWithClass("div", "status");
91 this.titlesElement = createElementWithClass("div", "titles");
93 this.titleContainer = this.titlesElement.createChild("span", "title-container");
94 this.titleElement = this.titleContainer.createChild("span", "title");
96 this.subtitleElement = this.titlesElement.createChild("span", "subtitle");
98 this.className = className;
99 this.mainTitle = title;
100 this.subtitle = subtitle;
103 WebInspector.SidebarTreeElement.prototype = {
112 if (this.listItemElement)
113 this.listItemElement.classList.toggle("small", this._small);
118 return this._mainTitle;
124 this.refreshTitles();
129 return this._subtitle;
135 this.refreshTitles();
140 this.listItemElement.classList.toggle("wait", x);
143 refreshTitles: function()
145 var mainTitle = this.mainTitle;
146 if (this.titleElement.textContent !== mainTitle)
147 this.titleElement.textContent = mainTitle;
149 var subtitle = this.subtitle;
151 if (this.subtitleElement.textContent !== subtitle)
152 this.subtitleElement.textContent = subtitle;
153 this.titlesElement.classList.remove("no-subtitle");
155 this.subtitleElement.textContent = "";
156 this.titlesElement.classList.add("no-subtitle");
163 isEventWithinDisclosureTriangle: function(event)
165 return event.target === this.disclosureButton;
170 this.listItemElement.classList.add("sidebar-tree-item");
173 this.listItemElement.classList.add(this.className);
176 this.listItemElement.classList.add("small");
178 if (this.hasChildren && this.disclosureButton)
179 this.listItemElement.appendChild(this.disclosureButton);
181 this.listItemElement.appendChildren(this.iconElement, this.statusElement, this.titlesElement);
186 if (this.listItemElement)
187 this.listItemElement.scrollIntoViewIfNeeded(false);
190 __proto__: TreeElement.prototype