2 * Copyright (C) 2012 Google 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 are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * @extends {WebInspector.Object}
34 * @param {boolean} canDock
36 WebInspector.DockController = function(canDock)
38 this._canDock = canDock;
40 this._dockSide = WebInspector.DockController.State.Undocked;
45 WebInspector.settings.currentDockState = WebInspector.settings.createSetting("currentDockState", "");
46 WebInspector.settings.lastDockState = WebInspector.settings.createSetting("lastDockState", "");
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.UIString("Undock into separate window."), WebInspector.UIString("Dock to main window.")];
49 if (WebInspector.experimentsSettings.dockToLeft.isEnabled()) {
50 states.push(WebInspector.DockController.State.DockedToLeft);
51 titles.push(WebInspector.UIString("Dock to main window."));
53 this._dockToggleButton = new WebInspector.StatusBarStatesSettingButton(
54 "dock-status-bar-item",
57 WebInspector.settings.currentDockState,
58 WebInspector.settings.lastDockState,
59 this._dockSideChanged.bind(this));
62 WebInspector.DockController.State = {
63 DockedToBottom: "bottom",
64 DockedToRight: "right",
69 WebInspector.DockController.Events = {
70 DockSideChanged: "DockSideChanged"
73 WebInspector.DockController.prototype = {
79 return this._canDock ? this._dockToggleButton.element : null;
87 return this._dockSide;
101 isVertical: function()
103 return this._dockSide === WebInspector.DockController.State.DockedToRight || this._dockSide === WebInspector.DockController.State.DockedToLeft;
107 * @param {string} dockSide
109 _dockSideChanged: function(dockSide)
111 if (this._dockSide === dockSide)
114 this._dockSide = dockSide;
116 this.dispatchEventToListeners(WebInspector.DockController.Events.DockSideChanged, this._dockSide);
119 InspectorFrontendHost.setIsDocked(dockSide !== WebInspector.DockController.State.Undocked);
122 _updateUI: function()
124 var body = document.body;
125 switch (this._dockSide) {
126 case WebInspector.DockController.State.DockedToBottom:
127 body.classList.remove("undocked");
128 body.classList.remove("dock-to-right");
129 body.classList.remove("dock-to-left");
130 body.classList.add("dock-to-bottom");
132 case WebInspector.DockController.State.DockedToRight:
133 body.classList.remove("undocked");
134 body.classList.add("dock-to-right");
135 body.classList.remove("dock-to-left");
136 body.classList.remove("dock-to-bottom");
138 case WebInspector.DockController.State.DockedToLeft:
139 body.classList.remove("undocked");
140 body.classList.remove("dock-to-right");
141 body.classList.add("dock-to-left");
142 body.classList.remove("dock-to-bottom");
144 case WebInspector.DockController.State.Undocked:
145 body.classList.add("undocked");
146 body.classList.remove("dock-to-right");
147 body.classList.remove("dock-to-left");
148 body.classList.remove("dock-to-bottom");
153 __proto__: WebInspector.Object.prototype
157 * @type {!WebInspector.DockController}
159 WebInspector.dockController;