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

Side by Side Diff: Source/devtools/front_end/ui/SettingsUI.js

Issue 365923002: [DevTools] Allow arrow keys to increment/decrement value in numeric inputs. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 if (validatorCallback) 125 if (validatorCallback)
126 validate(); 126 validate();
127 if (instant) 127 if (instant)
128 apply(); 128 apply();
129 } 129 }
130 130
131 function onKeyDown(event) 131 function onKeyDown(event)
132 { 132 {
133 if (isEnterKey(event)) 133 if (isEnterKey(event))
134 apply(); 134 apply();
135 incrementForArrows(event);
136 }
137
138 function incrementForArrows(event)
139 {
140 if (!numeric)
141 return;
142
143 var increment = event.keyIdentifier === "Up" ? 1 : event.keyIdentifier = == "Down" ? -1 : 0;
144 if (!increment)
145 return;
146 if (event.shiftKey)
147 increment *= 10;
148
149 var value = inputElement.value;
150 if (validatorCallback && validatorCallback(value))
vsevik 2014/07/02 15:17:25 Looks like this is not really needed.
dgozman 2014/07/02 15:50:17 This is to do nothing if user enters "abc" and pre
151 return;
152 value = Number(value);
153 if (clearForZero && !value)
vsevik 2014/07/02 15:17:25 So we'll never increment zero?
dgozman 2014/07/02 15:50:17 Yes, if we replace zero value by empty string (use
154 return;
155 value += increment;
156 if (clearForZero && !value)
vsevik 2014/07/02 15:17:25 Why?
dgozman 2014/07/02 15:50:17 Same reasons. I don't want to switch from "1" to e
157 return;
158 value = String(value);
159 if (validatorCallback && validatorCallback(value))
160 return;
161
162 inputElement.value = value;
163 apply();
164 event.preventDefault();
135 } 165 }
136 166
137 function validate() 167 function validate()
138 { 168 {
139 var error = validatorCallback(inputElement.value); 169 var error = validatorCallback(inputElement.value);
140 if (!error) 170 if (!error)
141 error = ""; 171 error = "";
142 inputElement.classList.toggle("error-input", !!error); 172 inputElement.classList.toggle("error-input", !!error);
143 errorMessageLabel.textContent = error; 173 errorMessageLabel.textContent = error;
144 } 174 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 288
259 WebInspector.UISettingDelegate.prototype = { 289 WebInspector.UISettingDelegate.prototype = {
260 /** 290 /**
261 * @return {?Element} 291 * @return {?Element}
262 */ 292 */
263 settingElement: function() 293 settingElement: function()
264 { 294 {
265 return null; 295 return null;
266 } 296 }
267 } 297 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698