OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 19 matching lines...) Expand all Loading... |
30 * @constructor | 30 * @constructor |
31 * @extends {WebInspector.Widget} | 31 * @extends {WebInspector.Widget} |
32 * @param {string} title | 32 * @param {string} title |
33 */ | 33 */ |
34 WebInspector.SidebarPane = function(title) | 34 WebInspector.SidebarPane = function(title) |
35 { | 35 { |
36 WebInspector.Widget.call(this); | 36 WebInspector.Widget.call(this); |
37 this.setMinimumSize(25, 0); | 37 this.setMinimumSize(25, 0); |
38 this.element.className = "sidebar-pane"; // Override | 38 this.element.className = "sidebar-pane"; // Override |
39 | 39 |
40 this.titleElement = createElementWithClass("div", "sidebar-pane-toolbar"); | |
41 this.bodyElement = this.element.createChild("div", "body"); | |
42 this._title = title; | 40 this._title = title; |
43 this._expandCallback = null; | 41 this._expandCallback = null; |
44 this._paneVisible = true; | 42 this._paneVisible = true; |
45 } | 43 } |
46 | 44 |
47 WebInspector.SidebarPane.prototype = { | 45 WebInspector.SidebarPane.prototype = { |
48 /** | 46 /** |
| 47 * @return {!WebInspector.Toolbar} |
| 48 */ |
| 49 toolbar: function() |
| 50 { |
| 51 if (!this._toolbar) { |
| 52 this._toolbar = new WebInspector.Toolbar(); |
| 53 this._toolbar.element.addEventListener("click", consumeEvent); |
| 54 this.element.insertBefore(this._toolbar.element, this.element.firstC
hild); |
| 55 } |
| 56 return this._toolbar; |
| 57 }, |
| 58 |
| 59 /** |
49 * @return {string} | 60 * @return {string} |
50 */ | 61 */ |
51 title: function() | 62 title: function() |
52 { | 63 { |
53 return this._title; | 64 return this._title; |
54 }, | 65 }, |
55 | 66 |
56 expand: function() | 67 expand: function() |
57 { | 68 { |
58 this.onContentReady(); | 69 this.onContentReady(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 */ | 113 */ |
103 WebInspector.SidebarPaneTitle = function(container, pane) | 114 WebInspector.SidebarPaneTitle = function(container, pane) |
104 { | 115 { |
105 this._pane = pane; | 116 this._pane = pane; |
106 | 117 |
107 this.element = container.createChild("div", "sidebar-pane-title"); | 118 this.element = container.createChild("div", "sidebar-pane-title"); |
108 this.element.textContent = pane.title(); | 119 this.element.textContent = pane.title(); |
109 this.element.tabIndex = 0; | 120 this.element.tabIndex = 0; |
110 this.element.addEventListener("click", this._toggleExpanded.bind(this), fals
e); | 121 this.element.addEventListener("click", this._toggleExpanded.bind(this), fals
e); |
111 this.element.addEventListener("keydown", this._onTitleKeyDown.bind(this), fa
lse); | 122 this.element.addEventListener("keydown", this._onTitleKeyDown.bind(this), fa
lse); |
112 this.element.appendChild(this._pane.titleElement); | |
113 } | 123 } |
114 | 124 |
115 WebInspector.SidebarPaneTitle.prototype = { | 125 WebInspector.SidebarPaneTitle.prototype = { |
116 _expand: function() | 126 _expand: function() |
117 { | 127 { |
118 this.element.classList.add("expanded"); | 128 this.element.classList.add("expanded"); |
119 this._pane.show(this.element.parentElement, /** @type {?Element} */ (thi
s.element.nextSibling)); | 129 this._pane.show(this.element.parentElement, /** @type {?Element} */ (thi
s.element.nextSibling)); |
120 }, | 130 }, |
121 | 131 |
122 _collapse: function() | 132 _collapse: function() |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 168 } |
159 | 169 |
160 WebInspector.SidebarPaneStack.prototype = { | 170 WebInspector.SidebarPaneStack.prototype = { |
161 /** | 171 /** |
162 * @param {!WebInspector.SidebarPane} pane | 172 * @param {!WebInspector.SidebarPane} pane |
163 */ | 173 */ |
164 addPane: function(pane) | 174 addPane: function(pane) |
165 { | 175 { |
166 var paneTitle = new WebInspector.SidebarPaneTitle(this.element, pane); | 176 var paneTitle = new WebInspector.SidebarPaneTitle(this.element, pane); |
167 this._titleByPane.set(pane, paneTitle); | 177 this._titleByPane.set(pane, paneTitle); |
| 178 if (pane._toolbar) |
| 179 paneTitle.element.appendChild(pane._toolbar.element); |
168 pane._attached(this._setPaneVisible.bind(this, pane), paneTitle._expand.
bind(paneTitle)); | 180 pane._attached(this._setPaneVisible.bind(this, pane), paneTitle._expand.
bind(paneTitle)); |
169 }, | 181 }, |
170 | 182 |
171 /** | 183 /** |
172 * @param {!WebInspector.SidebarPane} pane | 184 * @param {!WebInspector.SidebarPane} pane |
173 * @param {boolean} visible | 185 * @param {boolean} visible |
174 */ | 186 */ |
175 _setPaneVisible: function(pane, visible) | 187 _setPaneVisible: function(pane, visible) |
176 { | 188 { |
177 var title = this._titleByPane.get(pane); | 189 var title = this._titleByPane.get(pane); |
(...skipping 19 matching lines...) Expand all Loading... |
197 } | 209 } |
198 | 210 |
199 WebInspector.SidebarTabbedPane.prototype = { | 211 WebInspector.SidebarTabbedPane.prototype = { |
200 /** | 212 /** |
201 * @param {!WebInspector.SidebarPane} pane | 213 * @param {!WebInspector.SidebarPane} pane |
202 */ | 214 */ |
203 addPane: function(pane) | 215 addPane: function(pane) |
204 { | 216 { |
205 var title = pane.title(); | 217 var title = pane.title(); |
206 this.appendTab(title, title, pane); | 218 this.appendTab(title, title, pane); |
207 pane.element.appendChild(pane.titleElement); | 219 if (pane._toolbar) |
| 220 pane.element.insertBefore(pane._toolbar.element, pane.element.firstC
hild); |
208 pane._attached(this._setPaneVisible.bind(this, pane), this.selectTab.bin
d(this, title)); | 221 pane._attached(this._setPaneVisible.bind(this, pane), this.selectTab.bin
d(this, title)); |
209 }, | 222 }, |
210 | 223 |
211 /** | 224 /** |
212 * @param {!WebInspector.SidebarPane} pane | 225 * @param {!WebInspector.SidebarPane} pane |
213 * @param {boolean} visible | 226 * @param {boolean} visible |
214 */ | 227 */ |
215 _setPaneVisible: function(pane, visible) | 228 _setPaneVisible: function(pane, visible) |
216 { | 229 { |
217 var title = pane._title; | 230 var title = pane._title; |
218 if (visible) { | 231 if (visible) { |
219 if (!this.hasTab(title)) | 232 if (!this.hasTab(title)) |
220 this.appendTab(title, title, pane); | 233 this.appendTab(title, title, pane); |
221 } else { | 234 } else { |
222 if (this.hasTab(title)) | 235 if (this.hasTab(title)) |
223 this.closeTab(title); | 236 this.closeTab(title); |
224 } | 237 } |
225 }, | 238 }, |
226 | 239 |
227 __proto__: WebInspector.TabbedPane.prototype | 240 __proto__: WebInspector.TabbedPane.prototype |
228 } | 241 } |
OLD | NEW |