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}
29 * @param {string} title
31 WebInspector
.SidebarSectionTreeElement = function(title
)
33 TreeElement
.call(this, title
.escapeHTML(), true);
37 WebInspector
.SidebarSectionTreeElement
.prototype = {
42 // Should not collapse as it is not selectable.
47 return this._smallChildren
;
52 if (this._smallChildren
=== x
)
55 this._smallChildren
= x
;
57 this._childrenListNode
.classList
.toggle("small", this._smallChildren
);
62 this.listItemElement
.classList
.add("sidebar-tree-section");
67 if (this.listItemElement
)
68 this.listItemElement
.scrollIntoViewIfNeeded(false);
71 __proto__
: TreeElement
.prototype
76 * @extends {TreeElement}
77 * @param {string} className
78 * @param {string} title
79 * @param {string=} subtitle
80 * @param {boolean=} expandable
82 WebInspector
.SidebarTreeElement = function(className
, title
, subtitle
, expandable
)
84 TreeElement
.call(this, "", expandable
);
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");
164 isEventWithinDisclosureTriangle: function(event
)
166 return event
.target
=== this.disclosureButton
;
171 this.listItemElement
.classList
.add("sidebar-tree-item");
174 this.listItemElement
.classList
.add(this.className
);
177 this.listItemElement
.classList
.add("small");
179 if (this.isExpandable() && this.disclosureButton
)
180 this.listItemElement
.appendChild(this.disclosureButton
);
182 this.listItemElement
.appendChildren(this.iconElement
, this.statusElement
, this.titlesElement
);
187 if (this.listItemElement
)
188 this.listItemElement
.scrollIntoViewIfNeeded(false);
191 __proto__
: TreeElement
.prototype