| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @implements {WebInspector.App} | 7 * @implements {WebInspector.App} |
| 8 */ | 8 */ |
| 9 WebInspector.AdvancedApp = function() | 9 WebInspector.AdvancedApp = function() |
| 10 { | 10 { |
| 11 this._toggleEmulationButton = new WebInspector.ToolbarButton(WebInspector.UI
String("Toggle device mode"), "emulation-toolbar-item"); | |
| 12 this._toggleEmulationButton.setToggled(WebInspector.overridesSupport.emulati
onEnabled()); | |
| 13 this._toggleEmulationButton.addEventListener("click", this._toggleEmulationE
nabled, this); | |
| 14 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.EmulationStateChanged, this._emulationEnabledChanged, this); | |
| 15 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.OverridesWarningUpdated, this._overridesWarningUpdated, this); | |
| 16 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve
nts.BeforeDockSideChanged, this._openToolboxWindow, this); | 11 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve
nts.BeforeDockSideChanged, this._openToolboxWindow, this); |
| 17 }; | 12 }; |
| 18 | 13 |
| 19 WebInspector.AdvancedApp.prototype = { | 14 WebInspector.AdvancedApp.prototype = { |
| 20 _toggleEmulationEnabled: function() | |
| 21 { | |
| 22 var enabled = !this._toggleEmulationButton.toggled(); | |
| 23 WebInspector.overridesSupport.setEmulationEnabled(enabled); | |
| 24 }, | |
| 25 | |
| 26 _emulationEnabledChanged: function() | |
| 27 { | |
| 28 this._toggleEmulationButton.setToggled(WebInspector.overridesSupport.emu
lationEnabled()); | |
| 29 }, | |
| 30 | |
| 31 _overridesWarningUpdated: function() | |
| 32 { | |
| 33 if (!this._toggleEmulationButton) | |
| 34 return; | |
| 35 var message = WebInspector.overridesSupport.warningMessage(); | |
| 36 this._toggleEmulationButton.setTitle(message || WebInspector.UIString("T
oggle device mode")); | |
| 37 this._toggleEmulationButton.element.classList.toggle("warning", !!messag
e); | |
| 38 }, | |
| 39 | |
| 40 /** | 15 /** |
| 41 * @param {!Document} document | 16 * @param {!Document} document |
| 42 * @override | 17 * @override |
| 43 */ | 18 */ |
| 44 presentUI: function(document) | 19 presentUI: function(document) |
| 45 { | 20 { |
| 46 var rootView = new WebInspector.RootView(); | 21 var rootView = new WebInspector.RootView(); |
| 47 | 22 |
| 48 this._rootSplitWidget = new WebInspector.SplitWidget(false, true, "Inspe
ctorView.splitViewState", 555, 300, true); | 23 this._rootSplitWidget = new WebInspector.SplitWidget(false, true, "Inspe
ctorView.splitViewState", 555, 300, true); |
| 49 this._rootSplitWidget.show(rootView.element); | 24 this._rootSplitWidget.show(rootView.element); |
| 50 | 25 |
| 51 this._rootSplitWidget.setSidebarWidget(WebInspector.inspectorView); | 26 this._rootSplitWidget.setSidebarWidget(WebInspector.inspectorView); |
| 52 | 27 |
| 53 this._inspectedPagePlaceholder = new WebInspector.InspectedPagePlacehold
er(); | 28 this._inspectedPagePlaceholder = new WebInspector.InspectedPagePlacehold
er(); |
| 54 this._inspectedPagePlaceholder.addEventListener(WebInspector.InspectedPa
gePlaceholder.Events.Update, this._onSetInspectedPageBounds.bind(this, false), t
his); | 29 this._inspectedPagePlaceholder.addEventListener(WebInspector.InspectedPa
gePlaceholder.Events.Update, this._onSetInspectedPageBounds.bind(this, false), t
his); |
| 55 this._responsiveDesignView = new WebInspector.ResponsiveDesignView(this.
_inspectedPagePlaceholder); | 30 this._responsiveDesignView = new WebInspector.ResponsiveDesignView(this.
_inspectedPagePlaceholder); |
| 56 this._rootSplitWidget.setMainWidget(this._responsiveDesignView); | 31 this._rootSplitWidget.setMainWidget(this._responsiveDesignView); |
| 57 | 32 |
| 58 WebInspector.dockController.addEventListener(WebInspector.DockController
.Events.BeforeDockSideChanged, this._onBeforeDockSideChange, this); | 33 WebInspector.dockController.addEventListener(WebInspector.DockController
.Events.BeforeDockSideChanged, this._onBeforeDockSideChange, this); |
| 59 WebInspector.dockController.addEventListener(WebInspector.DockController
.Events.DockSideChanged, this._onDockSideChange, this); | 34 WebInspector.dockController.addEventListener(WebInspector.DockController
.Events.DockSideChanged, this._onDockSideChange, this); |
| 60 WebInspector.dockController.addEventListener(WebInspector.DockController
.Events.AfterDockSideChanged, this._onAfterDockSideChange, this); | 35 WebInspector.dockController.addEventListener(WebInspector.DockController
.Events.AfterDockSideChanged, this._onAfterDockSideChange, this); |
| 61 this._onDockSideChange(); | 36 this._onDockSideChange(); |
| 62 | 37 |
| 63 this._overridesWarningUpdated(); | |
| 64 | |
| 65 WebInspector.inspectorView.showInitialPanel(); | 38 WebInspector.inspectorView.showInitialPanel(); |
| 66 console.timeStamp("AdvancedApp.attachToBody"); | 39 console.timeStamp("AdvancedApp.attachToBody"); |
| 67 rootView.attachToDocument(document); | 40 rootView.attachToDocument(document); |
| 68 this._inspectedPagePlaceholder.update(); | 41 this._inspectedPagePlaceholder.update(); |
| 69 }, | 42 }, |
| 70 | 43 |
| 71 /** | 44 /** |
| 72 * @param {!WebInspector.Event} event | 45 * @param {!WebInspector.Event} event |
| 73 */ | 46 */ |
| 74 _openToolboxWindow: function(event) | 47 _openToolboxWindow: function(event) |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 WebInspector.AdvancedAppProvider.prototype = { | 203 WebInspector.AdvancedAppProvider.prototype = { |
| 231 /** | 204 /** |
| 232 * @override | 205 * @override |
| 233 * @return {!WebInspector.App} | 206 * @return {!WebInspector.App} |
| 234 */ | 207 */ |
| 235 createApp: function() | 208 createApp: function() |
| 236 { | 209 { |
| 237 return WebInspector.AdvancedApp._instance(); | 210 return WebInspector.AdvancedApp._instance(); |
| 238 } | 211 } |
| 239 }; | 212 }; |
| 240 | |
| 241 /** | |
| 242 * @constructor | |
| 243 * @implements {WebInspector.ToolbarItem.Provider} | |
| 244 */ | |
| 245 WebInspector.AdvancedApp.EmulationButtonProvider = function() | |
| 246 { | |
| 247 } | |
| 248 | |
| 249 WebInspector.AdvancedApp.EmulationButtonProvider.prototype = { | |
| 250 /** | |
| 251 * @override | |
| 252 * @return {?WebInspector.ToolbarItem} | |
| 253 */ | |
| 254 item: function() | |
| 255 { | |
| 256 return WebInspector.AdvancedApp._instance()._toggleEmulationButton; | |
| 257 } | |
| 258 } | |
| 259 | |
| 260 /** | |
| 261 * @constructor | |
| 262 * @implements {WebInspector.ActionDelegate} | |
| 263 */ | |
| 264 WebInspector.AdvancedApp.ToggleDeviceModeActionDelegate = function() | |
| 265 { | |
| 266 } | |
| 267 | |
| 268 WebInspector.AdvancedApp.ToggleDeviceModeActionDelegate.prototype = { | |
| 269 /** | |
| 270 * @override | |
| 271 * @param {!WebInspector.Context} context | |
| 272 * @param {string} actionId | |
| 273 */ | |
| 274 handleAction: function(context, actionId) | |
| 275 { | |
| 276 WebInspector.AdvancedApp._instance()._toggleEmulationEnabled(); | |
| 277 } | |
| 278 } | |
| OLD | NEW |