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

Side by Side Diff: Source/devtools/front_end/elements/OverridesView.js

Issue 347583003: DevTools: add emulation toggle button and splash screen. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: For landing Created 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 25 matching lines...) Expand all
36 { 36 {
37 WebInspector.VBox.call(this); 37 WebInspector.VBox.call(this);
38 this.registerRequiredCSS("overrides.css"); 38 this.registerRequiredCSS("overrides.css");
39 this.registerRequiredCSS("helpScreen.css"); 39 this.registerRequiredCSS("helpScreen.css");
40 this.element.classList.add("overrides-view"); 40 this.element.classList.add("overrides-view");
41 41
42 this._tabbedPane = new WebInspector.TabbedPane(); 42 this._tabbedPane = new WebInspector.TabbedPane();
43 this._tabbedPane.shrinkableTabs = false; 43 this._tabbedPane.shrinkableTabs = false;
44 this._tabbedPane.verticalTabLayout = true; 44 this._tabbedPane.verticalTabLayout = true;
45 45
46
46 if (!WebInspector.overridesSupport.isInspectingDevice()) { 47 if (!WebInspector.overridesSupport.isInspectingDevice()) {
47 new WebInspector.OverridesView.DeviceTab().appendAsTab(this._tabbedPane) ; 48 new WebInspector.OverridesView.DeviceTab().appendAsTab(this._tabbedPane) ;
48 new WebInspector.OverridesView.MediaTab().appendAsTab(this._tabbedPane); 49 new WebInspector.OverridesView.MediaTab().appendAsTab(this._tabbedPane);
49 } 50 }
50 new WebInspector.OverridesView.NetworkTab().appendAsTab(this._tabbedPane); 51 new WebInspector.OverridesView.NetworkTab().appendAsTab(this._tabbedPane);
51 new WebInspector.OverridesView.SensorsTab().appendAsTab(this._tabbedPane); 52 new WebInspector.OverridesView.SensorsTab().appendAsTab(this._tabbedPane);
52 53
53 this._lastSelectedTabSetting = WebInspector.settings.createSetting("lastSele ctedEmulateTab", "device"); 54 this._lastSelectedTabSetting = WebInspector.settings.createSetting("lastSele ctedEmulateTab", "device");
54 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get()); 55 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get());
55 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSele cted, this._tabSelected, this); 56 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSele cted, this._tabSelected, this);
56 this._tabbedPane.show(this.element); 57 this._tabbedPane.show(this.element);
57 58
59 var resetButtonElement = this._tabbedPane.headerElement().createChild("butto n", "settings-tab-text-button overrides-reset-button");
60 resetButtonElement.textContent = WebInspector.UIString("Reset");
61 resetButtonElement.addEventListener("click", WebInspector.overridesSupport.r eset.bind(WebInspector.overridesSupport), false);
62
58 this._warningFooter = this.element.createChild("div", "overrides-footer"); 63 this._warningFooter = this.element.createChild("div", "overrides-footer");
59 this._overridesWarningUpdated(); 64 this._overridesWarningUpdated();
65
66 this._splashScreenElement = this.element.createChild("div", "overrides-splas h-screen");
67 this._splashScreenElement.createTextChild(WebInspector.UIString("Emulation i s currently disabled. Toggle "));
68 var toggleEmulationButton = new WebInspector.StatusBarButton("", "responsive -design-status-bar-item");
69 toggleEmulationButton.addEventListener("click", this._toggleEmulationEnabled , this);
70 this._splashScreenElement.appendChild(toggleEmulationButton.element);
71 this._splashScreenElement.createTextChild(WebInspector.UIString("in the main toolbar to enable it."));
72
60 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport .Events.OverridesWarningUpdated, this._overridesWarningUpdated, this); 73 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport .Events.OverridesWarningUpdated, this._overridesWarningUpdated, this);
74 WebInspector.overridesSupport.settings.emulationEnabled.addChangeListener(th is._emulationEnabledChanged, this);
75 this._emulationEnabledChanged();
61 } 76 }
62 77
63 WebInspector.OverridesView.prototype = { 78 WebInspector.OverridesView.prototype = {
64 /** 79 /**
65 * @param {!WebInspector.Event} event 80 * @param {!WebInspector.Event} event
66 */ 81 */
67 _tabSelected: function(event) 82 _tabSelected: function(event)
68 { 83 {
69 this._lastSelectedTabSetting.set(this._tabbedPane.selectedTabId); 84 this._lastSelectedTabSetting.set(this._tabbedPane.selectedTabId);
70 }, 85 },
71 86
72 _overridesWarningUpdated: function() 87 _overridesWarningUpdated: function()
73 { 88 {
74 var message = WebInspector.overridesSupport.warningMessage(); 89 var message = WebInspector.overridesSupport.warningMessage();
75 this._warningFooter.classList.toggle("hidden", !message); 90 this._warningFooter.classList.toggle("hidden", !WebInspector.overridesSu pport.settings.emulationEnabled.get() || !message);
76 this._warningFooter.textContent = message; 91 this._warningFooter.textContent = message;
77 }, 92 },
78 93
94 _toggleEmulationEnabled: function()
95 {
96 WebInspector.overridesSupport.settings.emulationEnabled.set(true);
97 },
98
99 _emulationEnabledChanged: function()
100 {
101 this._tabbedPane.element.classList.toggle("hidden", !WebInspector.overri desSupport.settings.emulationEnabled.get());
102 this._overridesWarningUpdated();
103 this._splashScreenElement.classList.toggle("hidden", WebInspector.overri desSupport.settings.emulationEnabled.get());
104 },
105
79 __proto__: WebInspector.VBox.prototype 106 __proto__: WebInspector.VBox.prototype
80 } 107 }
81 108
82 /** 109 /**
83 * @constructor 110 * @constructor
84 * @extends {WebInspector.VBox} 111 * @extends {WebInspector.VBox}
85 * @param {string} id 112 * @param {string} id
86 * @param {string} name 113 * @param {string} name
87 * @param {!Array.<!WebInspector.Setting>} settings 114 * @param {!Array.<!WebInspector.Setting>} settings
88 * @param {!Array.<function():boolean>=} predicates 115 * @param {!Array.<function():boolean>=} predicates
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 170
144 __proto__: WebInspector.VBox.prototype 171 __proto__: WebInspector.VBox.prototype
145 } 172 }
146 173
147 /** 174 /**
148 * @constructor 175 * @constructor
149 * @extends {WebInspector.OverridesView.Tab} 176 * @extends {WebInspector.OverridesView.Tab}
150 */ 177 */
151 WebInspector.OverridesView.DeviceTab = function() 178 WebInspector.OverridesView.DeviceTab = function()
152 { 179 {
153 WebInspector.OverridesView.Tab.call(this, "device", WebInspector.UIString("D evice"), [], [function(){return true;}]); 180 WebInspector.OverridesView.Tab.call(this, "device", WebInspector.UIString("D evice"), [
181 WebInspector.overridesSupport.settings.deviceWidth,
182 WebInspector.overridesSupport.settings.deviceHeight,
183 WebInspector.overridesSupport.settings.deviceScaleFactor,
184 WebInspector.overridesSupport.settings.emulateViewport,
185 WebInspector.overridesSupport.settings.deviceTextAutosizing
186 ]);
154 this.element.classList.add("overrides-device"); 187 this.element.classList.add("overrides-device");
155 188
156 this.element.appendChild(this._createDeviceElement()); 189 this.element.appendChild(this._createDeviceElement());
157 190
158 var footnote = this.element.createChild("p", "help-footnote"); 191 var footnote = this.element.createChild("p", "help-footnote");
159 var footnoteLink = footnote.createChild("a"); 192 var footnoteLink = footnote.createChild("a");
160 footnoteLink.href = "https://developers.google.com/chrome-developer-tools/do cs/mobile-emulation"; 193 footnoteLink.href = "https://developers.google.com/chrome-developer-tools/do cs/mobile-emulation";
161 footnoteLink.target = "_blank"; 194 footnoteLink.target = "_blank";
162 footnoteLink.createTextChild(WebInspector.UIString("More information about s creen emulation")); 195 footnoteLink.createTextChild(WebInspector.UIString("More information about s creen emulation"));
163 } 196 }
164 197
165 WebInspector.OverridesView.DeviceTab.prototype = { 198 WebInspector.OverridesView.DeviceTab.prototype = {
166 _createDeviceElement: function() 199 _createDeviceElement: function()
167 { 200 {
168 var fieldsetElement = document.createElement("fieldset"); 201 var fieldsetElement = document.createElement("fieldset");
169 fieldsetElement.id = "metrics-override-section"; 202 fieldsetElement.id = "metrics-override-section";
170 203
171 fieldsetElement.createChild("span").textContent = WebInspector.UIString( "Device:"); 204 fieldsetElement.createChild("span").textContent = WebInspector.UIString( "Model:");
172 fieldsetElement.appendChild(WebInspector.overridesSupport.createDeviceSe lect(document)); 205 fieldsetElement.appendChild(WebInspector.overridesSupport.createDeviceSe lect(document));
173 206
174 var tableElement = fieldsetElement.createChild("table", "nowrap"); 207 var tableElement = fieldsetElement.createChild("table", "nowrap");
175 208
176 var rowElement = tableElement.createChild("tr"); 209 var rowElement = tableElement.createChild("tr");
177 var cellElement = rowElement.createChild("td"); 210 var cellElement = rowElement.createChild("td");
178 cellElement.appendChild(document.createTextNode(WebInspector.UIString("R esolution:"))); 211 cellElement.appendChild(document.createTextNode(WebInspector.UIString("R esolution:")));
179 cellElement = rowElement.createChild("td"); 212 cellElement = rowElement.createChild("td");
180 213
181 var widthOverrideInput = WebInspector.SettingsUI.createSettingInputField ("", WebInspector.overridesSupport.settings.deviceWidth, true, 4, "80px", WebIns pector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UIString(" --")); 214 var widthOverrideInput = WebInspector.SettingsUI.createSettingInputField ("", WebInspector.overridesSupport.settings.deviceWidth, true, 4, "80px", WebIns pector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UIString(" \u2013"));
182 cellElement.appendChild(widthOverrideInput); 215 cellElement.appendChild(widthOverrideInput);
183 this._swapDimensionsElement = cellElement.createChild("button", "overrid es-swap"); 216 this._swapDimensionsElement = cellElement.createChild("button", "overrid es-swap");
184 this._swapDimensionsElement.appendChild(document.createTextNode(" \u21C4 ")); // RIGHTWARDS ARROW OVER LEFTWARDS ARROW. 217 this._swapDimensionsElement.appendChild(document.createTextNode(" \u21C4 ")); // RIGHTWARDS ARROW OVER LEFTWARDS ARROW.
185 this._swapDimensionsElement.title = WebInspector.UIString("Swap dimensio ns"); 218 this._swapDimensionsElement.title = WebInspector.UIString("Swap dimensio ns");
186 this._swapDimensionsElement.addEventListener("click", WebInspector.overr idesSupport.swapDimensions.bind(WebInspector.overridesSupport), false); 219 this._swapDimensionsElement.addEventListener("click", WebInspector.overr idesSupport.swapDimensions.bind(WebInspector.overridesSupport), false);
187 this._swapDimensionsElement.tabIndex = -1; 220 this._swapDimensionsElement.tabIndex = -1;
188 var heightOverrideInput = WebInspector.SettingsUI.createSettingInputFiel d("", WebInspector.overridesSupport.settings.deviceHeight, true, 4, "80px", WebI nspector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UIString ("--")); 221 var heightOverrideInput = WebInspector.SettingsUI.createSettingInputFiel d("", WebInspector.overridesSupport.settings.deviceHeight, true, 4, "80px", WebI nspector.OverridesSupport.deviceSizeValidator, true, true, WebInspector.UIString ("\u2013"));
189 cellElement.appendChild(heightOverrideInput); 222 cellElement.appendChild(heightOverrideInput);
190 223
191 rowElement = tableElement.createChild("tr"); 224 rowElement = tableElement.createChild("tr");
192 cellElement = rowElement.createChild("td"); 225 cellElement = rowElement.createChild("td");
193 cellElement.colSpan = 4; 226 cellElement.colSpan = 4;
194 227
195 rowElement = tableElement.createChild("tr"); 228 rowElement = tableElement.createChild("tr");
196 rowElement.title = WebInspector.UIString("Ratio between a device's physi cal pixels and device-independent pixels."); 229 rowElement.title = WebInspector.UIString("Ratio between a device's physi cal pixels and device-independent pixels.");
197 rowElement.createChild("td").appendChild(document.createTextNode(WebInsp ector.UIString("Device pixel ratio:"))); 230 rowElement.createChild("td").appendChild(document.createTextNode(WebInsp ector.UIString("Device pixel ratio:")));
198 rowElement.createChild("td").appendChild(WebInspector.SettingsUI.createS ettingInputField("", WebInspector.overridesSupport.settings.deviceScaleFactor, t rue, 4, "80px", WebInspector.OverridesSupport.deviceScaleFactorValidator, true, true, WebInspector.UIString("--"))); 231 rowElement.createChild("td").appendChild(WebInspector.SettingsUI.createS ettingInputField("", WebInspector.overridesSupport.settings.deviceScaleFactor, t rue, 4, "80px", WebInspector.OverridesSupport.deviceScaleFactorValidator, true, true, WebInspector.UIString("\u2013")));
199 232
200 var viewportCheckbox = this._createSettingCheckbox(WebInspector.UIString ("Emulate mobile"), WebInspector.overridesSupport.settings.emulateViewport); 233 var viewportCheckbox = this._createSettingCheckbox(WebInspector.UIString ("Emulate mobile"), WebInspector.overridesSupport.settings.emulateViewport);
201 viewportCheckbox.title = WebInspector.UIString("Enable meta viewport, ov erlay scrollbars and default 980px body width"); 234 viewportCheckbox.title = WebInspector.UIString("Enable meta viewport, ov erlay scrollbars and default 980px body width");
202 fieldsetElement.appendChild(viewportCheckbox); 235 fieldsetElement.appendChild(viewportCheckbox);
203 236
204 // FIXME: move text autosizing to the "misc" tab together with css media , and separate it from device emulation. 237 // FIXME: move text autosizing to the "misc" tab together with css media , and separate it from device emulation.
205 var textAutosizingOverrideElement = this._createSettingCheckbox(WebInspe ctor.UIString("Enable text autosizing "), WebInspector.overridesSupport.settings .deviceTextAutosizing); 238 var textAutosizingOverrideElement = this._createSettingCheckbox(WebInspe ctor.UIString("Enable text autosizing "), WebInspector.overridesSupport.settings .deviceTextAutosizing);
206 textAutosizingOverrideElement.title = WebInspector.UIString("Text autosi zing is the feature that boosts font sizes on mobile devices."); 239 textAutosizingOverrideElement.title = WebInspector.UIString("Text autosi zing is the feature that boosts font sizes on mobile devices.");
207 fieldsetElement.appendChild(textAutosizingOverrideElement); 240 fieldsetElement.appendChild(textAutosizingOverrideElement);
208 241
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 630
598 __proto__ : WebInspector.OverridesView.Tab.prototype 631 __proto__ : WebInspector.OverridesView.Tab.prototype
599 } 632 }
600 633
601 /** @enum {string} */ 634 /** @enum {string} */
602 WebInspector.OverridesView.SensorsTab.DeviceOrientationModificationSource = { 635 WebInspector.OverridesView.SensorsTab.DeviceOrientationModificationSource = {
603 UserInput: "userInput", 636 UserInput: "userInput",
604 UserDrag: "userDrag", 637 UserDrag: "userDrag",
605 ResetButton: "resetButton" 638 ResetButton: "resetButton"
606 } 639 }
640
641 /**
642 * @constructor
643 * @implements {WebInspector.Revealer}
644 */
645 WebInspector.OverridesView.Revealer = function()
646 {
647 }
648
649 WebInspector.OverridesView.Revealer.prototype = {
650 /**
651 * @param {!Object} overridesSupport
652 */
653 reveal: function(overridesSupport)
654 {
655 InspectorFrontendHost.bringToFront();
656 WebInspector.inspectorView.showViewInDrawer("emulation");
657 }
658 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/ResponsiveDesignView.js ('k') | Source/devtools/front_end/elements/module.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698