polymer-gold-rails 1.0.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +36 -0
  3. data/Rakefile +1 -0
  4. data/app/assets/components/gold-cc-cvc-input/README.md +24 -0
  5. data/app/assets/components/gold-cc-cvc-input/bower.json +39 -0
  6. data/app/assets/components/gold-cc-cvc-input/cvc_hint.png +0 -0
  7. data/app/assets/components/gold-cc-cvc-input/cvc_hint_amex.png +0 -0
  8. data/app/assets/components/gold-cc-cvc-input/demo/index.html +54 -0
  9. data/app/assets/components/gold-cc-cvc-input/gold-cc-cvc-input.html +195 -0
  10. data/app/assets/components/gold-cc-cvc-input/hero.svg +36 -0
  11. data/app/assets/components/gold-cc-cvc-input/index.html +26 -0
  12. data/app/assets/components/gold-cc-cvc-input/test/basic.html +125 -0
  13. data/app/assets/components/gold-cc-cvc-input/test/index.html +25 -0
  14. data/app/assets/components/gold-cc-expiration-input/README.md +10 -0
  15. data/app/assets/components/gold-cc-expiration-input/bower.json +40 -0
  16. data/app/assets/components/gold-cc-expiration-input/date-input.html +157 -0
  17. data/app/assets/components/gold-cc-expiration-input/date-validator.html +38 -0
  18. data/app/assets/components/gold-cc-expiration-input/demo/index.html +53 -0
  19. data/app/assets/components/gold-cc-expiration-input/gold-cc-expiration-input.html +131 -0
  20. data/app/assets/components/gold-cc-expiration-input/hero.svg +58 -0
  21. data/app/assets/components/gold-cc-expiration-input/index.html +28 -0
  22. data/app/assets/components/gold-cc-expiration-input/test/basic.html +126 -0
  23. data/app/assets/components/gold-cc-expiration-input/test/index.html +25 -0
  24. data/app/assets/components/gold-cc-input/README.md +9 -0
  25. data/app/assets/components/gold-cc-input/bower.json +39 -0
  26. data/app/assets/components/gold-cc-input/cc-validator.js +192 -0
  27. data/app/assets/components/gold-cc-input/demo/index.html +48 -0
  28. data/app/assets/components/gold-cc-input/gold-cc-input.html +215 -0
  29. data/app/assets/components/gold-cc-input/hero.svg +52 -0
  30. data/app/assets/components/gold-cc-input/images/amex.png +0 -0
  31. data/app/assets/components/gold-cc-input/images/diners_club.png +0 -0
  32. data/app/assets/components/gold-cc-input/images/discover.png +0 -0
  33. data/app/assets/components/gold-cc-input/images/jcb.png +0 -0
  34. data/app/assets/components/gold-cc-input/images/mastercard.png +0 -0
  35. data/app/assets/components/gold-cc-input/images/visa.png +0 -0
  36. data/app/assets/components/gold-cc-input/index.html +28 -0
  37. data/app/assets/components/gold-cc-input/test/basic.html +136 -0
  38. data/app/assets/components/gold-cc-input/test/index.html +25 -0
  39. data/app/assets/components/gold-elements/README.md +12 -0
  40. data/app/assets/components/gold-elements/bower.json +42 -0
  41. data/app/assets/components/gold-elements/demo/complex-form.html +127 -0
  42. data/app/assets/components/gold-elements/demo/index.html +94 -0
  43. data/app/assets/components/gold-elements/demo/item-card.html +59 -0
  44. data/app/assets/components/gold-elements/demo/simple-form.css +55 -0
  45. data/app/assets/components/gold-elements/demo/simple-form.html +93 -0
  46. data/app/assets/components/gold-elements/screenshot.png +0 -0
  47. data/app/assets/components/gold-email-input/README.md +8 -0
  48. data/app/assets/components/gold-email-input/bower.json +40 -0
  49. data/app/assets/components/gold-email-input/demo/index.html +46 -0
  50. data/app/assets/components/gold-email-input/email-validator.html +31 -0
  51. data/app/assets/components/gold-email-input/gold-email-input.html +108 -0
  52. data/app/assets/components/gold-email-input/hero.svg +59 -0
  53. data/app/assets/components/gold-email-input/index.html +28 -0
  54. data/app/assets/components/gold-email-input/test/basic.html +97 -0
  55. data/app/assets/components/gold-email-input/test/index.html +25 -0
  56. data/app/assets/components/gold-phone-input/README.md +13 -0
  57. data/app/assets/components/gold-phone-input/bower.json +39 -0
  58. data/app/assets/components/gold-phone-input/demo/index.html +53 -0
  59. data/app/assets/components/gold-phone-input/gold-phone-input.html +197 -0
  60. data/app/assets/components/gold-phone-input/hero.svg +63 -0
  61. data/app/assets/components/gold-phone-input/index.html +28 -0
  62. data/app/assets/components/gold-phone-input/test/basic.html +117 -0
  63. data/app/assets/components/gold-phone-input/test/index.html +25 -0
  64. data/app/assets/components/gold-zip-input/README.md +8 -0
  65. data/app/assets/components/gold-zip-input/bower.json +40 -0
  66. data/app/assets/components/gold-zip-input/demo/index.html +54 -0
  67. data/app/assets/components/gold-zip-input/gold-zip-input.html +113 -0
  68. data/app/assets/components/gold-zip-input/hero.svg +43 -0
  69. data/app/assets/components/gold-zip-input/index.html +28 -0
  70. data/app/assets/components/gold-zip-input/test/basic.html +116 -0
  71. data/app/assets/components/gold-zip-input/test/index.html +25 -0
  72. data/app/assets/components/gold-zip-input/zip-validator.html +32 -0
  73. data/app/assets/components/iron-autogrow-textarea/README.md +24 -0
  74. data/app/assets/components/iron-autogrow-textarea/bower.json +37 -0
  75. data/app/assets/components/iron-autogrow-textarea/demo/index.html +81 -0
  76. data/app/assets/components/iron-autogrow-textarea/hero.svg +33 -0
  77. data/app/assets/components/iron-autogrow-textarea/index.html +30 -0
  78. data/app/assets/components/iron-autogrow-textarea/iron-autogrow-textarea.html +263 -0
  79. data/app/assets/components/iron-autogrow-textarea/test/basic.html +94 -0
  80. data/app/assets/components/iron-autogrow-textarea/test/index.html +25 -0
  81. data/app/assets/components/iron-flex-layout/README.md +4 -0
  82. data/app/assets/components/iron-flex-layout/bower.json +21 -0
  83. data/app/assets/components/iron-flex-layout/classes/iron-flex-layout.html +307 -0
  84. data/app/assets/components/iron-flex-layout/classes/iron-shadow-flex-layout.html +302 -0
  85. data/app/assets/components/iron-flex-layout/demo/index.html +40 -0
  86. data/app/assets/components/iron-flex-layout/demo/x-app.html +106 -0
  87. data/app/assets/components/iron-flex-layout/iron-flex-layout.html +313 -0
  88. data/app/assets/components/iron-form-element-behavior/README.md +2 -0
  89. data/app/assets/components/iron-form-element-behavior/bower.json +27 -0
  90. data/app/assets/components/iron-form-element-behavior/demo/index.html +53 -0
  91. data/app/assets/components/iron-form-element-behavior/demo/simple-element.html +27 -0
  92. data/app/assets/components/iron-form-element-behavior/demo/simple-form.html +42 -0
  93. data/app/assets/components/iron-form-element-behavior/index.html +30 -0
  94. data/app/assets/components/iron-form-element-behavior/iron-form-element-behavior.html +50 -0
  95. data/app/assets/components/iron-icon/README.md +56 -0
  96. data/app/assets/components/iron-icon/bower.json +29 -0
  97. data/app/assets/components/iron-icon/demo/index.html +28 -0
  98. data/app/assets/components/iron-icon/demo/location.png +0 -0
  99. data/app/assets/components/iron-icon/hero.svg +19 -0
  100. data/app/assets/components/iron-icon/index.html +26 -0
  101. data/app/assets/components/iron-icon/iron-icon.html +187 -0
  102. data/app/assets/components/iron-icon/test/index.html +31 -0
  103. data/app/assets/components/iron-icon/test/iron-icon.html +120 -0
  104. data/app/assets/components/iron-input/README.md +16 -0
  105. data/app/assets/components/iron-input/bower.json +36 -0
  106. data/app/assets/components/iron-input/demo/index.html +87 -0
  107. data/app/assets/components/iron-input/hero.svg +19 -0
  108. data/app/assets/components/iron-input/index.html +30 -0
  109. data/app/assets/components/iron-input/iron-input.html +235 -0
  110. data/app/assets/components/iron-input/test/index.html +24 -0
  111. data/app/assets/components/iron-input/test/iron-input.html +139 -0
  112. data/app/assets/components/iron-input/test/letters-only.html +30 -0
  113. data/app/assets/components/iron-meta/README.md +46 -0
  114. data/app/assets/components/iron-meta/bower.json +28 -0
  115. data/app/assets/components/iron-meta/demo/index.html +45 -0
  116. data/app/assets/components/iron-meta/hero.svg +33 -0
  117. data/app/assets/components/iron-meta/index.html +27 -0
  118. data/app/assets/components/iron-meta/iron-meta.html +352 -0
  119. data/app/assets/components/iron-meta/test/basic.html +48 -0
  120. data/app/assets/components/iron-meta/test/index.html +30 -0
  121. data/app/assets/components/iron-meta/test/iron-meta.html +186 -0
  122. data/app/assets/components/iron-validatable-behavior/README.md +3 -0
  123. data/app/assets/components/iron-validatable-behavior/bower.json +35 -0
  124. data/app/assets/components/iron-validatable-behavior/demo/cats-only.html +46 -0
  125. data/app/assets/components/iron-validatable-behavior/demo/index.html +71 -0
  126. data/app/assets/components/iron-validatable-behavior/demo/validatable-input.html +46 -0
  127. data/app/assets/components/iron-validatable-behavior/index.html +30 -0
  128. data/app/assets/components/iron-validatable-behavior/iron-validatable-behavior.html +101 -0
  129. data/app/assets/components/iron-validatable-behavior/test/index.html +35 -0
  130. data/app/assets/components/iron-validatable-behavior/test/iron-validatable-behavior.html +52 -0
  131. data/app/assets/components/iron-validatable-behavior/test/test-validatable.html +28 -0
  132. data/app/assets/components/iron-validator-behavior/README.md +4 -0
  133. data/app/assets/components/iron-validator-behavior/bower.json +34 -0
  134. data/app/assets/components/iron-validator-behavior/demo/cats-only.html +46 -0
  135. data/app/assets/components/iron-validator-behavior/demo/index.html +144 -0
  136. data/app/assets/components/iron-validator-behavior/index.html +30 -0
  137. data/app/assets/components/iron-validator-behavior/iron-validator-behavior.html +61 -0
  138. data/app/assets/components/iron-validator-behavior/test/index.html +34 -0
  139. data/app/assets/components/iron-validator-behavior/test/iron-validator-behavior.html +47 -0
  140. data/app/assets/components/iron-validator-behavior/test/simple-validator.html +26 -0
  141. data/app/assets/components/paper-input/README.md +5 -0
  142. data/app/assets/components/paper-input/all-imports.html +12 -0
  143. data/app/assets/components/paper-input/bower.json +44 -0
  144. data/app/assets/components/paper-input/demo/index.html +96 -0
  145. data/app/assets/components/paper-input/demo/ssn-input.html +94 -0
  146. data/app/assets/components/paper-input/demo/ssn-validator.html +31 -0
  147. data/app/assets/components/paper-input/hero.svg +19 -0
  148. data/app/assets/components/paper-input/index.html +28 -0
  149. data/app/assets/components/paper-input/paper-input-addon-behavior.html +47 -0
  150. data/app/assets/components/paper-input/paper-input-behavior.html +317 -0
  151. data/app/assets/components/paper-input/paper-input-char-counter.html +95 -0
  152. data/app/assets/components/paper-input/paper-input-container.html +495 -0
  153. data/app/assets/components/paper-input/paper-input-error.html +99 -0
  154. data/app/assets/components/paper-input/paper-input.html +126 -0
  155. data/app/assets/components/paper-input/paper-textarea.html +106 -0
  156. data/app/assets/components/paper-input/test/index.html +28 -0
  157. data/app/assets/components/paper-input/test/letters-only.html +30 -0
  158. data/app/assets/components/paper-input/test/paper-input-char-counter.html +112 -0
  159. data/app/assets/components/paper-input/test/paper-input-container.html +237 -0
  160. data/app/assets/components/paper-input/test/paper-input-error.html +60 -0
  161. data/app/assets/components/paper-input/test/paper-input.html +213 -0
  162. data/app/assets/components/paper-input/test/paper-textarea.html +169 -0
  163. data/app/assets/components/paper-styles/README.md +3 -0
  164. data/app/assets/components/paper-styles/bower.json +27 -0
  165. data/app/assets/components/paper-styles/classes/global.html +96 -0
  166. data/app/assets/components/paper-styles/classes/shadow-layout.html +302 -0
  167. data/app/assets/components/paper-styles/classes/shadow.html +39 -0
  168. data/app/assets/components/paper-styles/classes/typography.html +171 -0
  169. data/app/assets/components/paper-styles/color.html +333 -0
  170. data/app/assets/components/paper-styles/default-theme.html +39 -0
  171. data/app/assets/components/paper-styles/demo-pages.html +72 -0
  172. data/app/assets/components/paper-styles/demo.css +25 -0
  173. data/app/assets/components/paper-styles/paper-styles-classes.html +14 -0
  174. data/app/assets/components/paper-styles/paper-styles.html +17 -0
  175. data/app/assets/components/paper-styles/shadow.html +61 -0
  176. data/app/assets/components/paper-styles/typography.html +240 -0
  177. data/app/assets/components/polymer/LICENSE.txt +27 -0
  178. data/app/assets/components/polymer/bower.json +26 -0
  179. data/app/assets/components/polymer/build.log +27 -0
  180. data/app/assets/components/polymer/polymer-micro.html +523 -0
  181. data/app/assets/components/polymer/polymer-mini.html +1368 -0
  182. data/app/assets/components/polymer/polymer.html +3768 -0
  183. data/app/assets/components/webcomponentsjs/CustomElements.js +956 -0
  184. data/app/assets/components/webcomponentsjs/CustomElements.min.js +11 -0
  185. data/app/assets/components/webcomponentsjs/HTMLImports.js +1078 -0
  186. data/app/assets/components/webcomponentsjs/HTMLImports.min.js +11 -0
  187. data/app/assets/components/webcomponentsjs/MutationObserver.js +344 -0
  188. data/app/assets/components/webcomponentsjs/MutationObserver.min.js +11 -0
  189. data/app/assets/components/webcomponentsjs/README.md +125 -0
  190. data/app/assets/components/webcomponentsjs/ShadowDOM.js +4414 -0
  191. data/app/assets/components/webcomponentsjs/ShadowDOM.min.js +15 -0
  192. data/app/assets/components/webcomponentsjs/bower.json +14 -0
  193. data/app/assets/components/webcomponentsjs/build.log +33 -0
  194. data/app/assets/components/webcomponentsjs/package.json +31 -0
  195. data/app/assets/components/webcomponentsjs/webcomponents-lite.js +2300 -0
  196. data/app/assets/components/webcomponentsjs/webcomponents-lite.min.js +13 -0
  197. data/app/assets/components/webcomponentsjs/webcomponents.js +7112 -0
  198. data/app/assets/components/webcomponentsjs/webcomponents.min.js +15 -0
  199. data/lib/polymer-gold-rails.rb +2 -0
  200. data/lib/polymer-gold-rails/enigne.rb +4 -0
  201. data/lib/polymer-gold-rails/version.rb +3 -0
  202. metadata +312 -0
