73bcce88
luigser
COMPONENTS
|
1
2
3
4
5
6
7
8
9
10
11
|
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../polymer/polymer.html">
|
a1a3bc73
Luigi Serra
graphs updates
|
12
13
14
15
|
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="../paper-styles/color.html">
<link rel="import" href="../paper-styles/default-theme.html">
<link rel="import" href="../paper-styles/typography.html">
|
73bcce88
luigser
COMPONENTS
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
<!--
`<paper-input-container>` is a container for a `<label>`, an `<input is="iron-input">` or
`<iron-autogrow-textarea>` and optional add-on elements such as an error message or character
counter, used to implement Material Design text fields.
For example:
<paper-input-container>
<label>Your name</label>
<input is="iron-input">
</paper-input-container>
### Listening for input changes
By default, it listens for changes on the `bind-value` attribute on its children nodes and perform
tasks such as auto-validating and label styling when the `bind-value` changes. You can configure
the attribute it listens to with the `attr-for-value` attribute.
### Using a custom input element
You can use a custom input element in a `<paper-input-container>`, for example to implement a
compound input field like a social security number input. The custom input element should have the
`paper-input-input` class, have a `notify:true` value property and optionally implements
|
e619a3b0
Luigi Serra
Controllet cross ...
|
40
|
`Polymer.IronValidatableBehavior` if it is validatable.
|
73bcce88
luigser
COMPONENTS
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
<paper-input-container attr-for-value="ssn-value">
<label>Social security number</label>
<ssn-input class="paper-input-input"></ssn-input>
</paper-input-container>
### Validation
If the `auto-validate` attribute is set, the input container will validate the input and update
the container styling when the input value changes.
### Add-ons
Add-ons are child elements of a `<paper-input-container>` with the `add-on` attribute and
implements the `Polymer.PaperInputAddonBehavior` behavior. They are notified when the input value
or validity changes, and may implement functionality such as error messages or character counters.
They appear at the bottom of the input.
|
e619a3b0
Luigi Serra
Controllet cross ...
|
59
60
61
62
63
64
65
66
67
68
69
|
### Prefixes and suffixes
These are child elements of a `<paper-input-container>` with the `prefix`
or `suffix` attribute, and are displayed inline with the input, before or after.
<paper-input-container>
<div prefix>$</div>
<label>Total</label>
<input is="iron-input">
<paper-icon-button suffix icon="clear"></paper-icon-button>
</paper-input-container>
|
73bcce88
luigser
COMPONENTS
|
70
71
72
73
74
75
76
77
|
### Styling
The following custom properties and mixins are available for styling:
Custom property | Description | Default
----------------|-------------|----------
`--paper-input-container-color` | Label and underline color when the input is not focused | `--secondary-text-color`
`--paper-input-container-focus-color` | Label and underline color when the input is focused | `--default-primary-color`
|
e619a3b0
Luigi Serra
Controllet cross ...
|
78
|
`--paper-input-container-invalid-color` | Label and underline color when the input is is invalid | `--google-red-500`
|
73bcce88
luigser
COMPONENTS
|
79
80
|
`--paper-input-container-input-color` | Input foreground color | `--primary-text-color`
`--paper-input-container` | Mixin applied to the container | `{}`
|
eb240478
Luigi Serra
public room cards...
|
81
|
`--paper-input-container-disabled` | Mixin applied to the container when it's disabled | `{}`
|
73bcce88
luigser
COMPONENTS
|
82
83
|
`--paper-input-container-label` | Mixin applied to the label | `{}`
`--paper-input-container-label-focus` | Mixin applied to the label when the input is focused | `{}`
|
a1a3bc73
Luigi Serra
graphs updates
|
84
|
`--paper-input-container-label-floating` | Mixin applied to the label when floating | `{}`
|
73bcce88
luigser
COMPONENTS
|
85
|
`--paper-input-container-input` | Mixin applied to the input | `{}`
|
73bcce88
luigser
COMPONENTS
|
86
|
`--paper-input-container-underline` | Mixin applied to the underline | `{}`
|
a1a3bc73
Luigi Serra
graphs updates
|
87
|
`--paper-input-container-underline-focus` | Mixin applied to the underline when the input is focused | `{}`
|
73bcce88
luigser
COMPONENTS
|
88
|
`--paper-input-container-underline-disabled` | Mixin applied to the underline when the input is disabled | `{}`
|
eb240478
Luigi Serra
public room cards...
|
89
90
|
`--paper-input-prefix` | Mixin applied to the input prefix | `{}`
`--paper-input-suffix` | Mixin applied to the input suffix | `{}`
|
73bcce88
luigser
COMPONENTS
|
91
92
93
94
|
This element is `display:block` by default, but you can set the `inline` attribute to make it
`display:inline-block`.
-->
|
a1a3bc73
Luigi Serra
graphs updates
|
95
|
|
73bcce88
luigser
COMPONENTS
|
96
|
<dom-module id="paper-input-container">
|
e619a3b0
Luigi Serra
Controllet cross ...
|
97
|
<template>
|
e619a3b0
Luigi Serra
Controllet cross ...
|
98
99
100
101
|
<style>
:host {
display: block;
padding: 8px 0;
|
73bcce88
luigser
COMPONENTS
|
102
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
103
104
|
@apply(--paper-input-container);
}
|
73bcce88
luigser
COMPONENTS
|
105
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
106
107
108
|
:host[inline] {
display: inline-block;
}
|
73bcce88
luigser
COMPONENTS
|
109
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
110
111
112
|
:host([disabled]) {
pointer-events: none;
opacity: 0.33;
|
73bcce88
luigser
COMPONENTS
|
113
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
114
115
|
@apply(--paper-input-container-disabled);
}
|
73bcce88
luigser
COMPONENTS
|
116
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
117
118
119
|
.floated-label-placeholder {
@apply(--paper-font-caption);
}
|
73bcce88
luigser
COMPONENTS
|
120
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
121
122
123
|
.underline {
position: relative;
}
|
73bcce88
luigser
COMPONENTS
|
124
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
125
|
.focused-line {
|
a1a3bc73
Luigi Serra
graphs updates
|
126
|
@apply(--layout-fit);
|
73bcce88
luigser
COMPONENTS
|
127
|
|
a1a3bc73
Luigi Serra
graphs updates
|
128
129
|
background: var(--paper-input-container-focus-color, --default-primary-color);
height: 2px;
|
e619a3b0
Luigi Serra
Controllet cross ...
|
130
131
132
133
|
-webkit-transform-origin: center center;
transform-origin: center center;
-webkit-transform: scale3d(0,1,1);
transform: scale3d(0,1,1);
|
73bcce88
luigser
COMPONENTS
|
134
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
135
136
|
@apply(--paper-input-container-underline-focus);
}
|
73bcce88
luigser
COMPONENTS
|
137
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
138
139
140
141
142
|
.underline.is-highlighted .focused-line {
-webkit-transform: none;
transform: none;
-webkit-transition: -webkit-transform 0.25s;
transition: transform 0.25s;
|
73bcce88
luigser
COMPONENTS
|
143
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
144
145
|
@apply(--paper-transition-easing);
}
|
73bcce88
luigser
COMPONENTS
|
146
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
147
148
|
.underline.is-invalid .focused-line {
background: var(--paper-input-container-invalid-color, --google-red-500);
|
e619a3b0
Luigi Serra
Controllet cross ...
|
149
150
151
152
|
-webkit-transform: none;
transform: none;
-webkit-transition: -webkit-transform 0.25s;
transition: transform 0.25s;
|
73bcce88
luigser
COMPONENTS
|
153
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
154
155
|
@apply(--paper-transition-easing);
}
|
73bcce88
luigser
COMPONENTS
|
156
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
157
|
.unfocused-line {
|
a1a3bc73
Luigi Serra
graphs updates
|
158
159
|
@apply(--layout-fit);
|
e619a3b0
Luigi Serra
Controllet cross ...
|
160
161
|
height: 1px;
background: var(--paper-input-container-color, --secondary-text-color);
|
73bcce88
luigser
COMPONENTS
|
162
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
163
164
|
@apply(--paper-input-container-underline);
}
|
73bcce88
luigser
COMPONENTS
|
165
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
166
167
168
169
|
:host([disabled]) .unfocused-line {
border-bottom: 1px dashed;
border-color: var(--paper-input-container-color, --secondary-text-color);
background: transparent;
|
73bcce88
luigser
COMPONENTS
|
170
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
171
172
|
@apply(--paper-input-container-underline-disabled);
}
|
73bcce88
luigser
COMPONENTS
|
173
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
174
|
.label-and-input-container {
|
a1a3bc73
Luigi Serra
graphs updates
|
175
|
@apply(--layout-flex-auto);
|
e619a3b0
Luigi Serra
Controllet cross ...
|
176
|
@apply(--layout-relative);
|
a1a3bc73
Luigi Serra
graphs updates
|
177
178
|
width: 100%;
max-width: 100%;
|
e619a3b0
Luigi Serra
Controllet cross ...
|
179
|
}
|
73bcce88
luigser
COMPONENTS
|
180
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
181
|
.input-content {
|
e619a3b0
Luigi Serra
Controllet cross ...
|
182
|
@apply(--layout-horizontal);
|
a1a3bc73
Luigi Serra
graphs updates
|
183
184
185
|
@apply(--layout-center);
position: relative;
|
e619a3b0
Luigi Serra
Controllet cross ...
|
186
|
}
|
73bcce88
luigser
COMPONENTS
|
187
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
188
189
190
191
192
193
|
.input-content ::content label,
.input-content ::content .paper-input-label {
position: absolute;
top: 0;
right: 0;
left: 0;
|
a1a3bc73
Luigi Serra
graphs updates
|
194
|
width: 100%;
|
e619a3b0
Luigi Serra
Controllet cross ...
|
195
196
197
|
font: inherit;
color: var(--paper-input-container-color, --secondary-text-color);
|
eb240478
Luigi Serra
public room cards...
|
198
|
@apply(--paper-font-common-nowrap);
|
e619a3b0
Luigi Serra
Controllet cross ...
|
199
200
201
|
@apply(--paper-font-subhead);
@apply(--paper-input-container-label);
}
|
73bcce88
luigser
COMPONENTS
|
202
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
203
204
205
206
|
.input-content.label-is-floating ::content label,
.input-content.label-is-floating ::content .paper-input-label {
-webkit-transform: translateY(-75%) scale(0.75);
transform: translateY(-75%) scale(0.75);
|
a1a3bc73
Luigi Serra
graphs updates
|
207
208
|
-webkit-transition: -webkit-transform 0.25s, width 0.25s;
transition: transform 0.25s, width 0.25s;
|
f748e9cf
Luigi Serra
new controllet an...
|
209
210
211
|
-webkit-transform-origin: left top;
transform-origin: left top;
|
eb240478
Luigi Serra
public room cards...
|
212
213
214
215
|
/* Since we scale to 75/100 of the size, we actually have 100/75 of the
original space now available */
width: 133%;
|
e619a3b0
Luigi Serra
Controllet cross ...
|
216
|
@apply(--paper-transition-easing);
|
a1a3bc73
Luigi Serra
graphs updates
|
217
|
@apply(--paper-input-container-label-floating);
|
e619a3b0
Luigi Serra
Controllet cross ...
|
218
|
}
|
73bcce88
luigser
COMPONENTS
|
219
|
|
f748e9cf
Luigi Serra
new controllet an...
|
220
221
222
223
224
225
226
227
228
229
|
:host-context([dir="rtl"]) .input-content.label-is-floating ::content label,
:host-context([dir="rtl"]) .input-content.label-is-floating ::content .paper-input-label {
/* TODO(noms): Figure out why leaving the width at 133% before the animation
* actually makes
* it wider on the right side, not left side, as you would expect in RTL */
width: 100%;
-webkit-transform-origin: right top;
transform-origin: right top;
}
|
e619a3b0
Luigi Serra
Controllet cross ...
|
230
231
232
|
.input-content.label-is-highlighted ::content label,
.input-content.label-is-highlighted ::content .paper-input-label {
color: var(--paper-input-container-focus-color, --default-primary-color);
|
73bcce88
luigser
COMPONENTS
|
233
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
234
235
|
@apply(--paper-input-container-label-focus);
}
|
73bcce88
luigser
COMPONENTS
|
236
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
237
238
239
240
|
.input-content.is-invalid ::content label,
.input-content.is-invalid ::content .paper-input-label {
color: var(--paper-input-container-invalid-color, --google-red-500);
}
|
73bcce88
luigser
COMPONENTS
|
241
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
242
243
244
245
|
.input-content.label-is-hidden ::content label,
.input-content.label-is-hidden ::content .paper-input-label {
visibility: hidden;
}
|
73bcce88
luigser
COMPONENTS
|
246
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
247
248
249
250
251
252
253
254
255
|
.input-content ::content input,
.input-content ::content textarea,
.input-content ::content iron-autogrow-textarea,
.input-content ::content .paper-input-input {
position: relative; /* to make a stacking context */
outline: none;
box-shadow: none;
padding: 0;
width: 100%;
|
a1a3bc73
Luigi Serra
graphs updates
|
256
|
max-width: 100%;
|
e619a3b0
Luigi Serra
Controllet cross ...
|
257
258
259
260
|
background: transparent;
border: none;
color: var(--paper-input-container-input-color, --primary-text-color);
-webkit-appearance: none;
|
f748e9cf
Luigi Serra
new controllet an...
|
261
|
text-align: inherit;
|
e619a3b0
Luigi Serra
Controllet cross ...
|
262
263
264
265
|
@apply(--paper-font-subhead);
@apply(--paper-input-container-input);
}
|
73bcce88
luigser
COMPONENTS
|
266
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
267
268
269
|
::content [prefix] {
@apply(--paper-font-subhead);
@apply(--paper-input-prefix);
|
a1a3bc73
Luigi Serra
graphs updates
|
270
|
@apply(--layout-flex-none);
|
e619a3b0
Luigi Serra
Controllet cross ...
|
271
|
}
|
73bcce88
luigser
COMPONENTS
|
272
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
273
274
275
|
::content [suffix] {
@apply(--paper-font-subhead);
@apply(--paper-input-suffix);
|
a1a3bc73
Luigi Serra
graphs updates
|
276
|
@apply(--layout-flex-none);
|
e619a3b0
Luigi Serra
Controllet cross ...
|
277
|
}
|
73bcce88
luigser
COMPONENTS
|
278
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
279
280
281
282
|
/* Firefox sets a min-width on the input, which can cause layout issues */
.input-content ::content input {
min-width: 0;
}
|
73bcce88
luigser
COMPONENTS
|
283
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
284
285
286
|
.input-content ::content textarea {
resize: none;
}
|
73bcce88
luigser
COMPONENTS
|
287
|
|
f748e9cf
Luigi Serra
new controllet an...
|
288
289
290
291
|
.add-on-content {
position: relative;
}
|
e619a3b0
Luigi Serra
Controllet cross ...
|
292
293
294
295
296
297
298
299
|
.add-on-content.is-invalid ::content * {
color: var(--paper-input-container-invalid-color, --google-red-500);
}
.add-on-content.is-highlighted ::content * {
color: var(--paper-input-container-focus-color, --default-primary-color);
}
</style>
|
73bcce88
luigser
COMPONENTS
|
300
301
302
303
304
305
|
<template is="dom-if" if="[[!noLabelFloat]]">
<div class="floated-label-placeholder"> </div>
</template>
<div class$="[[_computeInputContentClass(noLabelFloat,alwaysFloatLabel,focused,invalid,_inputHasContent)]]">
|
e619a3b0
Luigi Serra
Controllet cross ...
|
306
|
<content select="[prefix]" id="prefix"></content>
|
f748e9cf
Luigi Serra
new controllet an...
|
307
308
|
<div class="label-and-input-container" id="labelAndInputContainer">
|
e619a3b0
Luigi Serra
Controllet cross ...
|
309
310
|
<content select=":not([add-on]):not([prefix]):not([suffix])"></content>
</div>
|
a1a3bc73
Luigi Serra
graphs updates
|
311
|
|
e619a3b0
Luigi Serra
Controllet cross ...
|
312
|
<content select="[suffix]"></content>
|
73bcce88
luigser
COMPONENTS
|
313
314
315
|
</div>
<div class$="[[_computeUnderlineClass(focused,invalid)]]">
|
a1a3bc73
Luigi Serra
graphs updates
|
316
317
|
<div class="unfocused-line"></div>
<div class="focused-line"></div>
|
73bcce88
luigser
COMPONENTS
|
318
319
320
321
322
|
</div>
<div class$="[[_computeAddOnContentClass(focused,invalid)]]">
<content id="addOnContent" select="[add-on]"></content>
</div>
|
73bcce88
luigser
COMPONENTS
|
323
|
</template>
|
73bcce88
luigser
COMPONENTS
|
324
325
326
|
</dom-module>
<script>
|
73bcce88
luigser
COMPONENTS
|
327
|
Polymer({
|
73bcce88
luigser
COMPONENTS
|
328
329
330
|
is: 'paper-input-container',
properties: {
|
73bcce88
luigser
COMPONENTS
|
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
|
/**
* Set to true to disable the floating label. The label disappears when the input value is
* not null.
*/
noLabelFloat: {
type: Boolean,
value: false
},
/**
* Set to true to always float the floating label.
*/
alwaysFloatLabel: {
type: Boolean,
value: false
},
/**
* The attribute to listen for value changes on.
*/
attrForValue: {
type: String,
value: 'bind-value'
},
/**
* Set to true to auto-validate the input value when it changes.
*/
autoValidate: {
type: Boolean,
value: false
},
/**
* True if the input is invalid. This property is set automatically when the input value
|
e619a3b0
Luigi Serra
Controllet cross ...
|
366
|
* changes if auto-validating, or when the `iron-input-validate` event is heard from a child.
|
73bcce88
luigser
COMPONENTS
|
367
368
369
370
371
372
373
374
375
376
377
378
379
|
*/
invalid: {
observer: '_invalidChanged',
type: Boolean,
value: false
},
/**
* True if the input has focus.
*/
focused: {
readOnly: true,
type: Boolean,
|
e619a3b0
Luigi Serra
Controllet cross ...
|
380
381
|
value: false,
notify: true
|
73bcce88
luigser
COMPONENTS
|
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
|
},
_addons: {
type: Array
// do not set a default value here intentionally - it will be initialized lazily when a
// distributed child is attached, which may occur before configuration for this element
// in polyfill.
},
_inputHasContent: {
type: Boolean,
value: false
},
_inputSelector: {
type: String,
value: 'input,textarea,.paper-input-input'
},
_boundOnFocus: {
type: Function,
value: function() {
return this._onFocus.bind(this);
}
},
_boundOnBlur: {
type: Function,
value: function() {
return this._onBlur.bind(this);
}
},
_boundOnInput: {
type: Function,
value: function() {
return this._onInput.bind(this);
}
},
_boundValueChanged: {
type: Function,
value: function() {
return this._onValueChanged.bind(this);
}
}
|
73bcce88
luigser
COMPONENTS
|
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
|
},
listeners: {
'addon-attached': '_onAddonAttached',
'iron-input-validate': '_onIronInputValidate'
},
get _valueChangedEvent() {
return this.attrForValue + '-changed';
},
get _propertyForValue() {
return Polymer.CaseMap.dashToCamelCase(this.attrForValue);
},
get _inputElement() {
return Polymer.dom(this).querySelector(this._inputSelector);
},
|
e619a3b0
Luigi Serra
Controllet cross ...
|
447
448
449
450
|
get _inputElementValue() {
return this._inputElement[this._propertyForValue] || this._inputElement.value;
},
|
73bcce88
luigser
COMPONENTS
|
451
452
453
454
455
456
457
458
459
460
461
462
463
464
|
ready: function() {
if (!this._addons) {
this._addons = [];
}
this.addEventListener('focus', this._boundOnFocus, true);
this.addEventListener('blur', this._boundOnBlur, true);
if (this.attrForValue) {
this._inputElement.addEventListener(this._valueChangedEvent, this._boundValueChanged);
} else {
this.addEventListener('input', this._onInput);
}
},
attached: function() {
|
e619a3b0
Luigi Serra
Controllet cross ...
|
465
466
467
468
469
470
|
// Only validate when attached if the input already has a value.
if (this._inputElementValue != '') {
this._handleValueAndAutoValidate(this._inputElement);
} else {
this._handleValue(this._inputElement);
}
|
73bcce88
luigser
COMPONENTS
|
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
},
_onAddonAttached: function(event) {
if (!this._addons) {
this._addons = [];
}
var target = event.target;
if (this._addons.indexOf(target) === -1) {
this._addons.push(target);
if (this.isAttached) {
this._handleValue(this._inputElement);
}
}
},
_onFocus: function() {
this._setFocused(true);
},
_onBlur: function() {
this._setFocused(false);
|
e619a3b0
Luigi Serra
Controllet cross ...
|
492
|
this._handleValueAndAutoValidate(this._inputElement);
|
73bcce88
luigser
COMPONENTS
|
493
494
495
|
},
_onInput: function(event) {
|
e619a3b0
Luigi Serra
Controllet cross ...
|
496
|
this._handleValueAndAutoValidate(event.target);
|
73bcce88
luigser
COMPONENTS
|
497
498
499
|
},
_onValueChanged: function(event) {
|
e619a3b0
Luigi Serra
Controllet cross ...
|
500
|
this._handleValueAndAutoValidate(event.target);
|
73bcce88
luigser
COMPONENTS
|
501
502
503
|
},
_handleValue: function(inputElement) {
|
e619a3b0
Luigi Serra
Controllet cross ...
|
504
|
var value = this._inputElementValue;
|
73bcce88
luigser
COMPONENTS
|
505
506
|
// type="number" hack needed because this.value is empty until it's valid
|
e619a3b0
Luigi Serra
Controllet cross ...
|
507
|
if (value || value === 0 || (inputElement.type === 'number' && !inputElement.checkValidity())) {
|
73bcce88
luigser
COMPONENTS
|
508
509
510
511
512
513
514
515
516
517
518
519
|
this._inputHasContent = true;
} else {
this._inputHasContent = false;
}
this.updateAddons({
inputElement: inputElement,
value: value,
invalid: this.invalid
});
},
|
e619a3b0
Luigi Serra
Controllet cross ...
|
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
|
_handleValueAndAutoValidate: function(inputElement) {
if (this.autoValidate) {
var valid;
if (inputElement.validate) {
valid = inputElement.validate(this._inputElementValue);
} else {
valid = inputElement.checkValidity();
}
this.invalid = !valid;
}
// Call this last to notify the add-ons.
this._handleValue(inputElement);
},
|
73bcce88
luigser
COMPONENTS
|
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
|
_onIronInputValidate: function(event) {
this.invalid = this._inputElement.invalid;
},
_invalidChanged: function() {
if (this._addons) {
this.updateAddons({invalid: this.invalid});
}
},
/**
* Call this to update the state of add-ons.
* @param {Object} state Add-on state.
*/
updateAddons: function(state) {
for (var addon, index = 0; addon = this._addons[index]; index++) {
addon.update(state);
}
},
_computeInputContentClass: function(noLabelFloat, alwaysFloatLabel, focused, invalid, _inputHasContent) {
var cls = 'input-content';
if (!noLabelFloat) {
|
e619a3b0
Luigi Serra
Controllet cross ...
|
558
559
|
var label = this.querySelector('label');
|
73bcce88
luigser
COMPONENTS
|
560
561
|
if (alwaysFloatLabel || _inputHasContent) {
cls += ' label-is-floating';
|
a1a3bc73
Luigi Serra
graphs updates
|
562
563
564
565
|
// If the label is floating, ignore any offsets that may have been
// applied from a prefix element.
this.$.labelAndInputContainer.style.position = 'static';
|
73bcce88
luigser
COMPONENTS
|
566
567
568
569
570
|
if (invalid) {
cls += ' is-invalid';
} else if (focused) {
cls += " label-is-highlighted";
}
|
e619a3b0
Luigi Serra
Controllet cross ...
|
571
572
573
|
} else {
// When the label is not floating, it should overlap the input element.
if (label) {
|
f748e9cf
Luigi Serra
new controllet an...
|
574
|
this.$.labelAndInputContainer.style.position = 'relative';
|
e619a3b0
Luigi Serra
Controllet cross ...
|
575
|
}
|
73bcce88
luigser
COMPONENTS
|
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
|
}
} else {
if (_inputHasContent) {
cls += ' label-is-hidden';
}
}
return cls;
},
_computeUnderlineClass: function(focused, invalid) {
var cls = 'underline';
if (invalid) {
cls += ' is-invalid';
} else if (focused) {
cls += ' is-highlighted'
}
return cls;
},
_computeAddOnContentClass: function(focused, invalid) {
var cls = 'add-on-content';
if (invalid) {
cls += ' is-invalid';
} else if (focused) {
cls += ' is-highlighted'
}
return cls;
}
|
73bcce88
luigser
COMPONENTS
|
604
|
});
|
73bcce88
luigser
COMPONENTS
|
605
|
</script>
|