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

Side by Side Diff: third_party/polymer/v1_0/components-chromium/paper-input/paper-input-behavior-extracted.js

Issue 1162963002: Revert "Rename polymer and cr_elements v0_8 to v1_0" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
2
3 /**
4 * Use `Polymer.PaperInputBehavior` to implement inputs with `<paper-input-con tainer>`. This
5 * behavior is implemented by `<paper-input>`. It exposes a number of properti es from
6 * `<paper-input-container>` and `<input is="iron-input">` and they should be bound in your
7 * template.
8 *
9 * The input element can be accessed by the `inputElement` property if you nee d to access
10 * properties or methods that are not exposed.
11 * @polymerBehavior
12 */
13 Polymer.PaperInputBehavior = {
14
15 properties: {
16
17 /**
18 * The label for this input. Bind this to `<paper-input-container>`'s `lab el` property.
19 */
20 label: {
21 type: String
22 },
23
24 /**
25 * The value for this input. Bind this to the `<input is="iron-input">`'s `bindValue`
26 * property, or the value property of your input that is `notify:true`.
27 */
28 value: {
29 notify: true,
30 type: String
31 },
32
33 /**
34 * Set to true to disable this input. Bind this to both the `<paper-input- container>`'s
35 * and the input's `disabled` property.
36 */
37 disabled: {
38 type: Boolean,
39 value: false
40 },
41
42 /**
43 * Returns true if the value is invalid. Bind this to both the `<paper-inp ut-container>`'s
44 * and the input's `invalid` property.
45 */
46 invalid: {
47 type: Boolean,
48 value: false
49 },
50
51 /**
52 * Set to true to prevent the user from entering invalid input. Bind this to the
53 * `<input is="iron-input">`'s `preventInvalidInput` property.
54 */
55 preventInvalidInput: {
56 type: Boolean
57 },
58
59 /**
60 * Set this to specify the pattern allowed by `preventInvalidInput`. Bind this to the
61 * `<input is="iron-input">`'s `allowedPattern` property.
62 */
63 allowedPattern: {
64 type: String
65 },
66
67 /**
68 * The type of the input. The supported types are `text`, `number` and `pa ssword`. Bind this
69 * to the `<input is="iron-input">`'s `type` property.
70 */
71 type: {
72 type: String
73 },
74
75 /**
76 * A pattern to validate the `input` with. Bind this to the `<input is="ir on-input">`'s
77 * `pattern` property.
78 */
79 pattern: {
80 type: String
81 },
82
83 /**
84 * Set to true to mark the input as required. Bind this to the `<input is= "iron-input">`'s
85 * `required` property.
86 */
87 required: {
88 type: Boolean,
89 value: false
90 },
91
92 /**
93 * The maximum length of the input value. Bind this to the `<input is="iro n-input">`'s
94 * `maxlength` property.
95 */
96 maxlength: {
97 type: Number
98 },
99
100 /**
101 * The error message to display when the input is invalid. Bind this to th e
102 * `<paper-input-error>`'s content, if using.
103 */
104 errorMessage: {
105 type: String
106 },
107
108 /**
109 * Set to true to show a character counter.
110 */
111 charCounter: {
112 type: Boolean,
113 value: false
114 },
115
116 /**
117 * Set to true to disable the floating label. Bind this to the `<paper-inp ut-container>`'s
118 * `noLabelFloat` property.
119 */
120 noLabelFloat: {
121 type: Boolean,
122 value: false
123 },
124
125 /**
126 * Set to true to always float the label. Bind this to the `<paper-input-c ontainer>`'s
127 * `alwaysFloatLabel` property.
128 */
129 alwaysFloatLabel: {
130 type: Boolean,
131 value: false
132 },
133
134 /**
135 * Set to true to auto-validate the input value. Bind this to the `<paper- input-container>`'s
136 * `autoValidate` property.
137 */
138 autoValidate: {
139 type: Boolean,
140 value: false
141 },
142
143 /**
144 * Name of the validator to use. Bind this to the `<input is="iron-input"> `'s `validator`
145 * property.
146 */
147 validator: {
148 type: String
149 },
150
151 // HTMLInputElement attributes for binding if needed
152
153 /**
154 * Bind this to the `<input is="iron-input">`'s `autocomplete` property.
155 */
156 autocomplete: {
157 type: String,
158 value: 'off'
159 },
160
161 /**
162 * Bind this to the `<input is="iron-input">`'s `autofocus` property.
163 */
164 autofocus: {
165 type: Boolean
166 },
167
168 /**
169 * Bind this to the `<input is="iron-input">`'s `inputmode` property.
170 */
171 inputmode: {
172 type: String
173 },
174
175 /**
176 * Bind this to the `<input is="iron-input">`'s `minlength` property.
177 */
178 minlength: {
179 type: Number
180 },
181
182 /**
183 * Bind this to the `<input is="iron-input">`'s `name` property.
184 */
185 name: {
186 type: String
187 },
188
189 /**
190 * A placeholder string in addition to the label. If this is set, the labe l will always float.
191 */
192 placeholder: {
193 type: String
194 },
195
196 /**
197 * Bind this to the `<input is="iron-input">`'s `readonly` property.
198 */
199 readonly: {
200 type: Boolean,
201 value: false
202 },
203
204 /**
205 * Bind this to the `<input is="iron-input">`'s `size` property.
206 */
207 size: {
208 type: Number
209 },
210
211 _ariaDescribedBy: {
212 type: String,
213 value: ''
214 }
215
216 },
217
218 listeners: {
219 'addon-attached': '_onAddonAttached'
220 },
221
222 /**
223 * Returns a reference to the input element.
224 */
225 get inputElement() {
226 return this.$.input;
227 },
228
229 attached: function() {
230 this._updateAriaLabelledBy();
231 },
232
233 _appendStringWithSpace: function(str, more) {
234 if (str) {
235 str = str + ' ' + more;
236 } else {
237 str = more;
238 }
239 return str;
240 },
241
242 _onAddonAttached: function(event) {
243 var target = event.path ? event.path[0] : event.target;
244 if (target.id) {
245 this._ariaDescribedBy = this._appendStringWithSpace(this._ariaDescribedB y, target.id);
246 } else {
247 var id = 'paper-input-add-on-' + Math.floor((Math.random() * 100000));
248 target.id = id;
249 this._ariaDescribedBy = this._appendStringWithSpace(this._ariaDescribedB y, id);
250 }
251 },
252
253 /**
254 * Validates the input element and sets an error style if needed.
255 */
256 validate: function () {
257 return this.inputElement.validate();
258 },
259
260 _computeAlwaysFloatLabel: function(alwaysFloatLabel, placeholder) {
261 return placeholder || alwaysFloatLabel;
262 },
263
264 _updateAriaLabelledBy: function() {
265 var label = Polymer.dom(this.root).querySelector('label');
266 if (!label) {
267 this._ariaLabelledBy = '';
268 return;
269 }
270 var labelledBy;
271 if (label.id) {
272 labelledBy = label.id;
273 } else {
274 labelledBy = 'paper-input-label-' + new Date().getUTCMilliseconds();
275 label.id = labelledBy;
276 }
277 this._ariaLabelledBy = labelledBy;
278 }
279
280 };
281
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698