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

Unified Diff: Source/devtools/front_end/emulation/DeviceModeButton.js

Issue 1164933008: [DevTools] Extract DeviceModeButton from AdvancedApp. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/devtools.gypi ('k') | Source/devtools/front_end/emulation/module.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/emulation/DeviceModeButton.js
diff --git a/Source/devtools/front_end/emulation/DeviceModeButton.js b/Source/devtools/front_end/emulation/DeviceModeButton.js
new file mode 100644
index 0000000000000000000000000000000000000000..a69910e17b5ff96f95ffaf066425734137211577
--- /dev/null
+++ b/Source/devtools/front_end/emulation/DeviceModeButton.js
@@ -0,0 +1,67 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @constructor
+ * @implements {WebInspector.ToolbarItem.Provider}
+ */
+WebInspector.DeviceModeButtonProvider = function()
+{
+ var button = new WebInspector.ToolbarButton(WebInspector.UIString("Toggle device mode"), "emulation-toolbar-item");
+ button.addEventListener("click", toggleEmulationEnabled);
+ WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport.Events.EmulationStateChanged, emulationEnabledChanged);
+ WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport.Events.OverridesWarningUpdated, overridesWarningUpdated);
+ emulationEnabledChanged();
+ overridesWarningUpdated();
+
+ function toggleEmulationEnabled()
+ {
+ WebInspector.overridesSupport.setEmulationEnabled(!button.toggled());
+ }
+
+ function emulationEnabledChanged()
+ {
+ button.setToggled(WebInspector.overridesSupport.emulationEnabled());
+ }
+
+ function overridesWarningUpdated()
+ {
+ var message = WebInspector.overridesSupport.warningMessage();
+ button.setTitle(message || WebInspector.UIString("Toggle device mode"));
+ button.element.classList.toggle("warning", !!message);
+ }
+
+ this._button = button;
+}
+
+WebInspector.DeviceModeButtonProvider.prototype = {
+ /**
+ * @override
+ * @return {?WebInspector.ToolbarItem}
+ */
+ item: function()
+ {
+ return this._button;
+ }
+}
+
+/**
+ * @constructor
+ * @implements {WebInspector.ActionDelegate}
+ */
+WebInspector.ToggleDeviceModeActionDelegate = function()
+{
+}
+
+WebInspector.ToggleDeviceModeActionDelegate.prototype = {
+ /**
+ * @override
+ * @param {!WebInspector.Context} context
+ * @param {string} actionId
+ */
+ handleAction: function(context, actionId)
+ {
+ WebInspector.overridesSupport.setEmulationEnabled(!WebInspector.overridesSupport.emulationEnabled());
+ }
+}
« no previous file with comments | « Source/devtools/devtools.gypi ('k') | Source/devtools/front_end/emulation/module.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698