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
3 * found in the LICENSE file. */
7 * 'cr-input' is a single-line text field for user input. It is a convenience
8 * element composed of a 'paper-input-decorator' and a 'input is="core-input"'.
12 * <cr-input></cr-input>
14 * @group Chrome Elements
20 * The label for this input. It normally appears as grey text inside
21 * the text input and disappears once the user enters text.
30 * If true, the label will "float" above the text input once the
31 * user enters text instead of disappearing.
33 * @attribute floatingLabel
40 * Set to true to style the element as disabled.
46 disabled: {value: false, reflect: true},
49 * Set to true to mark the input as required.
55 required: {value: false, reflect: true},
58 * The current value of the input.
67 * The validation pattern for the input.
76 * The type of the input (password, date, etc.).
85 * The message to display if the input value fails validation. If this
86 * is unset or the empty string, a default message is displayed depending
87 * on the type of validation error.
96 * The most recently committed value of the input.
98 * @attribute committedValue
106 * Focuses the 'input' element.
109 this.$.input.focus();
112 valueChanged: function() {
113 this.$.decorator.updateLabelVisibility(this.value);
116 patternChanged: function() {
118 this.$.input.pattern = this.pattern;
120 this.$.input.removeAttribute('pattern');
125 this.$.events.forward(this.$.input, ['change']);
126 this.patternChanged();