6 is: 'paper-input-container',
11 * Set to true to disable the floating label. The label disappears when the input value is
20 * Set to true to always float the floating label.
28 * The attribute to listen for value changes on.
36 * Set to true to auto-validate the input value when it changes.
44 * True if the input is invalid. This property is set automatically when the input value
45 * changes if auto-validating, or when the `iron-input-valid` event is heard from a child.
48 observer: '_invalidChanged',
54 * True if the input has focus.
64 // do not set a default value here intentionally - it will be initialized lazily when a
65 // distributed child is attached, which may occur before configuration for this element
76 value: 'input,textarea,.paper-input-input'
82 return this._onFocus.bind(this);
89 return this._onBlur.bind(this);
96 return this._onInput.bind(this);
100 _boundValueChanged: {
103 return this._onValueChanged.bind(this);
110 'addon-attached': '_onAddonAttached',
111 'iron-input-validate': '_onIronInputValidate'
114 get _valueChangedEvent() {
115 return this.attrForValue + '-changed';
118 get _propertyForValue() {
119 return Polymer.CaseMap.dashToCamelCase(this.attrForValue);
122 get _inputElement() {
123 return Polymer.dom(this).querySelector(this._inputSelector);
130 this.addEventListener('focus', this._boundOnFocus, true);
131 this.addEventListener('blur', this._boundOnBlur, true);
132 if (this.attrForValue) {
133 this._inputElement.addEventListener(this._valueChangedEvent, this._boundValueChanged);
135 this.addEventListener('input', this._onInput);
139 attached: function() {
140 this._handleValue(this._inputElement);
143 _onAddonAttached: function(event) {
147 var target = event.target;
148 if (this._addons.indexOf(target) === -1) {
149 this._addons.push(target);
150 if (this.isAttached) {
151 this._handleValue(this._inputElement);
156 _onFocus: function() {
157 this._setFocused(true);
160 _onBlur: function() {
161 this._setFocused(false);
164 _onInput: function(event) {
165 this._handleValue(event.target);
168 _onValueChanged: function(event) {
169 this._handleValue(event.target);
172 _handleValue: function(inputElement) {
173 var value = inputElement[this._propertyForValue] || inputElement.value;
175 if (this.autoValidate) {
177 if (inputElement.validate) {
178 valid = inputElement.validate(value);
180 valid = inputElement.checkValidity();
182 this.invalid = !valid;
185 // type="number" hack needed because this.value is empty until it's valid
186 if (value || (inputElement.type === 'number' && !inputElement.checkValidity())) {
187 this._inputHasContent = true;
189 this._inputHasContent = false;
193 inputElement: inputElement,
195 invalid: this.invalid
199 _onIronInputValidate: function(event) {
200 this.invalid = this._inputElement.invalid;
203 _invalidChanged: function() {
205 this.updateAddons({invalid: this.invalid});
210 * Call this to update the state of add-ons.
211 * @param {Object} state Add-on state.
213 updateAddons: function(state) {
214 for (var addon, index = 0; addon = this._addons[index]; index++) {
219 _computeInputContentClass: function(noLabelFloat, alwaysFloatLabel, focused, invalid, _inputHasContent) {
220 var cls = 'input-content';
222 if (alwaysFloatLabel || _inputHasContent) {
223 cls += ' label-is-floating';
225 cls += ' is-invalid';
226 } else if (focused) {
227 cls += " label-is-highlighted";
231 if (_inputHasContent) {
232 cls += ' label-is-hidden';
238 _computeUnderlineClass: function(focused, invalid) {
239 var cls = 'underline';
241 cls += ' is-invalid';
242 } else if (focused) {
243 cls += ' is-highlighted'
248 _computeAddOnContentClass: function(focused, invalid) {
249 var cls = 'add-on-content';
251 cls += ' is-invalid';
252 } else if (focused) {
253 cls += ' is-highlighted'