Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: Source/devtools/front_end/components/DockController.js

Issue 298913004: [DevTools] Add Toolbox page to undocked DevTools frontend. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 }, 109 },
110 110
111 /** 111 /**
112 * @param {string} dockSide 112 * @param {string} dockSide
113 */ 113 */
114 _dockSideChanged: function(dockSide) 114 _dockSideChanged: function(dockSide)
115 { 115 {
116 if (this._dockSide === dockSide) 116 if (this._dockSide === dockSide)
117 return; 117 return;
118 118
119 // We have to create toolbox window while still docked.
120 // In the case of starting undocked there are no listeners yet, so
121 // toolbox window must be created here.
122 if (dockSide === WebInspector.DockController.State.Undocked) {
123 this._openToolboxWindow();
124 if (this._toolboxWindowLoaded)
125 this._doChangeDockSide(dockSide);
126 else
127 this._toolboxWindowLoadedCallback = this._doChangeDockSide.bind( this, dockSide);
128 } else {
129 delete this._toolboxWindowLoadedCallback;
130 this._doChangeDockSide(dockSide);
131 }
132 },
133
134 /**
135 * @param {string} dockSide
136 */
137 _doChangeDockSide: function(dockSide)
138 {
119 this.dispatchEventToListeners(WebInspector.DockController.Events.BeforeD ockSideChanged, dockSide); 139 this.dispatchEventToListeners(WebInspector.DockController.Events.BeforeD ockSideChanged, dockSide);
120 InspectorFrontendHost.setIsDocked(dockSide !== WebInspector.DockControll er.State.Undocked, this._setIsDockedResponse.bind(this)); 140 var oldDockSide = this._dockSide;
141 InspectorFrontendHost.setIsDocked(dockSide !== WebInspector.DockControll er.State.Undocked, this._setIsDockedResponse.bind(this, oldDockSide));
121 this._dockSide = dockSide; 142 this._dockSide = dockSide;
122 this._updateUI(); 143 this._updateUI();
123 this.dispatchEventToListeners(WebInspector.DockController.Events.DockSid eChanged, this._dockSide); 144 this.dispatchEventToListeners(WebInspector.DockController.Events.DockSid eChanged, oldDockSide);
124 }, 145 },
125 146
126 _setIsDockedResponse: function() 147 /**
148 * @param {string} oldDockSide
149 */
150 _setIsDockedResponse: function(oldDockSide)
127 { 151 {
128 this.dispatchEventToListeners(WebInspector.DockController.Events.AfterDo ckSideChanged, this._dockSide); 152 this.dispatchEventToListeners(WebInspector.DockController.Events.AfterDo ckSideChanged, oldDockSide);
153 },
154
155 _openToolboxWindow: function()
156 {
157 if (this._toolboxWindow)
158 return;
159
160 var toolbox = (window.location.search ? "&" : "?") + "toolbox=true";
161 var hash = window.location.hash;
162 var url = window.location.href.replace(hash, "") + toolbox + hash;
163 this._toolboxWindow = window.open(url, undefined);
164
165 this._onToolboxWindowLoadedBound = this._onToolboxWindowLoaded.bind(this );
166 this._toolboxWindow.addEventListener("DOMContentLoaded", this._onToolbox WindowLoadedBound, false);
pfeldman 2014/05/27 15:37:04 DOMContentLoaded should fire just once.
167 },
168
169 _onToolboxWindowLoaded: function()
170 {
171 this._toolboxWindow.removeEventListener("DOMContentLoaded", this._onTool boxWindowLoadedBound, false);
172 this._toolboxWindowLoaded = true;
173
174 if (this._toolboxWindowLoadedCallback) {
175 this._toolboxWindowLoadedCallback(this._toolboxWindow);
176 delete this._toolboxWindowLoadedCallback;
177 }
178 },
179
180 /**
181 * @return {?Window}
182 */
183 toolboxWindow: function()
184 {
185 return this._toolboxWindowLoaded ? this._toolboxWindow : null;
129 }, 186 },
130 187
131 _updateUI: function() 188 _updateUI: function()
132 { 189 {
133 var body = document.body; 190 var body = document.body;
134 switch (this._dockSide) { 191 switch (this._dockSide) {
135 case WebInspector.DockController.State.DockedToBottom: 192 case WebInspector.DockController.State.DockedToBottom:
136 body.classList.remove("undocked"); 193 body.classList.remove("undocked");
137 body.classList.remove("dock-to-right"); 194 body.classList.remove("dock-to-right");
138 body.classList.remove("dock-to-left"); 195 body.classList.remove("dock-to-left");
(...skipping 20 matching lines...) Expand all
159 } 216 }
160 }, 217 },
161 218
162 __proto__: WebInspector.Object.prototype 219 __proto__: WebInspector.Object.prototype
163 } 220 }
164 221
165 /** 222 /**
166 * @type {!WebInspector.DockController} 223 * @type {!WebInspector.DockController}
167 */ 224 */
168 WebInspector.dockController; 225 WebInspector.dockController;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698