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 * @extends {WebInspector.App} | 7 * @extends {WebInspector.App} |
8 */ | 8 */ |
9 WebInspector.AdvancedApp = function() | 9 WebInspector.AdvancedApp = function() |
10 { | 10 { |
11 WebInspector.App.call(this); | 11 WebInspector.App.call(this); |
12 if (WebInspector.overridesSupport.responsiveDesignAvailable()) { | 12 if (WebInspector.overridesSupport.responsiveDesignAvailable()) { |
13 this._toggleEmulationButton = new WebInspector.StatusBarButton(WebInspec
tor.UIString("Toggle device mode."), "emulation-status-bar-item"); | 13 this._toggleEmulationButton = new WebInspector.StatusBarButton(WebInspec
tor.UIString("Toggle device mode."), "emulation-status-bar-item"); |
14 this._toggleEmulationButton.toggled = WebInspector.overridesSupport.emul
ationEnabled(); | 14 this._toggleEmulationButton.setToggled(WebInspector.overridesSupport.emu
lationEnabled()); |
15 this._toggleEmulationButton.addEventListener("click", this._toggleEmulat
ionEnabled, this); | 15 this._toggleEmulationButton.addEventListener("click", this._toggleEmulat
ionEnabled, this); |
16 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSup
port.Events.EmulationStateChanged, this._emulationEnabledChanged, this); | 16 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSup
port.Events.EmulationStateChanged, this._emulationEnabledChanged, this); |
17 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSup
port.Events.OverridesWarningUpdated, this._overridesWarningUpdated, this); | 17 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSup
port.Events.OverridesWarningUpdated, this._overridesWarningUpdated, this); |
18 } | 18 } |
19 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve
nts.BeforeDockSideChanged, this._openToolboxWindow, this); | 19 WebInspector.dockController.addEventListener(WebInspector.DockController.Eve
nts.BeforeDockSideChanged, this._openToolboxWindow, this); |
20 }; | 20 }; |
21 | 21 |
22 WebInspector.AdvancedApp.prototype = { | 22 WebInspector.AdvancedApp.prototype = { |
23 _toggleEmulationEnabled: function() | 23 _toggleEmulationEnabled: function() |
24 { | 24 { |
25 var enabled = !this._toggleEmulationButton.toggled; | 25 var enabled = !this._toggleEmulationButton.toggled(); |
26 if (enabled) | 26 if (enabled) |
27 WebInspector.userMetrics.DeviceModeEnabled.record(); | 27 WebInspector.userMetrics.DeviceModeEnabled.record(); |
28 WebInspector.overridesSupport.setEmulationEnabled(enabled); | 28 WebInspector.overridesSupport.setEmulationEnabled(enabled); |
29 }, | 29 }, |
30 | 30 |
31 _emulationEnabledChanged: function() | 31 _emulationEnabledChanged: function() |
32 { | 32 { |
33 this._toggleEmulationButton.toggled = WebInspector.overridesSupport.emul
ationEnabled(); | 33 this._toggleEmulationButton.setToggled(WebInspector.overridesSupport.emu
lationEnabled()); |
34 if (!WebInspector.overridesSupport.responsiveDesignAvailable() && WebIns
pector.overridesSupport.emulationEnabled()) | 34 if (!WebInspector.overridesSupport.responsiveDesignAvailable() && WebIns
pector.overridesSupport.emulationEnabled()) |
35 WebInspector.inspectorView.showViewInDrawer("emulation", true); | 35 WebInspector.inspectorView.showViewInDrawer("emulation", true); |
36 }, | 36 }, |
37 | 37 |
38 _overridesWarningUpdated: function() | 38 _overridesWarningUpdated: function() |
39 { | 39 { |
40 if (!this._toggleEmulationButton) | 40 if (!this._toggleEmulationButton) |
41 return; | 41 return; |
42 var message = WebInspector.overridesSupport.warningMessage(); | 42 var message = WebInspector.overridesSupport.warningMessage(); |
43 this._toggleEmulationButton.title = message || WebInspector.UIString("To
ggle device mode."); | 43 this._toggleEmulationButton.setTitle(message || WebInspector.UIString("T
oggle device mode.")); |
44 this._toggleEmulationButton.element.classList.toggle("warning", !!messag
e); | 44 this._toggleEmulationButton.element.classList.toggle("warning", !!messag
e); |
45 }, | 45 }, |
46 | 46 |
47 /** | 47 /** |
48 * @param {!Document} document | 48 * @param {!Document} document |
49 * @override | 49 * @override |
50 */ | 50 */ |
51 presentUI: function(document) | 51 presentUI: function(document) |
52 { | 52 { |
53 var rootView = new WebInspector.RootView(); | 53 var rootView = new WebInspector.RootView(); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 handleAction: function() | 293 handleAction: function() |
294 { | 294 { |
295 if (!WebInspector.overridesSupport.responsiveDesignAvailable()) | 295 if (!WebInspector.overridesSupport.responsiveDesignAvailable()) |
296 return false; | 296 return false; |
297 if (!(WebInspector.app instanceof WebInspector.AdvancedApp)) | 297 if (!(WebInspector.app instanceof WebInspector.AdvancedApp)) |
298 return false; | 298 return false; |
299 WebInspector.app._toggleEmulationEnabled(); | 299 WebInspector.app._toggleEmulationEnabled(); |
300 return true; | 300 return true; |
301 } | 301 } |
302 } | 302 } |
OLD | NEW |