@@ -0,0 +1,495 @@
1
+ <!--
2
+ @license
3
+ Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
4
+ This code may only be used under the BSD style license found at http://polymer.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/CONTRIBUTORS.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/PATENTS.txt
9
+ -->
10
+
11
+ <link rel="import" href="../polymer/polymer.html">
12
+ <link rel="import" href="../paper-styles/paper-styles.html">
13
+
14
+ <!--
15
+ `<paper-input-container>` is a container for a `<label>`, an `<input is="iron-input">` or
16
+ `<iron-autogrow-textarea>` and optional add-on elements such as an error message or character
17
+ counter, used to implement Material Design text fields.
18
+
19
+ For example:
20
+
21
+ <paper-input-container>
22
+ <label>Your name</label>
23
+ <input is="iron-input">
24
+ </paper-input-container>
25
+
26
+ ### Listening for input changes
27
+
28
+ By default, it listens for changes on the `bind-value` attribute on its children nodes and perform
29
+ tasks such as auto-validating and label styling when the `bind-value` changes. You can configure
30
+ the attribute it listens to with the `attr-for-value` attribute.
31
+
32
+ ### Using a custom input element
33
+
34
+ You can use a custom input element in a `<paper-input-container>`, for example to implement a
35
+ compound input field like a social security number input. The custom input element should have the
36
+ `paper-input-input` class, have a `notify:true` value property and optionally implements
37
+ `Polymer.IronValidatableBehavior` if it is validatble.
38
+
39
+ <paper-input-container attr-for-value="ssn-value">
40
+ <label>Social security number</label>
41
+ <ssn-input class="paper-input-input"></ssn-input>
42
+ </paper-input-container>
43
+
44
+ ### Validation
45
+
46
+ If the `auto-validate` attribute is set, the input container will validate the input and update
47
+ the container styling when the input value changes.
48
+
49
+ ### Add-ons
50
+
51
+ Add-ons are child elements of a `<paper-input-container>` with the `add-on` attribute and
52
+ implements the `Polymer.PaperInputAddonBehavior` behavior. They are notified when the input value
53
+ or validity changes, and may implement functionality such as error messages or character counters.
54
+ They appear at the bottom of the input.
55
+
56
+ ### Styling
57
+
58
+ The following custom properties and mixins are available for styling:
59
+
60
+ Custom property | Description | Default
61
+ ----------------|-------------|----------
62
+ `--paper-input-container-color` | Label and underline color when the input is not focused | `--secondary-text-color`
63
+ `--paper-input-container-focus-color` | Label and underline color when the input is focused | `--default-primary-color`
64
+ `--paper-input-container-invalid-color` | Label and underline color when the input is focused | `--google-red-500`
65
+ `--paper-input-container-input-color` | Input foreground color | `--primary-text-color`
66
+ `--paper-input-container` | Mixin applied to the container | `{}`
67
+ `--paper-input-container-label` | Mixin applied to the label | `{}`
68
+ `--paper-input-container-input` | Mixin applied to the input | `{}`
69
+
70
+ This element is `display:block` by default, but you can set the `inline` attribute to make it
71
+ `display:inline-block`.
72
+ -->
73
+ <dom-module id="paper-input-container">
74
+
75
+ <style>
76
+
77
+ :host {
78
+ display: block;
79
+ padding: 8px 0;
80
+
81
+ @apply(--paper-input-container);
82
+ }
83
+
84
+ :host[inline] {
85
+ display: inline-block;
86
+ }
87
+
88
+ :host([disabled]) {
89
+ pointer-events: none;
90
+ opacity: 0.33;
91
+ }
92
+
93
+ .floated-label-placeholder {
94
+ @apply(--paper-font-caption);
95
+ }
96
+
97
+ .underline {
98
+ position: relative;
99
+ }
100
+
101
+ .focused-line {
102
+ height: 2px;
103
+
104
+ -webkit-transform-origin: center center;
105
+ transform-origin: center center;
106
+ -webkit-transform: scale3d(0,1,1);
107
+ transform: scale3d(0,1,1);
108
+
109
+ background: var(--paper-input-container-focus-color, --default-primary-color);
110
+ }
111
+
112
+ .underline.is-highlighted .focused-line {
113
+ -webkit-transform: none;
114
+ transform: none;
115
+ -webkit-transition: -webkit-transform 0.25s;
116
+ transition: transform 0.25s;
117
+
118
+ @apply(--paper-transition-easing);
119
+ }
120
+
121
+ .underline.is-invalid .focused-line {
122
+ background: var(--paper-input-container-invalid-color, --google-red-500);
123
+
124
+ -webkit-transform: none;
125
+ transform: none;
126
+ -webkit-transition: -webkit-transform 0.25s;
127
+ transition: transform 0.25s;
128
+
129
+ @apply(--paper-transition-easing);
130
+ }
131
+
132
+ .unfocused-line {
133
+ height: 1px;
134
+ background: var(--paper-input-container-color, --secondary-text-color);
135
+ }
136
+
137
+ :host([disabled]) .unfocused-line {
138
+ border-bottom: 1px dashed;
139
+ border-color: var(--paper-input-container-color, --secondary-text-color);
140
+ background: transparent;
141
+ }
142
+
143
+ .input-content {
144
+ position: relative;
145
+ }
146
+
147
+ .input-content ::content label,
148
+ .input-content ::content .paper-input-label {
149
+ position: absolute;
150
+ top: 0;
151
+ right: 0;
152
+ left: 0;
153
+ font: inherit;
154
+ color: var(--paper-input-container-color, --secondary-text-color);
155
+
156
+ @apply(--paper-font-subhead);
157
+ @apply(--paper-input-container-label);
158
+ }
159
+
160
+ .input-content.label-is-floating ::content label,
161
+ .input-content.label-is-floating ::content .paper-input-label {
162
+ -webkit-transform: translate3d(0, -75%, 0) scale(0.75);
163
+ transform: translate3d(0, -75%, 0) scale(0.75);
164
+ -webkit-transform-origin: left top;
165
+ transform-origin: left top;
166
+ -webkit-transition: -webkit-transform 0.25s;
167
+ transition: transform 0.25s;
168
+
169
+ @apply(--paper-transition-easing);
170
+ }
171
+
172
+ .input-content.label-is-highlighted ::content label,
173
+ .input-content.label-is-highlighted ::content .paper-input-label {
174
+ color: var(--paper-input-container-focus-color, --default-primary-color);
175
+ }
176
+
177
+ .input-content.is-invalid ::content label,
178
+ .input-content.is-invalid ::content .paper-input-label {
179
+ color: var(--paper-input-container-invalid-color, --google-red-500);
180
+ }
181
+
182
+ .input-content.label-is-hidden ::content label,
183
+ .input-content.label-is-hidden ::content .paper-input-label {
184
+ visibility: hidden;
185
+ }
186
+
187
+ .input-content ::content input,
188
+ .input-content ::content textarea,
189
+ .input-content ::content iron-autogrow-textarea,
190
+ .input-content ::content .paper-input-input {
191
+ position: relative; /* to make a stacking context */
192
+ outline: none;
193
+ box-shadow: none;
194
+ padding: 0;
195
+ width: 100%;
196
+ background: transparent;
197
+ border: none;
198
+ color: var(--paper-input-container-input-color, --primary-text-color);
199
+
200
+ @apply(--paper-font-subhead);
201
+ @apply(--paper-input-container-input);
202
+ }
203
+
204
+ /* Firefox sets a min-width on the input, which can cause layout issues */
205
+ .input-content ::content input {
206
+ min-width: 0;
207
+ }
208
+
209
+ .input-content ::content textarea {
210
+ resize: none;
211
+ }
212
+
213
+ .add-on-content.is-invalid ::content * {
214
+ color: var(--paper-input-container-invalid-color, --google-red-500);
215
+ }
216
+
217
+ .add-on-content.is-highlighted ::content * {
218
+ color: var(--paper-input-container-focus-color, --default-primary-color);
219
+ }
220
+
221
+ </style>
222
+
223
+ <template>
224
+
225
+ <template is="dom-if" if="[[!noLabelFloat]]">
226
+ <div class="floated-label-placeholder">&nbsp;</div>
227
+ </template>
228
+
229
+ <div class$="[[_computeInputContentClass(noLabelFloat,alwaysFloatLabel,focused,invalid,_inputHasContent)]]">
230
+ <content select=":not([add-on])"></content>
231
+ </div>
232
+
233
+ <div class$="[[_computeUnderlineClass(focused,invalid)]]">
234
+ <div class="unfocused-line fit"></div>
235
+ <div class="focused-line fit"></div>
236
+ </div>
237
+
238
+ <div class$="[[_computeAddOnContentClass(focused,invalid)]]">
239
+ <content id="addOnContent" select="[add-on]"></content>
240
+ </div>
241
+
242
+ </template>
243
+
244
+ </dom-module>
245
+
246
+ <script>
247
+ (function() {
248
+
249
+ Polymer({
250
+
251
+ is: 'paper-input-container',
252
+
253
+ properties: {
254
+
255
+ /**
256
+ * Set to true to disable the floating label. The label disappears when the input value is
257
+ * not null.
258
+ */
259
+ noLabelFloat: {
260
+ type: Boolean,
261
+ value: false
262
+ },
263
+
264
+ /**
265
+ * Set to true to always float the floating label.
266
+ */
267
+ alwaysFloatLabel: {
268
+ type: Boolean,
269
+ value: false
270
+ },
271
+
272
+ /**
273
+ * The attribute to listen for value changes on.
274
+ */
275
+ attrForValue: {
276
+ type: String,
277
+ value: 'bind-value'
278
+ },
279
+
280
+ /**
281
+ * Set to true to auto-validate the input value when it changes.
282
+ */
283
+ autoValidate: {
284
+ type: Boolean,
285
+ value: false
286
+ },
287
+
288
+ /**
289
+ * True if the input is invalid. This property is set automatically when the input value
290
+ * changes if auto-validating, or when the `iron-input-valid` event is heard from a child.
291
+ */
292
+ invalid: {
293
+ observer: '_invalidChanged',
294
+ type: Boolean,
295
+ value: false
296
+ },
297
+
298
+ /**
299
+ * True if the input has focus.
300
+ */
301
+ focused: {
302
+ readOnly: true,
303
+ type: Boolean,
304
+ value: false
305
+ },
306
+
307
+ _addons: {
308
+ type: Array,
309
+ value: function() {
310
+ return [];
311
+ }
312
+ },
313
+
314
+ _inputHasContent: {
315
+ type: Boolean,
316
+ value: false
317
+ },
318
+
319
+ _inputSelector: {
320
+ type: String,
321
+ value: 'input,textarea,.paper-input-input'
322
+ },
323
+
324
+ _boundOnFocus: {
325
+ type: Function,
326
+ value: function() {
327
+ return this._onFocus.bind(this);
328
+ }
329
+ },
330
+
331
+ _boundOnBlur: {
332
+ type: Function,
333
+ value: function() {
334
+ return this._onBlur.bind(this);
335
+ }
336
+ },
337
+
338
+ _boundOnInput: {
339
+ type: Function,
340
+ value: function() {
341
+ this._onInput.bind(this)
342
+ }
343
+ },
344
+
345
+ _boundValueChanged: {
346
+ type: Function,
347
+ value: function() {
348
+ return this._onValueChanged.bind(this);
349
+ }
350
+ }
351
+
352
+ },
353
+
354
+ listeners: {
355
+ 'addon-attached': '_onAddonAttached',
356
+ 'iron-input-validate': '_onIronInputValidate'
357
+ },
358
+
359
+ get _valueChangedEvent() {
360
+ return this.attrForValue + '-changed';
361
+ },
362
+
363
+ get _propertyForValue() {
364
+ return Polymer.CaseMap.dashToCamelCase(this.attrForValue);
365
+ },
366
+
367
+ get _inputElement() {
368
+ return Polymer.dom(this).querySelector(this._inputSelector);
369
+ },
370
+
371
+ ready: function() {
372
+ this.addEventListener('focus', this._boundOnFocus, true);
373
+ this.addEventListener('blur', this._boundOnBlur, true);
374
+ if (this.attrForValue) {
375
+ this._inputElement.addEventListener(this._valueChangedEvent, this._boundValueChanged);
376
+ } else {
377
+ this.addEventListener('input', this._onInput);
378
+ }
379
+ },
380
+
381
+ attached: function() {
382
+ this._handleValue(this._inputElement);
383
+ },
384
+
385
+ _onAddonAttached: function(event) {
386
+ this._addons.push(event.target);
387
+ this._handleValue(this._inputElement);
388
+ },
389
+
390
+ _onFocus: function() {
391
+ this._setFocused(true);
392
+ },
393
+
394
+ _onBlur: function() {
395
+ this._setFocused(false);
396
+ },
397
+
398
+ _onInput: function(event) {
399
+ this._handleValue(event.target);
400
+ },
401
+
402
+ _onValueChanged: function(event) {
403
+ this._handleValue(event.target);
404
+ },
405
+
406
+ _handleValue: function(inputElement) {
407
+ var value = inputElement[this._propertyForValue] || inputElement.value;
408
+
409
+ if (this.autoValidate) {
410
+ var valid;
411
+ if (inputElement.validate) {
412
+ valid = inputElement.validate(value);
413
+ } else {
414
+ valid = inputElement.checkValidity();
415
+ }
416
+ this.invalid = !valid;
417
+ }
418
+
419
+ // type="number" hack needed because this.value is empty until it's valid
420
+ if (value || (inputElement.type === 'number' && !inputElement.checkValidity())) {
421
+ this._inputHasContent = true;
422
+ } else {
423
+ this._inputHasContent = false;
424
+ }
425
+
426
+ this.updateAddons({
427
+ inputElement: inputElement,
428
+ value: value,
429
+ invalid: this.invalid
430
+ });
431
+ },
432
+
433
+ _onIronInputValidate: function(event) {
434
+ this.invalid = this._inputElement.invalid;
435
+ },
436
+
437
+ _invalidChanged: function() {
438
+ if (this._addons) {
439
+ this.updateAddons({invalid: this.invalid});
440
+ }
441
+ },
442
+
443
+ /**
444
+ * Call this to update the state of add-ons.
445
+ * @param {Object} state Add-on state.
446
+ */
447
+ updateAddons: function(state) {
448
+ for (var addon, index = 0; addon = this._addons[index]; index++) {
449
+ addon.update(state);
450
+ }
451
+ },
452
+
453
+ _computeInputContentClass: function(noLabelFloat, alwaysFloatLabel, focused, invalid, _inputHasContent) {
454
+ var cls = 'input-content';
455
+ if (!noLabelFloat) {
456
+ if (alwaysFloatLabel || _inputHasContent) {
457
+ cls += ' label-is-floating';
458
+ if (invalid) {
459
+ cls += ' is-invalid';
460
+ } else if (focused) {
461
+ cls += " label-is-highlighted";
462
+ }
463
+ }
464
+ } else {
465
+ if (_inputHasContent) {
466
+ cls += ' label-is-hidden';
467
+ }
468
+ }
469
+ return cls;
470
+ },
471
+
472
+ _computeUnderlineClass: function(focused, invalid) {
473
+ var cls = 'underline';
474
+ if (invalid) {
475
+ cls += ' is-invalid';
476
+ } else if (focused) {
477
+ cls += ' is-highlighted'
478
+ }
479
+ return cls;
480
+ },
481
+
482
+ _computeAddOnContentClass: function(focused, invalid) {
483
+ var cls = 'add-on-content';
484
+ if (invalid) {
485
+ cls += ' is-invalid';
486
+ } else if (focused) {
487
+ cls += ' is-highlighted'
488
+ }
489
+ return cls;
490
+ }
491
+
492
+ });
493
+
494
+ })();
495
+ </script>