| 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(undefined, true); |
| 53 this._toolbar.element.addEventListener("click", consumeEvent); |
| 54 this._toolbar.element.classList.add("sidebar-pane-toolbar"); |
| 55 this.element.insertBefore(this._toolbar.element, this.element.firstC
hild); |
| 56 } |
| 57 return this._toolbar; |
| 58 }, |
| 59 |
| 60 /** |
| 49 * @return {string} | 61 * @return {string} |
| 50 */ | 62 */ |
| 51 title: function() | 63 title: function() |
| 52 { | 64 { |
| 53 return this._title; | 65 return this._title; |
| 54 }, | 66 }, |
| 55 | 67 |
| 56 expand: function() | 68 expand: function() |
| 57 { | 69 { |
| 58 this.onContentReady(); | 70 this.onContentReady(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 */ | 114 */ |
| 103 WebInspector.SidebarPaneTitle = function(container, pane) | 115 WebInspector.SidebarPaneTitle = function(container, pane) |
| 104 { | 116 { |
| 105 this._pane = pane; | 117 this._pane = pane; |
| 106 | 118 |
| 107 this.element = container.createChild("div", "sidebar-pane-title"); | 119 this.element = container.createChild("div", "sidebar-pane-title"); |
| 108 this.element.textContent = pane.title(); | 120 this.element.textContent = pane.title(); |
| 109 this.element.tabIndex = 0; | 121 this.element.tabIndex = 0; |
| 110 this.element.addEventListener("click", this._toggleExpanded.bind(this), fals
e); | 122 this.element.addEventListener("click", this._toggleExpanded.bind(this), fals
e); |
| 111 this.element.addEventListener("keydown", this._onTitleKeyDown.bind(this), fa
lse); | 123 this.element.addEventListener("keydown", this._onTitleKeyDown.bind(this), fa
lse); |
| 112 this.element.appendChild(this._pane.titleElement); | |
| 113 } | 124 } |
| 114 | 125 |
| 115 WebInspector.SidebarPaneTitle.prototype = { | 126 WebInspector.SidebarPaneTitle.prototype = { |
| 116 _expand: function() | 127 _expand: function() |
| 117 { | 128 { |
| 118 this.element.classList.add("expanded"); | 129 this.element.classList.add("expanded"); |
| 119 this._pane.show(this.element.parentElement, /** @type {?Element} */ (thi
s.element.nextSibling)); | 130 this._pane.show(this.element.parentElement, /** @type {?Element} */ (thi
s.element.nextSibling)); |
| 120 }, | 131 }, |
| 121 | 132 |
| 122 _collapse: function() | 133 _collapse: function() |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 169 } |
| 159 | 170 |
| 160 WebInspector.SidebarPaneStack.prototype = { | 171 WebInspector.SidebarPaneStack.prototype = { |
| 161 /** | 172 /** |
| 162 * @param {!WebInspector.SidebarPane} pane | 173 * @param {!WebInspector.SidebarPane} pane |
| 163 */ | 174 */ |
| 164 addPane: function(pane) | 175 addPane: function(pane) |
| 165 { | 176 { |
| 166 var paneTitle = new WebInspector.SidebarPaneTitle(this.element, pane); | 177 var paneTitle = new WebInspector.SidebarPaneTitle(this.element, pane); |
| 167 this._titleByPane.set(pane, paneTitle); | 178 this._titleByPane.set(pane, paneTitle); |
| 179 if (pane._toolbar) |
| 180 paneTitle.element.appendChild(pane._toolbar.element); |
| 168 pane._attached(this._setPaneVisible.bind(this, pane), paneTitle._expand.
bind(paneTitle)); | 181 pane._attached(this._setPaneVisible.bind(this, pane), paneTitle._expand.
bind(paneTitle)); |
| 169 }, | 182 }, |
| 170 | 183 |
| 171 /** | 184 /** |
| 172 * @param {!WebInspector.SidebarPane} pane | 185 * @param {!WebInspector.SidebarPane} pane |
| 173 * @param {boolean} visible | 186 * @param {boolean} visible |
| 174 */ | 187 */ |
| 175 _setPaneVisible: function(pane, visible) | 188 _setPaneVisible: function(pane, visible) |
| 176 { | 189 { |
| 177 var title = this._titleByPane.get(pane); | 190 var title = this._titleByPane.get(pane); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 197 } | 210 } |
| 198 | 211 |
| 199 WebInspector.SidebarTabbedPane.prototype = { | 212 WebInspector.SidebarTabbedPane.prototype = { |
| 200 /** | 213 /** |
| 201 * @param {!WebInspector.SidebarPane} pane | 214 * @param {!WebInspector.SidebarPane} pane |
| 202 */ | 215 */ |
| 203 addPane: function(pane) | 216 addPane: function(pane) |
| 204 { | 217 { |
| 205 var title = pane.title(); | 218 var title = pane.title(); |
| 206 this.appendTab(title, title, pane); | 219 this.appendTab(title, title, pane); |
| 207 pane.element.appendChild(pane.titleElement); | 220 if (pane._toolbar) |
| 221 pane.element.insertBefore(pane._toolbar.element, pane.element.firstC
hild); |
| 208 pane._attached(this._setPaneVisible.bind(this, pane), this.selectTab.bin
d(this, title)); | 222 pane._attached(this._setPaneVisible.bind(this, pane), this.selectTab.bin
d(this, title)); |
| 209 }, | 223 }, |
| 210 | 224 |
| 211 /** | 225 /** |
| 212 * @param {!WebInspector.SidebarPane} pane | 226 * @param {!WebInspector.SidebarPane} pane |
| 213 * @param {boolean} visible | 227 * @param {boolean} visible |
| 214 */ | 228 */ |
| 215 _setPaneVisible: function(pane, visible) | 229 _setPaneVisible: function(pane, visible) |
| 216 { | 230 { |
| 217 var title = pane._title; | 231 var title = pane._title; |
| 218 if (visible) { | 232 if (visible) { |
| 219 if (!this.hasTab(title)) | 233 if (!this.hasTab(title)) |
| 220 this.appendTab(title, title, pane); | 234 this.appendTab(title, title, pane); |
| 221 } else { | 235 } else { |
| 222 if (this.hasTab(title)) | 236 if (this.hasTab(title)) |
| 223 this.closeTab(title); | 237 this.closeTab(title); |
| 224 } | 238 } |
| 225 }, | 239 }, |
| 226 | 240 |
| 227 __proto__: WebInspector.TabbedPane.prototype | 241 __proto__: WebInspector.TabbedPane.prototype |
| 228 } | 242 } |
| OLD | NEW |