| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 { | 37 { |
| 38 this._canDock = canDock; | 38 this._canDock = canDock; |
| 39 if (!canDock) { | 39 if (!canDock) { |
| 40 this._dockSide = WebInspector.DockController.State.Undocked; | 40 this._dockSide = WebInspector.DockController.State.Undocked; |
| 41 this._updateUI(); | 41 this._updateUI(); |
| 42 return; | 42 return; |
| 43 } | 43 } |
| 44 | 44 |
| 45 WebInspector.settings.currentDockState = WebInspector.settings.createSetting
("currentDockState", ""); | 45 WebInspector.settings.currentDockState = WebInspector.settings.createSetting
("currentDockState", ""); |
| 46 WebInspector.settings.lastDockState = WebInspector.settings.createSetting("l
astDockState", ""); | 46 WebInspector.settings.lastDockState = WebInspector.settings.createSetting("l
astDockState", ""); |
| 47 var states = [WebInspector.DockController.State.DockedToBottom, WebInspector
.DockController.State.Undocked, WebInspector.DockController.State.DockedToRight]
; | |
| 48 var titles = [WebInspector.UIString("Dock to main window."), WebInspector.UI
String("Undock into separate window."), WebInspector.UIString("Dock to main wind
ow.")]; | |
| 49 if (WebInspector.experimentsSettings.dockToLeft.isEnabled()) { | |
| 50 states.push(WebInspector.DockController.State.DockedToLeft); | |
| 51 titles.push(WebInspector.UIString("Dock to main window.")); | |
| 52 } | |
| 53 this._dockToggleButton = new WebInspector.StatusBarStatesSettingButton( | |
| 54 "dock-status-bar-item", | |
| 55 states, | |
| 56 titles, | |
| 57 WebInspector.settings.currentDockState, | |
| 58 WebInspector.settings.lastDockState, | |
| 59 this._dockSideChanged.bind(this)); | |
| 60 } | 47 } |
| 61 | 48 |
| 62 WebInspector.DockController.State = { | 49 WebInspector.DockController.State = { |
| 63 DockedToBottom: "bottom", | 50 DockedToBottom: "bottom", |
| 64 DockedToRight: "right", | 51 DockedToRight: "right", |
| 65 DockedToLeft: "left", | 52 DockedToLeft: "left", |
| 66 Undocked: "undocked" | 53 Undocked: "undocked" |
| 67 } | 54 } |
| 68 | 55 |
| 69 // Use BeforeDockSideChanged to do something before all the UI bits are updated, | 56 // Use BeforeDockSideChanged to do something before all the UI bits are updated, |
| 70 // DockSideChanged to update UI, and AfterDockSideChanged to perform actions | 57 // DockSideChanged to update UI, and AfterDockSideChanged to perform actions |
| 71 // after frontend is docked/undocked in the browser. | 58 // after frontend is docked/undocked in the browser. |
| 72 WebInspector.DockController.Events = { | 59 WebInspector.DockController.Events = { |
| 73 BeforeDockSideChanged: "BeforeDockSideChanged", | 60 BeforeDockSideChanged: "BeforeDockSideChanged", |
| 74 DockSideChanged: "DockSideChanged", | 61 DockSideChanged: "DockSideChanged", |
| 75 AfterDockSideChanged: "AfterDockSideChanged" | 62 AfterDockSideChanged: "AfterDockSideChanged" |
| 76 } | 63 } |
| 77 | 64 |
| 78 WebInspector.DockController.prototype = { | 65 WebInspector.DockController.prototype = { |
| 79 initialize: function() | |
| 80 { | |
| 81 if (this._canDock) | |
| 82 this._dockToggleButton.toggleInitialState(); | |
| 83 }, | |
| 84 | |
| 85 /** | |
| 86 * @return {?Element} | |
| 87 */ | |
| 88 get element() | |
| 89 { | |
| 90 return this._canDock ? this._dockToggleButton.element : null; | |
| 91 }, | |
| 92 | |
| 93 /** | 66 /** |
| 94 * @return {string} | 67 * @return {string} |
| 95 */ | 68 */ |
| 96 dockSide: function() | 69 dockSide: function() |
| 97 { | 70 { |
| 98 return this._dockSide; | 71 return this._dockSide; |
| 99 }, | 72 }, |
| 100 | 73 |
| 101 /** | 74 /** |
| 102 * @return {boolean} | 75 * @return {boolean} |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 body.classList.remove("dock-to-left"); | 135 body.classList.remove("dock-to-left"); |
| 163 body.classList.remove("dock-to-bottom"); | 136 body.classList.remove("dock-to-bottom"); |
| 164 break; | 137 break; |
| 165 } | 138 } |
| 166 }, | 139 }, |
| 167 | 140 |
| 168 __proto__: WebInspector.Object.prototype | 141 __proto__: WebInspector.Object.prototype |
| 169 } | 142 } |
| 170 | 143 |
| 171 /** | 144 /** |
| 145 * @constructor |
| 146 * @implements {WebInspector.StatusBarButton.Provider} |
| 147 */ |
| 148 WebInspector.DockController.ButtonProvider = function() |
| 149 { |
| 150 } |
| 151 |
| 152 WebInspector.DockController.ButtonProvider.prototype = { |
| 153 /** |
| 154 * @return {?WebInspector.StatusBarButton} |
| 155 */ |
| 156 button: function() |
| 157 { |
| 158 if (!WebInspector.dockController.canDock()) |
| 159 return null; |
| 160 |
| 161 if (!this._dockToggleButton) { |
| 162 var states = [WebInspector.DockController.State.DockedToBottom, WebI
nspector.DockController.State.Undocked, WebInspector.DockController.State.Docked
ToRight]; |
| 163 var titles = [WebInspector.UIString("Dock to main window."), WebInsp
ector.UIString("Undock into separate window."), WebInspector.UIString("Dock to m
ain window.")]; |
| 164 if (WebInspector.experimentsSettings.dockToLeft.isEnabled()) { |
| 165 states.push(WebInspector.DockController.State.DockedToLeft); |
| 166 titles.push(WebInspector.UIString("Dock to main window.")); |
| 167 } |
| 168 |
| 169 this._dockToggleButton = new WebInspector.StatusBarStatesSettingButt
on( |
| 170 "dock-status-bar-item", |
| 171 states, |
| 172 titles, |
| 173 WebInspector.settings.currentDockState, |
| 174 WebInspector.settings.lastDockState, |
| 175 WebInspector.dockController._dockSideChanged.bind(WebInspect
or.dockController)); |
| 176 this._dockToggleButton.toggleInitialState(); |
| 177 } |
| 178 return this._dockToggleButton; |
| 179 } |
| 180 } |
| 181 |
| 182 /** |
| 172 * @type {!WebInspector.DockController} | 183 * @type {!WebInspector.DockController} |
| 173 */ | 184 */ |
| 174 WebInspector.dockController; | 185 WebInspector.dockController; |
| OLD | NEW |