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

Side by Side Diff: chrome/browser/resources/settings/controls/settings_input.js

Issue 2631863002: MD Settings: Use "change" event instead of "blur" for settings-input. (Closed)
Patch Set: fix Created 3 years, 11 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
« no previous file with comments | « chrome/browser/resources/settings/controls/settings_input.html ('k') | 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 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 * @fileoverview 6 * @fileoverview
7 * `settings-input` is a single-line text field for user input associated 7 * `settings-input` is a single-line text field for user input associated
8 * with a pref value. 8 * with a pref value.
9 */ 9 */
10 Polymer({ 10 Polymer({
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 * Gets a tab index for this control if it can be tabbed to. 83 * Gets a tab index for this control if it can be tabbed to.
84 * @param {boolean} canTab 84 * @param {boolean} canTab
85 * @return {number} 85 * @return {number}
86 * @private 86 * @private
87 */ 87 */
88 getTabindex_: function(canTab) { 88 getTabindex_: function(canTab) {
89 return canTab ? 0 : -1; 89 return canTab ? 0 : -1;
90 }, 90 },
91 91
92 /** 92 /**
93 * Blur method for paper-input. Only update the pref value on a blur event. 93 * Change event handler for paper-input. Updates the pref value.
94 * settings-input uses the change event because it is fired by the Enter key.
94 * @private 95 * @private
95 */ 96 */
96 onBlur_: function() { 97 onChange_: function() {
97 if (!this.pref) 98 if (!this.pref)
98 return; 99 return;
99 100
100 if (this.pref.type == chrome.settingsPrivate.PrefType.NUMBER) { 101 if (this.pref.type == chrome.settingsPrivate.PrefType.NUMBER) {
101 if (!this.value) { 102 if (!this.value) {
102 // Ignore empty input field and restore value. 103 // Ignore empty input field and restore value.
103 this.value = this.pref.value.toString(); 104 this.value = this.pref.value.toString();
104 return; 105 return;
105 } 106 }
106 var n = parseInt(this.value, 10); 107 var n = parseInt(this.value, 10);
(...skipping 12 matching lines...) Expand all
119 /** 120 /**
120 * @param {boolean} disabled 121 * @param {boolean} disabled
121 * @param {!chrome.settingsPrivate.PrefObject} pref 122 * @param {!chrome.settingsPrivate.PrefObject} pref
122 * @return {boolean} Whether the element should be disabled. 123 * @return {boolean} Whether the element should be disabled.
123 * @private 124 * @private
124 */ 125 */
125 isDisabled_: function(disabled, pref) { 126 isDisabled_: function(disabled, pref) {
126 return disabled || this.isPrefPolicyControlled(pref); 127 return disabled || this.isPrefPolicyControlled(pref);
127 }, 128 },
128 }); 129 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/controls/settings_input.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698