| OLD | NEW |
| 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 18 matching lines...) Expand all Loading... |
| 29 notify: true, | 29 notify: true, |
| 30 }, | 30 }, |
| 31 | 31 |
| 32 /* Set to true to disable editing the input. */ | 32 /* Set to true to disable editing the input. */ |
| 33 disabled: { | 33 disabled: { |
| 34 type: Boolean, | 34 type: Boolean, |
| 35 value: false, | 35 value: false, |
| 36 reflectToAttribute: true | 36 reflectToAttribute: true |
| 37 }, | 37 }, |
| 38 | 38 |
| 39 canTab: Boolean, |
| 40 |
| 39 /* Properties for paper-input. This is not strictly necessary. | 41 /* Properties for paper-input. This is not strictly necessary. |
| 40 * Though it does define the types for the closure compiler. */ | 42 * Though it does define the types for the closure compiler. */ |
| 41 errorMessage: { type: String }, | 43 errorMessage: { type: String }, |
| 42 label: { type: String }, | 44 label: { type: String }, |
| 43 noLabelFloat: { type: Boolean, value: false }, | 45 noLabelFloat: { type: Boolean, value: false }, |
| 44 pattern: { type: String }, | 46 pattern: { type: String }, |
| 45 readonly: { type: Boolean, value: false }, | 47 readonly: { type: Boolean, value: false }, |
| 46 required: { type: Boolean, value: false }, | 48 required: { type: Boolean, value: false }, |
| 47 stopKeyboardEventPropagation: { type: Boolean, value: false }, | 49 stopKeyboardEventPropagation: { type: Boolean, value: false }, |
| 48 type: { type: String }, | 50 type: { type: String }, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 71 if (this.pref.type == chrome.settingsPrivate.PrefType.NUMBER) { | 73 if (this.pref.type == chrome.settingsPrivate.PrefType.NUMBER) { |
| 72 this.value = this.pref.value.toString(); | 74 this.value = this.pref.value.toString(); |
| 73 } else { | 75 } else { |
| 74 assert(this.pref.type == chrome.settingsPrivate.PrefType.STRING || | 76 assert(this.pref.type == chrome.settingsPrivate.PrefType.STRING || |
| 75 this.pref.type == chrome.settingsPrivate.PrefType.URL); | 77 this.pref.type == chrome.settingsPrivate.PrefType.URL); |
| 76 this.value = /** @type {string} */(this.pref.value); | 78 this.value = /** @type {string} */(this.pref.value); |
| 77 } | 79 } |
| 78 }, | 80 }, |
| 79 | 81 |
| 80 /** | 82 /** |
| 83 * Gets a tab index for this control if it can be tabbed to. |
| 84 * @param {boolean} canTab |
| 85 * @return {number} |
| 86 * @private |
| 87 */ |
| 88 getTabindex_: function(canTab) { |
| 89 return canTab ? 0 : -1; |
| 90 }, |
| 91 |
| 92 /** |
| 81 * Blur method for paper-input. Only update the pref value on a blur event. | 93 * Blur method for paper-input. Only update the pref value on a blur event. |
| 82 * @private | 94 * @private |
| 83 */ | 95 */ |
| 84 onBlur_: function() { | 96 onBlur_: function() { |
| 85 if (!this.pref) | 97 if (!this.pref) |
| 86 return; | 98 return; |
| 87 | 99 |
| 88 if (this.pref.type == chrome.settingsPrivate.PrefType.NUMBER) { | 100 if (this.pref.type == chrome.settingsPrivate.PrefType.NUMBER) { |
| 89 if (!this.value) { | 101 if (!this.value) { |
| 90 // Ignore empty input field and restore value. | 102 // Ignore empty input field and restore value. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 107 /** | 119 /** |
| 108 * @param {boolean} disabled | 120 * @param {boolean} disabled |
| 109 * @param {!chrome.settingsPrivate.PrefObject} pref | 121 * @param {!chrome.settingsPrivate.PrefObject} pref |
| 110 * @return {boolean} Whether the element should be disabled. | 122 * @return {boolean} Whether the element should be disabled. |
| 111 * @private | 123 * @private |
| 112 */ | 124 */ |
| 113 isDisabled_: function(disabled, pref) { | 125 isDisabled_: function(disabled, pref) { |
| 114 return disabled || this.isPrefPolicyControlled(pref); | 126 return disabled || this.isPrefPolicyControlled(pref); |
| 115 }, | 127 }, |
| 116 }); | 128 }); |
| OLD | NEW |