Chromium Code Reviews| Index: ui/webui/resources/cr_elements/cr_input/cr_input.js |
| diff --git a/ui/webui/resources/cr_elements/cr_input/cr_input.js b/ui/webui/resources/cr_elements/cr_input/cr_input.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2179c91da250b2c1f1c79db9fd8f6e5c2e60084f |
| --- /dev/null |
| +++ b/ui/webui/resources/cr_elements/cr_input/cr_input.js |
| @@ -0,0 +1,120 @@ |
| +/* Copyright 2015 The Chromium Authors. All rights reserved. |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. */ |
| + |
| +/** |
| + * @fileoverview |
| + * 'cr-input` is a single-line text field for user input. It is a convenience |
| + * element composed of a`paper-input-decorator` and a `input is="core-input". |
|
michaelpg
2015/02/13 00:08:29
missing space: a `paper-input-decorator`
missing c
Jeremy Klein
2015/02/13 00:22:55
Done.
|
| + * |
| + * Example: |
| + * |
| + * <cr-input></cr-input> |
| + * |
| + * @group Chrome Elements |
| + * @element cr-input |
| + */ |
| +Polymer('cr-input', { |
| + publish: { |
| + /** |
| + * The label for this input. It normally appears as grey text inside |
| + * the text input and disappears once the user enters text. |
| + * |
| + * @attribute label |
| + * @type string |
| + * @default '' |
| + */ |
| + label: '', |
| + |
| + /** |
| + * If true, the label will "float" above the text input once the |
| + * user enters text instead of disappearing. |
| + * |
| + * @attribute floatingLabel |
| + * @type boolean |
| + * @default true |
| + */ |
| + floatingLabel: true, |
| + |
| + /** |
| + * Set to true to style the element as disabled. |
| + * |
| + * @attribute disabled |
| + * @type boolean |
| + * @default false |
| + */ |
| + disabled: {value: false, reflect: true}, |
| + |
| + /** |
| + * Set to true to mark the input as required. |
| + * |
| + * @attribute required |
| + * @type boolean |
| + * @default false |
| + */ |
| + required: {value: false, reflect: true}, |
| + |
| + /** |
| + * The current value of the input. |
| + * |
| + * @attribute value |
| + * @type String |
|
michaelpg
2015/02/13 00:08:29
lower case
Jeremy Klein
2015/02/13 00:22:55
I took this from the Polymer elements docs. Appare
|
| + * @default '' |
| + */ |
| + value: '', |
| + |
| + /** |
| + * The validation pattern for the input. |
| + * |
| + * @attribute pattern |
| + * @type String |
|
michaelpg
2015/02/13 00:08:29
lower case
Jeremy Klein
2015/02/13 00:22:55
Done.
|
| + * @default '' |
| + */ |
| + pattern: '', |
| + |
| + /** |
| + * The type of the input (password, date, etc.). |
| + * |
| + * @attribute type |
| + * @type String |
|
michaelpg
2015/02/13 00:08:29
lower case
Jeremy Klein
2015/02/13 00:22:55
Done.
|
| + * @default 'text' |
| + */ |
| + type: 'text', |
| + |
| + /** |
| + * The message to display if the input value fails validation. If this |
| + * is unset or the empty string, a default message is displayed depending |
| + * on the type of validation error. |
| + * |
| + * @attribute error |
| + * @type string |
| + */ |
| + error: '', |
| + |
| + /** |
| + * The most recently committed value of the input. |
| + * |
| + * @attribute committedValue |
| + * @type String |
|
michaelpg
2015/02/13 00:08:29
lower case
Jeremy Klein
2015/02/13 00:22:55
Done.
|
| + * @default '' |
| + */ |
| + committedValue: '' |
| + }, |
| + |
| + /** |
| + * Focuses the `input`. |
| + * |
| + * @method focus |
| + */ |
| + focus: function() { |
| + this.$.input.focus(); |
| + }, |
| + |
| + valueChanged: function() { |
| + this.$.decorator.updateLabelVisibility(this.value); |
| + }, |
| + |
| + ready: function() { |
| + this.$.events.forward(this.$.input, ['change']); |
| + }, |
| +}); |