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

Side by Side Diff: ui/webui/resources/cr_elements/cr_input/cr_input.js

Issue 918913002: Add a <cr-input> element to cr_elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed line-length issues. Created 5 years, 10 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
OLDNEW
(Empty)
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. */
4
5 /**
6 * @fileoverview
7 * 'cr-input` is a single-line text field for user input. It is a convenience
Dan Beam 2015/02/20 23:45:46 why ' + ` ?
Jeremy Klein 2015/02/20 23:59:21 Ha, good catch. The back ticks are totally copy-pa
michaelpg 2015/02/21 00:13:07 we've been using `s because the polymer doc genera
8 * element composed of a `paper-input-decorator` and a `input is="core-input".
Dan Beam 2015/02/20 23:45:46 think you're missing a ` here
Jeremy Klein 2015/02/20 23:59:21 Done.
9 *
10 * Example:
11 *
12 * <cr-input></cr-input>
13 *
14 * @group Chrome Elements
15 * @element cr-input
16 */
17 Polymer('cr-input', {
18 publish: {
19 /**
20 * The label for this input. It normally appears as grey text inside
21 * the text input and disappears once the user enters text.
22 *
23 * @attribute label
24 * @type string
25 * @default ''
26 */
27 label: '',
28
29 /**
30 * If true, the label will "float" above the text input once the
31 * user enters text instead of disappearing.
32 *
33 * @attribute floatingLabel
34 * @type boolean
35 * @default true
Dan Beam 2015/02/20 23:45:47 why do we have all these duplicate @defaults?
Jeremy Klein 2015/02/20 23:59:21 Yeah I also feel like this is excessive, but for t
Jeremy Klein 2015/02/21 00:15:37 Just revisited the 0.8 primer (which seems to have
36 */
37 floatingLabel: true,
38
39 /**
40 * Set to true to style the element as disabled.
41 *
42 * @attribute disabled
43 * @type boolean
44 * @default false
45 */
46 disabled: {value: false, reflect: true},
47
48 /**
49 * Set to true to mark the input as required.
50 *
51 * @attribute required
52 * @type boolean
53 * @default false
54 */
55 required: {value: false, reflect: true},
56
57 /**
58 * The current value of the input.
59 *
60 * @attribute value
61 * @type string
62 * @default ''
63 */
64 value: '',
65
66 /**
67 * The validation pattern for the input.
68 *
69 * @attribute pattern
70 * @type string
71 * @default ''
72 */
73 pattern: '',
74
75 /**
76 * The type of the input (password, date, etc.).
77 *
78 * @attribute type
79 * @type string
80 * @default 'text'
81 */
82 type: 'text',
83
84 /**
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.
88 *
89 * @attribute error
90 * @type string
Dan Beam 2015/02/20 23:45:46 why no @default? or conversely, why not no @defau
Jeremy Klein 2015/02/20 23:59:21 Done.
91 */
92 error: '',
93
94 /**
95 * The most recently committed value of the input.
96 *
97 * @attribute committedValue
98 * @type string
99 * @default ''
100 */
101 committedValue: ''
102 },
103
104 /**
105 * Focuses the `input`.
106 *
107 * @method focus
Dan Beam 2015/02/20 23:45:46 useless
Jeremy Klein 2015/02/20 23:59:21 Yeah I hate this doc. Removed for now since we don
michaelpg 2015/02/21 00:13:07 :-\ this indicates which methods are considered "p
108 */
109 focus: function() {
110 this.$.input.focus();
111 },
112
113 valueChanged: function() {
114 this.$.decorator.updateLabelVisibility(this.value);
115 },
116
117 patternChanged: function() {
118 if (this.pattern) {
Dan Beam 2015/02/20 23:45:46 nit: most of webui has no curlies
Jeremy Klein 2015/02/20 23:59:21 Done.
119 this.$.input.pattern = this.pattern;
120 } else {
121 this.$.input.removeAttribute('pattern');
122 }
123 },
124
Dan Beam 2015/02/20 23:45:46 /** @override */ on all these?
Jeremy Klein 2015/02/20 23:59:21 Done for ready. Not really sure what to put for th
125 ready: function() {
126 this.$.events.forward(this.$.input, ['change']);
127 this.patternChanged();
128 },
129 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698