OLD | NEW |
| (Empty) |
1 <!-- | |
2 @license | |
3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | |
4 This code may only be used under the BSD style license found at http://polym
er.github.io/LICENSE.txt | |
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS
.txt | |
6 The complete set of contributors may be found at http://polymer.github.io/CO
NTRIBUTORS.txt | |
7 Code distributed by Google as part of the polymer project is also | |
8 subject to an additional IP rights grant found at http://polymer.github.io/P
ATENTS.txt | |
9 --> | |
10 <!doctype html> | |
11 <html> | |
12 <head> | |
13 <meta name="viewport" content="width=device-width, initial-scale=1, user-scala
ble=no"> | |
14 | |
15 <title>core-input</title> | |
16 | |
17 <script src="../platform/platform.js"></script> | |
18 | |
19 <link href="core-input.html" rel="import"> | |
20 | |
21 <style> | |
22 body { | |
23 padding: 24px; | |
24 margin: 0; | |
25 -webkit-transform: translateZ(0); | |
26 font-family: sans-serif; | |
27 font-size: 16px; | |
28 } | |
29 | |
30 section { | |
31 margin: 2em 0; | |
32 } | |
33 | |
34 aside { | |
35 background: #ccc; | |
36 padding: 1em; | |
37 margin-right: 2em; | |
38 font-size: 12px; | |
39 width: 250px; | |
40 border-radius: 3px; | |
41 } | |
42 | |
43 core-input { | |
44 margin: 1em; | |
45 } | |
46 | |
47 core-input[multiline] { | |
48 border: 1px dotted #ccc; | |
49 } | |
50 | |
51 core-input.sized { | |
52 width: 500px; | |
53 height: 200px; | |
54 } | |
55 | |
56 .validation core-input, | |
57 .validation core-input[multiline] { | |
58 border: solid 1px lime; | |
59 } | |
60 | |
61 .validation core-input.invalid, | |
62 .validation core-input[multiline].invalid { | |
63 border: solid 1px red; | |
64 } | |
65 | |
66 </style> | |
67 | |
68 </head> | |
69 <body> | |
70 | |
71 <section horizontal start layout> | |
72 <aside>A single-line text input. See console for committed values.</aside> | |
73 <core-input id="single" placeholder="Type something..."></core-input> | |
74 <script> | |
75 var single = document.getElementById('single'); | |
76 single.addEventListener('change', function() { | |
77 console.log('single: value committed: ', single.value); | |
78 }); | |
79 </script> | |
80 </section> | |
81 | |
82 <section horizontal start layout> | |
83 <aside>The <code>type</code> attribute is supported. This is a single-line i
nput with <code>type = password</code>. See console for committed values.</aside
> | |
84 <core-input id="password" type="password" placeholder="Enter password..."></
core-input> | |
85 <script> | |
86 var password = document.getElementById('password'); | |
87 password.addEventListener('change', function() { | |
88 console.log('password: value committed: ', password.value); | |
89 }); | |
90 </script> | |
91 </section> | |
92 | |
93 <section horizontal start layout> | |
94 <aside>A multi-line text input with 3 rows. The input is normally unstyled b
ut here is styled with a dotted border to show its size.</aside> | |
95 <core-input multiline rows="3" placeholder="Type many lines here..."></core-
input> | |
96 </section> | |
97 | |
98 <section horizontal start layout> | |
99 <aside>A multi-line text input sized with CSS. The input is normally unstyle
d but here is styled with a dotted border to show its size.</aside> | |
100 <core-input class="sized" multiline rows="fit" placeholder="This input is 50
0px * 200px"></core-input> | |
101 </section> | |
102 | |
103 <section horizontal start layout> | |
104 <aside>Inputs with the <code>tabindex</code> attribute.</aside> | |
105 <div> | |
106 <core-input tabindex="2" placeholder="tabindex = 2"></core-input> | |
107 <br> | |
108 <core-input tabindex="3" placeholder="tabindex = 3"></core-input> | |
109 <br> | |
110 <core-input tabindex="1" placeholder="tabindex = 1"></core-input> | |
111 </div> | |
112 </section> | |
113 | |
114 <section horizontal start layout> | |
115 <aside>Validation examples. The border color reflects the current validation
state. See console for validation events.</aside> | |
116 <div class="validation"> | |
117 <core-input id="validate-number" type="number" placeholder="type = number"
></core-input> | |
118 <br> | |
119 <core-input id="validate-email" type="email" placeholder="type = email"></
core-input> | |
120 <br> | |
121 <core-input id="validate-required" required placeholder="required"></core-
input> | |
122 <br> | |
123 <core-input id="validate-ml-required" multiline rows="3" required placehol
der="required (multiline)"></core-input> | |
124 <br> | |
125 <core-input id="validate-pattern" pattern="a*bc" placeholder="with pattern
= a*bc"></core-input> | |
126 <br> | |
127 <core-input id="validate-min-max" type="number" min="5" max="10" placehold
er="type = number, min = 5, max = 10"></core-input> | |
128 <br> | |
129 <core-input id="validate-step" type="number" step="2" placeholder="type =
number, step = 2"></core-input> | |
130 </div> | |
131 <script> | |
132 document.querySelector('.validation').addEventListener('input-invalid', fu
nction(e, value, s) { | |
133 console.log(e.target.id, 'invalid, inputValue:', e.detail.value, e.targe
t.validity); | |
134 }); | |
135 document.querySelector('.validation').addEventListener('input-valid', func
tion(e, value, s) { | |
136 console.log(e.target.id, 'valid, inputValue:', e.detail.value, e.target.
validity); | |
137 }); | |
138 </script> | |
139 </section> | |
140 | |
141 | |
142 </body> | |
OLD | NEW |