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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/devtools.gypi ('k') | Source/devtools/front_end/emulation/module.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« 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