| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 */ | 34 */ |
| 35 WebInspector.Drawer = function(splitView) | 35 WebInspector.Drawer = function(splitView) |
| 36 { | 36 { |
| 37 WebInspector.VBox.call(this); | 37 WebInspector.VBox.call(this); |
| 38 this.element.id = "drawer-contents"; | 38 this.element.id = "drawer-contents"; |
| 39 | 39 |
| 40 this._splitView = splitView; | 40 this._splitView = splitView; |
| 41 splitView.hideDefaultResizer(); | 41 splitView.hideDefaultResizer(); |
| 42 this.show(splitView.sidebarElement()); | 42 this.show(splitView.sidebarElement()); |
| 43 | 43 |
| 44 this._drawerEditorSplitView = new WebInspector.SplitView(true, true, "editor
InDrawerSplitViewState", 0.5, 0.5); | |
| 45 this._drawerEditorSplitView.hideSidebar(); | |
| 46 this._drawerEditorSplitView.addEventListener(WebInspector.SplitView.Events.S
howModeChanged, this._drawerEditorSplitViewShowModeChanged, this); | |
| 47 this._drawerEditorShownSetting = WebInspector.settings.createSetting("drawer
EditorShown", true); | |
| 48 this._drawerEditorSplitView.show(this.element); | |
| 49 | |
| 50 this._toggleDrawerButton = new WebInspector.StatusBarButton(WebInspector.UIS
tring("Show drawer."), "console-status-bar-item"); | 44 this._toggleDrawerButton = new WebInspector.StatusBarButton(WebInspector.UIS
tring("Show drawer."), "console-status-bar-item"); |
| 51 this._toggleDrawerButton.addEventListener("click", this.toggle, this); | 45 this._toggleDrawerButton.addEventListener("click", this.toggle, this); |
| 52 | 46 |
| 53 this._tabbedPane = new WebInspector.TabbedPane(); | 47 this._tabbedPane = new WebInspector.TabbedPane(); |
| 54 this._tabbedPane.element.id = "drawer-tabbed-pane"; | 48 this._tabbedPane.element.id = "drawer-tabbed-pane"; |
| 55 this._tabbedPane.closeableTabs = false; | 49 this._tabbedPane.closeableTabs = false; |
| 56 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSele
cted, this._tabSelected, this); | 50 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSele
cted, this._tabSelected, this); |
| 57 new WebInspector.ExtensibleTabbedPaneController(this._tabbedPane, "drawer-vi
ew"); | 51 new WebInspector.ExtensibleTabbedPaneController(this._tabbedPane, "drawer-vi
ew"); |
| 58 | 52 |
| 59 this._toggleDrawerEditorButton = this._drawerEditorSplitView.createShowHideS
idebarButton("editor in drawer", "drawer-editor-show-hide-button"); | |
| 60 this._tabbedPane.element.appendChild(this._toggleDrawerEditorButton.element)
; | |
| 61 if (!WebInspector.experimentsSettings.editorInDrawer.isEnabled()) | |
| 62 this.setDrawerEditorAvailable(false); | |
| 63 | |
| 64 splitView.installResizer(this._tabbedPane.headerElement()); | 53 splitView.installResizer(this._tabbedPane.headerElement()); |
| 65 this._lastSelectedViewSetting = WebInspector.settings.createSetting("WebInsp
ector.Drawer.lastSelectedView", "console"); | 54 this._lastSelectedViewSetting = WebInspector.settings.createSetting("WebInsp
ector.Drawer.lastSelectedView", "console"); |
| 66 this._tabbedPane.show(this._drawerEditorSplitView.mainElement()); | 55 this._tabbedPane.show(this.element); |
| 67 } | 56 } |
| 68 | 57 |
| 69 WebInspector.Drawer.prototype = { | 58 WebInspector.Drawer.prototype = { |
| 70 /** | 59 /** |
| 71 * @return {!WebInspector.StatusBarButton} | 60 * @return {!WebInspector.StatusBarButton} |
| 72 */ | 61 */ |
| 73 toggleButton: function() | 62 toggleButton: function() |
| 74 { | 63 { |
| 75 return this._toggleDrawerButton; | 64 return this._toggleDrawerButton; |
| 76 }, | 65 }, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 showDrawer: function() | 109 showDrawer: function() |
| 121 { | 110 { |
| 122 this.showView(this._lastSelectedViewSetting.get()); | 111 this.showView(this._lastSelectedViewSetting.get()); |
| 123 }, | 112 }, |
| 124 | 113 |
| 125 wasShown: function() | 114 wasShown: function() |
| 126 { | 115 { |
| 127 this.showView(this._lastSelectedViewSetting.get()); | 116 this.showView(this._lastSelectedViewSetting.get()); |
| 128 this._toggleDrawerButton.toggled = true; | 117 this._toggleDrawerButton.toggled = true; |
| 129 this._toggleDrawerButton.title = WebInspector.UIString("Hide drawer."); | 118 this._toggleDrawerButton.title = WebInspector.UIString("Hide drawer."); |
| 130 this._ensureDrawerEditorExistsIfNeeded(); | |
| 131 }, | 119 }, |
| 132 | 120 |
| 133 willHide: function() | 121 willHide: function() |
| 134 { | 122 { |
| 135 this._toggleDrawerButton.toggled = false; | 123 this._toggleDrawerButton.toggled = false; |
| 136 this._toggleDrawerButton.title = WebInspector.UIString("Show drawer."); | 124 this._toggleDrawerButton.title = WebInspector.UIString("Show drawer."); |
| 137 }, | 125 }, |
| 138 | 126 |
| 139 /** | 127 /** |
| 140 * @param {boolean=} immediate | 128 * @param {boolean=} immediate |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 }, | 182 }, |
| 195 | 183 |
| 196 /** | 184 /** |
| 197 * @return {?string} | 185 * @return {?string} |
| 198 */ | 186 */ |
| 199 selectedViewId: function() | 187 selectedViewId: function() |
| 200 { | 188 { |
| 201 return this._tabbedPane.selectedTabId; | 189 return this._tabbedPane.selectedTabId; |
| 202 }, | 190 }, |
| 203 | 191 |
| 204 /** | |
| 205 * @param {!WebInspector.Event} event | |
| 206 */ | |
| 207 _drawerEditorSplitViewShowModeChanged: function(event) | |
| 208 { | |
| 209 var mode = /** @type {string} */ (event.data); | |
| 210 var shown = mode === WebInspector.SplitView.ShowMode.Both; | |
| 211 | |
| 212 if (this._isHidingDrawerEditor) | |
| 213 return; | |
| 214 | |
| 215 this._drawerEditorShownSetting.set(shown); | |
| 216 | |
| 217 if (!shown) | |
| 218 return; | |
| 219 | |
| 220 this._ensureDrawerEditor(); | |
| 221 this._drawerEditor.view().show(this._drawerEditorSplitView.sidebarElemen
t()); | |
| 222 }, | |
| 223 | |
| 224 initialPanelShown: function() | 192 initialPanelShown: function() |
| 225 { | 193 { |
| 226 this._initialPanelWasShown = true; | 194 this._initialPanelWasShown = true; |
| 227 this._ensureDrawerEditorExistsIfNeeded(); | |
| 228 }, | |
| 229 | |
| 230 _ensureDrawerEditorExistsIfNeeded: function() | |
| 231 { | |
| 232 if (!this._initialPanelWasShown || !this.isShowing() || !this._drawerEdi
torShownSetting.get() || !WebInspector.experimentsSettings.editorInDrawer.isEnab
led()) | |
| 233 return; | |
| 234 this._ensureDrawerEditor(); | |
| 235 }, | |
| 236 | |
| 237 _ensureDrawerEditor: function() | |
| 238 { | |
| 239 if (this._drawerEditor) | |
| 240 return; | |
| 241 this._drawerEditor = WebInspector.moduleManager.instance(WebInspector.Dr
awerEditor); | |
| 242 this._drawerEditor.installedIntoDrawer(); | |
| 243 }, | |
| 244 | |
| 245 /** | |
| 246 * @param {boolean} available | |
| 247 */ | |
| 248 setDrawerEditorAvailable: function(available) | |
| 249 { | |
| 250 if (!WebInspector.experimentsSettings.editorInDrawer.isEnabled()) | |
| 251 available = false; | |
| 252 this._toggleDrawerEditorButton.element.classList.toggle("hidden", !avail
able); | |
| 253 }, | |
| 254 | |
| 255 showDrawerEditor: function() | |
| 256 { | |
| 257 if (!WebInspector.experimentsSettings.editorInDrawer.isEnabled()) | |
| 258 return; | |
| 259 | |
| 260 this._splitView.showBoth(); | |
| 261 this._drawerEditorSplitView.showBoth(); | |
| 262 }, | |
| 263 | |
| 264 hideDrawerEditor: function() | |
| 265 { | |
| 266 this._isHidingDrawerEditor = true; | |
| 267 this._drawerEditorSplitView.hideSidebar(); | |
| 268 this._isHidingDrawerEditor = false; | |
| 269 }, | |
| 270 | |
| 271 /** | |
| 272 * @return {boolean} | |
| 273 */ | |
| 274 isDrawerEditorShown: function() | |
| 275 { | |
| 276 return this._drawerEditorShownSetting.get(); | |
| 277 }, | 195 }, |
| 278 | 196 |
| 279 __proto__: WebInspector.VBox.prototype | 197 __proto__: WebInspector.VBox.prototype |
| 280 } | 198 } |
| 281 | 199 |
| 282 /** | 200 /** |
| 283 * @interface | 201 * @interface |
| 284 */ | 202 */ |
| 285 WebInspector.Drawer.ViewFactory = function() | 203 WebInspector.Drawer.ViewFactory = function() |
| 286 { | 204 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 308 /** | 226 /** |
| 309 * @return {!WebInspector.View} | 227 * @return {!WebInspector.View} |
| 310 */ | 228 */ |
| 311 createView: function() | 229 createView: function() |
| 312 { | 230 { |
| 313 if (!this._instance) | 231 if (!this._instance) |
| 314 this._instance = /** @type {!WebInspector.View} */(new this._constru
ctor()); | 232 this._instance = /** @type {!WebInspector.View} */(new this._constru
ctor()); |
| 315 return this._instance; | 233 return this._instance; |
| 316 } | 234 } |
| 317 } | 235 } |
| 318 | |
| 319 /** | |
| 320 * @interface | |
| 321 */ | |
| 322 WebInspector.DrawerEditor = function() | |
| 323 { | |
| 324 } | |
| 325 | |
| 326 WebInspector.DrawerEditor.prototype = { | |
| 327 /** | |
| 328 * @return {!WebInspector.View} | |
| 329 */ | |
| 330 view: function() { }, | |
| 331 | |
| 332 installedIntoDrawer: function() { }, | |
| 333 } | |
| OLD | NEW |