| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @constructor |
| 7 * @implements {WebInspector.ToolbarItem.Provider} |
| 8 */ |
| 9 WebInspector.DeviceModeButtonProvider = function() |
| 10 { |
| 11 var button = new WebInspector.ToolbarButton(WebInspector.UIString("Toggle de
vice mode"), "emulation-toolbar-item"); |
| 12 button.addEventListener("click", toggleEmulationEnabled); |
| 13 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.EmulationStateChanged, emulationEnabledChanged); |
| 14 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.OverridesWarningUpdated, overridesWarningUpdated); |
| 15 emulationEnabledChanged(); |
| 16 overridesWarningUpdated(); |
| 17 |
| 18 function toggleEmulationEnabled() |
| 19 { |
| 20 WebInspector.overridesSupport.setEmulationEnabled(!button.toggled()); |
| 21 } |
| 22 |
| 23 function emulationEnabledChanged() |
| 24 { |
| 25 button.setToggled(WebInspector.overridesSupport.emulationEnabled()); |
| 26 } |
| 27 |
| 28 function overridesWarningUpdated() |
| 29 { |
| 30 var message = WebInspector.overridesSupport.warningMessage(); |
| 31 button.setTitle(message || WebInspector.UIString("Toggle device mode")); |
| 32 button.element.classList.toggle("warning", !!message); |
| 33 } |
| 34 |
| 35 this._button = button; |
| 36 } |
| 37 |
| 38 WebInspector.DeviceModeButtonProvider.prototype = { |
| 39 /** |
| 40 * @override |
| 41 * @return {?WebInspector.ToolbarItem} |
| 42 */ |
| 43 item: function() |
| 44 { |
| 45 return this._button; |
| 46 } |
| 47 } |
| 48 |
| 49 /** |
| 50 * @constructor |
| 51 * @implements {WebInspector.ActionDelegate} |
| 52 */ |
| 53 WebInspector.ToggleDeviceModeActionDelegate = function() |
| 54 { |
| 55 } |
| 56 |
| 57 WebInspector.ToggleDeviceModeActionDelegate.prototype = { |
| 58 /** |
| 59 * @override |
| 60 * @param {!WebInspector.Context} context |
| 61 * @param {string} actionId |
| 62 */ |
| 63 handleAction: function(context, actionId) |
| 64 { |
| 65 WebInspector.overridesSupport.setEmulationEnabled(!WebInspector.override
sSupport.emulationEnabled()); |
| 66 } |
| 67 } |
| OLD | NEW |