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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/emulation/SensorsView.js

Issue 1923393006: DevTools: fix styles and input validation in sensor pane (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Orientation labels now alpha-beta-gamma Created 4 years, 7 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
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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.VBox} 7 * @extends {WebInspector.VBox}
8 */ 8 */
9 WebInspector.SensorsView = function() 9 WebInspector.SensorsView = function()
10 { 10 {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 // Validated input fieldset. 60 // Validated input fieldset.
61 this._fieldsetElement = fields.createChild("fieldset"); 61 this._fieldsetElement = fields.createChild("fieldset");
62 this._fieldsetElement.disabled = !this._geolocationOverrideEnabled; 62 this._fieldsetElement.disabled = !this._geolocationOverrideEnabled;
63 this._fieldsetElement.id = "geolocation-override-section"; 63 this._fieldsetElement.id = "geolocation-override-section";
64 64
65 var latitudeGroup = this._fieldsetElement.createChild("div", "latlong-gr oup"); 65 var latitudeGroup = this._fieldsetElement.createChild("div", "latlong-gr oup");
66 var longitudeGroup = this._fieldsetElement.createChild("div", "latlong-g roup"); 66 var longitudeGroup = this._fieldsetElement.createChild("div", "latlong-g roup");
67 67
68 this._latitudeInput = latitudeGroup.createChild("input"); 68 this._latitudeInput = latitudeGroup.createChild("input");
69 this._latitudeInput.setAttribute("type", "text"); 69 this._latitudeInput.setAttribute("type", "number");
70 this._latitudeInput.value = 0; 70 this._latitudeInput.value = 0;
71 WebInspector.bindInput(this._latitudeInput, this._applyGeolocationUserIn put.bind(this), WebInspector.Geolocation.latitudeValidator, true)(String(geoloca tion.latitude)); 71 this._latitudeSetter = WebInspector.bindInput(this._latitudeInput, this. _applyGeolocationUserInput.bind(this), WebInspector.Geolocation.latitudeValidato r, true);
72 this._latitudeSetter(String(geolocation.latitude));
72 73
73 this._longitudeInput = longitudeGroup.createChild("input"); 74 this._longitudeInput = longitudeGroup.createChild("input");
74 this._longitudeInput.setAttribute("type", "text"); 75 this._longitudeInput.setAttribute("type", "number");
75 this._longitudeInput.value = 0; 76 this._longitudeInput.value = 0;
76 WebInspector.bindInput(this._longitudeInput, this._applyGeolocationUserI nput.bind(this), WebInspector.Geolocation.longitudeValidator, true)(String(geolo cation.longitude)); 77 this._longitudeSetter = WebInspector.bindInput(this._longitudeInput, thi s._applyGeolocationUserInput.bind(this), WebInspector.Geolocation.longitudeValid ator, true);
78 this._longitudeSetter(String(geolocation.longitude));
77 79
78 latitudeGroup.createChild("div", "latlong-title").textContent = WebInspe ctor.UIString("Latitude"); 80 latitudeGroup.createChild("div", "latlong-title").textContent = WebInspe ctor.UIString("Latitude");
79 longitudeGroup.createChild("div", "latlong-title").textContent = WebInsp ector.UIString("Longitude"); 81 longitudeGroup.createChild("div", "latlong-title").textContent = WebInsp ector.UIString("Longitude");
80 }, 82 },
81 83
82 _geolocationSelectChanged: function() 84 _geolocationSelectChanged: function()
83 { 85 {
84 this._fieldsetElement.disabled = false; 86 this._fieldsetElement.disabled = false;
85 var value = this._locationSelectElement.options[this._locationSelectElem ent.selectedIndex].value; 87 var value = this._locationSelectElement.options[this._locationSelectElem ent.selectedIndex].value;
86 if (value === WebInspector.SensorsView.NonPresetOptions.NoOverride) { 88 if (value === WebInspector.SensorsView.NonPresetOptions.NoOverride) {
87 this._geolocationOverrideEnabled = false; 89 this._geolocationOverrideEnabled = false;
88 this._fieldsetElement.disabled = true; 90 this._fieldsetElement.disabled = true;
89 } else if (value === WebInspector.SensorsView.NonPresetOptions.Custom) { 91 } else if (value === WebInspector.SensorsView.NonPresetOptions.Custom) {
90 this._geolocationOverrideEnabled = true; 92 this._geolocationOverrideEnabled = true;
91 } else if (value === WebInspector.SensorsView.NonPresetOptions.Unavailab le) { 93 } else if (value === WebInspector.SensorsView.NonPresetOptions.Unavailab le) {
92 this._geolocationOverrideEnabled = true; 94 this._geolocationOverrideEnabled = true;
93 this._geolocation = new WebInspector.Geolocation(0, 0, true); 95 this._geolocation = new WebInspector.Geolocation(0, 0, true);
94 } else { 96 } else {
95 this._geolocationOverrideEnabled = true; 97 this._geolocationOverrideEnabled = true;
96 var coordinates = JSON.parse(value); 98 var coordinates = JSON.parse(value);
97 this._geolocation = new WebInspector.Geolocation(coordinates[0], coo rdinates[1], false); 99 this._geolocation = new WebInspector.Geolocation(coordinates[0], coo rdinates[1], false);
98 this._latitudeInput.value = coordinates[0]; 100 this._latitudeSetter(coordinates[0]);
99 this._longitudeInput.value = coordinates[1]; 101 this._longitudeSetter(coordinates[1]);
100 } 102 }
101 103
102 this._applyGeolocation(); 104 this._applyGeolocation();
103 if (value === WebInspector.SensorsView.NonPresetOptions.Custom) 105 if (value === WebInspector.SensorsView.NonPresetOptions.Custom)
104 this._latitudeInput.focus(); 106 this._latitudeInput.focus();
105 }, 107 },
106 108
107 _applyGeolocationUserInput: function() 109 _applyGeolocationUserInput: function()
108 { 110 {
109 var geolocation = WebInspector.Geolocation.parseUserInput(this._latitude Input.value.trim(), this._longitudeInput.value.trim(), ""); 111 var geolocation = WebInspector.Geolocation.parseUserInput(this._latitude Input.value.trim(), this._longitudeInput.value.trim(), "");
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 197
196 _applyDeviceOrientationUserInput: function() 198 _applyDeviceOrientationUserInput: function()
197 { 199 {
198 this._setDeviceOrientation(WebInspector.DeviceOrientation.parseUserInput (this._alphaElement.value.trim(), this._betaElement.value.trim(), this._gammaEle ment.value.trim()), WebInspector.SensorsView.DeviceOrientationModificationSource .UserInput); 200 this._setDeviceOrientation(WebInspector.DeviceOrientation.parseUserInput (this._alphaElement.value.trim(), this._betaElement.value.trim(), this._gammaEle ment.value.trim()), WebInspector.SensorsView.DeviceOrientationModificationSource .UserInput);
199 this._setSelectElementLabel(this._orientationSelectElement, WebInspector .SensorsView.NonPresetOptions.Custom); 201 this._setSelectElementLabel(this._orientationSelectElement, WebInspector .SensorsView.NonPresetOptions.Custom);
200 }, 202 },
201 203
202 _resetDeviceOrientation: function() 204 _resetDeviceOrientation: function()
203 { 205 {
204 this._setDeviceOrientation(new WebInspector.DeviceOrientation(0, 0, 0), WebInspector.SensorsView.DeviceOrientationModificationSource.ResetButton); 206 this._setDeviceOrientation(new WebInspector.DeviceOrientation(0, 0, 0), WebInspector.SensorsView.DeviceOrientationModificationSource.ResetButton);
207 this._setSelectElementLabel(this._orientationSelectElement, "[0, 0, 0]") ;
205 }, 208 },
206 209
207 /** 210 /**
208 * @param {?WebInspector.DeviceOrientation} deviceOrientation 211 * @param {?WebInspector.DeviceOrientation} deviceOrientation
209 * @param {!WebInspector.SensorsView.DeviceOrientationModificationSource} mo dificationSource 212 * @param {!WebInspector.SensorsView.DeviceOrientationModificationSource} mo dificationSource
210 */ 213 */
211 _setDeviceOrientation: function(deviceOrientation, modificationSource) 214 _setDeviceOrientation: function(deviceOrientation, modificationSource)
212 { 215 {
213 if (!deviceOrientation) 216 if (!deviceOrientation)
214 return; 217 return;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 */ 261 */
259 _createDeviceOrientationOverrideElement: function(deviceOrientation) 262 _createDeviceOrientationOverrideElement: function(deviceOrientation)
260 { 263 {
261 var fieldsetElement = createElement("fieldset"); 264 var fieldsetElement = createElement("fieldset");
262 fieldsetElement.classList.add("device-orientation-override-section"); 265 fieldsetElement.classList.add("device-orientation-override-section");
263 var tableElement = fieldsetElement.createChild("table"); 266 var tableElement = fieldsetElement.createChild("table");
264 var rowElement = tableElement.createChild("tr"); 267 var rowElement = tableElement.createChild("tr");
265 var cellElement = rowElement.createChild("td", "accelerometer-inputs-cel l"); 268 var cellElement = rowElement.createChild("td", "accelerometer-inputs-cel l");
266 269
267 this._alphaElement = createElement("input"); 270 this._alphaElement = createElement("input");
268 this._alphaSetter = this._createAxisInput(cellElement, this._alphaElemen t, WebInspector.UIString("Tilt left/right (\u03B1)")); 271 this._alphaSetter = this._createAxisInput(cellElement, this._alphaElemen t, WebInspector.UIString("\u03B1 (alpha)"));
269 this._alphaSetter(String(deviceOrientation.alpha)); 272 this._alphaSetter(String(deviceOrientation.alpha));
270 273
271 this._betaElement = createElement("input"); 274 this._betaElement = createElement("input");
272 this._betaSetter = this._createAxisInput(cellElement, this._betaElement, WebInspector.UIString("Tilt front/back (\u03B2)")); 275 this._betaSetter = this._createAxisInput(cellElement, this._betaElement, WebInspector.UIString("\u03B2 (beta)"));
273 this._betaSetter(String(deviceOrientation.beta)); 276 this._betaSetter(String(deviceOrientation.beta));
274 277
275 this._gammaElement = createElement("input"); 278 this._gammaElement = createElement("input");
276 this._gammaSetter = this._createAxisInput(cellElement, this._gammaElemen t, WebInspector.UIString("Rotate (\u03B3)")); 279 this._gammaSetter = this._createAxisInput(cellElement, this._gammaElemen t, WebInspector.UIString("\u03B3 (gamma)"));
277 this._gammaSetter(String(deviceOrientation.gamma)); 280 this._gammaSetter(String(deviceOrientation.gamma));
278 281
279 cellElement.appendChild(createTextButton(WebInspector.UIString("Reset"), this._resetDeviceOrientation.bind(this), "accelerometer-reset-button")); 282 cellElement.appendChild(createTextButton(WebInspector.UIString("Reset"), this._resetDeviceOrientation.bind(this), "accelerometer-reset-button"));
280 283
281 this._stageElement = rowElement.createChild("td","accelerometer-stage"); 284 this._stageElement = rowElement.createChild("td","accelerometer-stage");
282 this._boxElement = this._stageElement.createChild("section", "accelerome ter-box"); 285 this._boxElement = this._stageElement.createChild("section", "accelerome ter-box");
283 286
284 this._boxElement.createChild("section", "front"); 287 this._boxElement.createChild("section", "front");
285 this._boxElement.createChild("section", "top"); 288 this._boxElement.createChild("section", "top");
286 this._boxElement.createChild("section", "back"); 289 this._boxElement.createChild("section", "back");
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 * @param {!WebInspector.Context} context 472 * @param {!WebInspector.Context} context
470 * @param {string} actionId 473 * @param {string} actionId
471 * @return {boolean} 474 * @return {boolean}
472 */ 475 */
473 handleAction: function(context, actionId) 476 handleAction: function(context, actionId)
474 { 477 {
475 WebInspector.inspectorView.showViewInDrawer("sensors"); 478 WebInspector.inspectorView.showViewInDrawer("sensors");
476 return true; 479 return true;
477 } 480 }
478 } 481 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698