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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,13 @@
1
+ # gold-phone-input
2
+
3
+ `gold-phone-input` is a Material Design field for entering and formatting a
4
+ phone number.
5
+
6
+ Example:
7
+
8
+ ```html
9
+ <gold-phone-input></gold-phone-input>
10
+
11
+ <gold-phone-input country-code="33" phone-number-pattern="X-XX-XX-XX-XX">
12
+ </gold-phone-input>
13
+ ```
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "gold-phone-input",
3
+ "version": "1.0.2",
4
+ "description": "A validating input for a phone number",
5
+ "authors": [
6
+ "The Polymer Authors"
7
+ ],
8
+ "keywords": [
9
+ "web-components",
10
+ "polymer",
11
+ "gold",
12
+ "input"
13
+ ],
14
+ "main": [
15
+ "gold-phone-input.html"
16
+ ],
17
+ "private": true,
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git://github.com/PolymerElements/gold-phone-input.git"
21
+ },
22
+ "license": "http://polymer.github.io/LICENSE.txt",
23
+ "homepage": "https://github.com/PolymerElements/gold-phone-input",
24
+ "ignore": [],
25
+ "dependencies": {
26
+ "iron-input": "PolymerElements/iron-input#^1.0.0",
27
+ "iron-form-element-behavior": "PolymerElements/iron-form-element-behavior#^1.0.0",
28
+ "paper-input": "PolymerElements/paper-input#^1.0.0",
29
+ "paper-styles": "PolymerElements/paper-styles#^1.0.0",
30
+ "polymer": "Polymer/polymer#^1.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
34
+ "iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0",
35
+ "test-fixture": "PolymerElements/test-fixture#^1.0.0",
36
+ "web-component-tester": "*",
37
+ "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
38
+ }
39
+ }
@@ -0,0 +1,53 @@
1
+ <!doctype html>
2
+ <!--
3
+ @license
4
+ Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
5
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8
+ Code distributed by Google as part of the polymer project is also
9
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10
+ -->
11
+ <html>
12
+ <head>
13
+
14
+ <meta charset="utf-8">
15
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
16
+ <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
17
+
18
+ <title>gold-phone-input demo</title>
19
+
20
+ <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
21
+ <link rel="import" href="../gold-phone-input.html">
22
+
23
+ <link rel="stylesheet" href="../../paper-styles/paper-styles.html">
24
+ <link rel="import" href="../../paper-styles/demo-pages.html">
25
+ </head>
26
+ <body>
27
+ <div class="vertical-section-container centered">
28
+ <h4>Standard</h4>
29
+ <div class="vertical-section">
30
+ <gold-phone-input></gold-phone-input>
31
+ <gold-phone-input auto-validate label="Auto-validating"></gold-phone-input>
32
+ <gold-phone-input
33
+ label="France phone number"
34
+ country-code="33"
35
+ phone-number-pattern="X-XX-XX-XX-XX"
36
+ auto-validate
37
+ required>
38
+ </gold-phone-input>
39
+ </div>
40
+
41
+ <h4>Pre-validated</h4>
42
+ <div class="vertical-section">
43
+ <gold-phone-input country-code="44" auto-validate required></gold-phone-input>
44
+ <gold-phone-input label="Valid US number" value="415-111-1111" auto-validate></gold-phone-input>
45
+ <gold-phone-input label="Invalid US number" value="415-111-111" auto-validate></gold-phone-input>
46
+ </div>
47
+
48
+ <h4>Custom error message</h4>
49
+ <div class="vertical-section">
50
+ <gold-phone-input auto-validate label="Cats only" error-message="needs more cats" required></gold-phone-input>
51
+ </div>
52
+ </div>
53
+ </body>
@@ -0,0 +1,197 @@
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
+ <link rel="import" href="../polymer/polymer.html">
11
+ <link rel="import" href="../paper-input/paper-input-behavior.html">
12
+ <link rel="import" href="../paper-input/paper-input-container.html">
13
+ <link rel="import" href="../paper-input/paper-input-error.html">
14
+ <link rel="import" href="../iron-input/iron-input.html">
15
+ <link rel="import" href="../iron-form-element-behavior/iron-form-element-behavior.html">
16
+ <link rel="import" href="../iron-flex-layout/classes/iron-flex-layout.html">
17
+
18
+ <!--
19
+ `<gold-phone-input>` is a single-line text field with Material Design styling
20
+ for entering a phone number.
21
+
22
+ <gold-phone-input></gold-phone-input>
23
+
24
+ It may include an optional label, which by default is "Phone number".
25
+
26
+ <gold-phone-input label="call this"></gold-phone-input>
27
+
28
+ ### Validation
29
+
30
+ By default, the phone number is considered to be a US phone number, and
31
+ will be validated according to the pattern `XXX-XXX-XXXX`, where `X` is a
32
+ digit, and `-` is the separating dash. If you want to customize the input
33
+ for a different area code or number pattern, use the `country-code` and
34
+ `phone-number-pattern` attributes
35
+
36
+ <gold-phone-input
37
+ country-code="33"
38
+ phone-number-pattern="X-XX-XX-XX-XX">
39
+ </gold-phone-input>
40
+
41
+ The input can be automatically validated as the user is typing by using
42
+ the `auto-validate` and `required` attributes. For manual validation, the
43
+ element also has a `validate()` method, which returns the validity of the
44
+ input as well sets any appropriate error messages and styles.
45
+
46
+ See `Polymer.PaperInputBehavior` for more API docs.
47
+
48
+ ### Styling
49
+
50
+ See `Polymer.PaperInputContainer` for a list of custom properties used to
51
+ style this element.
52
+
53
+ @group Gold Elements
54
+ @hero hero.svg
55
+ @demo demo/index.html
56
+ @class gold-phone-input
57
+ -->
58
+
59
+ <dom-module id="gold-phone-input">
60
+ <style>
61
+ :host {
62
+ display: block;
63
+ }
64
+
65
+ /* TODO: This should be a dropdown */
66
+ span {
67
+ @apply(--paper-font-subhead);
68
+ @apply(--paper-input-container-input);
69
+ width: 40px;
70
+ }
71
+
72
+ </style>
73
+
74
+ <template>
75
+ <paper-input-container id="container" auto-validate="[[autoValidate]]">
76
+
77
+ <label style="left:40px;" hidden$="[[!label]]">[[label]]</label>
78
+
79
+ <div class="horizontal layout">
80
+ <span>+<span>[[countryCode]]</span></span>
81
+
82
+ <input is="iron-input" id="input" class="flex"
83
+ aria-labelledby$="[[_ariaLabelledBy]]"
84
+ aria-describedby$="[[_ariaDescribedBy]]"
85
+ required$="[[required]]"
86
+ bind-value="{{value}}"
87
+ name$="[[name]]"
88
+ allowed-pattern="[0-9]"
89
+ autocomplete="tel"
90
+ type="tel"
91
+ prevent-invalid-input>
92
+ </div>
93
+
94
+ <template is="dom-if" if="[[errorMessage]]">
95
+ <paper-input-error id="error">[[errorMessage]]</paper-input-error>
96
+ </template>
97
+
98
+ </paper-input-container>
99
+ </template>
100
+
101
+ </dom-module>
102
+
103
+ <script>
104
+ (function() {
105
+ Polymer({
106
+
107
+ is: 'gold-phone-input',
108
+
109
+ behaviors: [
110
+ Polymer.PaperInputBehavior,
111
+ Polymer.IronFormElementBehavior
112
+ ],
113
+
114
+ properties: {
115
+ /**
116
+ * The label for this input.
117
+ */
118
+ label: {
119
+ type: String,
120
+ value: 'Phone number'
121
+ },
122
+
123
+ /*
124
+ * The country code that should be recognized and parsed.
125
+ */
126
+ countryCode: {
127
+ type: String,
128
+ value: '1'
129
+ },
130
+
131
+ /*
132
+ * The format of a valid phone number, including formatting but excluding
133
+ * the country code. Use 'X' to denote the digits separated by dashes.
134
+ */
135
+ phoneNumberPattern: {
136
+ type: String,
137
+ value: 'XXX-XXX-XXXX',
138
+ observer: '_phoneNumberPatternChanged'
139
+ }
140
+ },
141
+
142
+ observers: [
143
+ '_computeValue(value)'
144
+ ],
145
+
146
+ _phoneNumberPatternChanged: function() {
147
+ // Transform the pattern into a regex the iron-input understands.
148
+ var regex = '';
149
+ regex = this.phoneNumberPattern.replace(/\s/g, '\\s');
150
+ regex = regex.replace(/X/gi, '\\d');
151
+ regex = regex.replace(/\+/g, '\\+');
152
+ this.$.input.pattern = regex;
153
+
154
+ if (this.autoValidate) {
155
+ this.$.container.invalid = !this.$.input.validate();
156
+ }
157
+ },
158
+
159
+ _computeValue: function(value) {
160
+ var start = this.$.input.selectionStart;
161
+ var previousCharADash = this.value.charAt(start - 1) == '-';
162
+
163
+ // Remove any already-applied formatting.
164
+ value = value.replace(/-/g, '');
165
+ var shouldFormat = value.length <= this.phoneNumberPattern.replace(/-/g, '').length;
166
+ var formattedValue = '';
167
+
168
+ // Fill in the dashes according to the specified pattern.
169
+ var currentDashIndex = 0;
170
+ var totalDashesAdded = 0;
171
+ for (var i = 0; i < value.length; i++) {
172
+ currentDashIndex = this.phoneNumberPattern.indexOf('-', currentDashIndex);
173
+
174
+ // Since we remove any formatting first, we need to account added dashes
175
+ // when counting the position of new dashes in the pattern.
176
+ if (shouldFormat && i == (currentDashIndex - totalDashesAdded)) {
177
+ formattedValue += '-';
178
+ currentDashIndex++;
179
+ totalDashesAdded++;
180
+ }
181
+
182
+ formattedValue += value[i];
183
+ }
184
+
185
+ this.value = formattedValue.trim();
186
+
187
+ // If the character right before the selection is a newly inserted
188
+ // dash, we need to advance the selection to maintain the caret position.
189
+ if (!previousCharADash && this.value.charAt(start - 1) == '-')
190
+ this.$.input.selectionStart++;
191
+ }
192
+
193
+ })
194
+
195
+ })();
196
+
197
+ </script>
@@ -0,0 +1,63 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ viewBox="0 0 225 126" enable-background="new 0 0 225 126" xml:space="preserve">
6
+ <g id="background" display="none">
7
+ <rect display="inline" fill="#B0BEC5" width="225" height="126"/>
8
+ </g>
9
+ <g id="label">
10
+ </g>
11
+ <g id="art">
12
+ <rect x="43" y="68" width="33" height="2"/>
13
+ <rect x="89" y="68" width="33" height="2"/>
14
+ <rect x="135" y="68" width="42" height="2"/>
15
+ <g>
16
+ <path d="M51.9,61h1.3v1h-1.3v2.1h-1.3V62h-4.2v-0.7l4.1-6.4h1.3V61z M47.9,61h2.8v-4.4l-0.2,0.3L47.9,61z"/>
17
+ <path d="M55.2,63h1.9v-6.6l-2,0.7V56l3.2-1.2h0.1V63h1.8v1.1h-5V63z"/>
18
+ <path d="M63.1,59.5l0.5-4.6h4.8V56h-3.7l-0.3,2.4c0.2-0.1,0.4-0.2,0.6-0.3s0.5-0.1,0.9-0.1c0.4,0,0.8,0.1,1.2,0.2
19
+ c0.3,0.1,0.6,0.4,0.9,0.6c0.2,0.3,0.4,0.6,0.5,1s0.2,0.8,0.2,1.3c0,0.4-0.1,0.9-0.2,1.2c-0.1,0.4-0.3,0.7-0.5,1
20
+ c-0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0.2,0.2,0.4,0.5,0.5,0.8
49
+ s0.2,0.7,0.2,1c0,0.3,0,0.5-0.1,0.8s-0.2,0.5-0.4,0.8c-0.2,0.3-0.3,0.5-0.5,0.8s-0.4,0.5-0.7,0.8l-2.5,2.7h4.6V64.1z"/>
50
+ <path d="M156.6,63h1.9v-6.6l-2,0.7V56l3.2-1.2h0.1V63h1.8v1.1h-5V63z"/>
51
+ <path d="M169.8,64.1h-6.1v-0.9l3-3.4c0.3-0.3,0.5-0.6,0.7-0.8c0.2-0.2,0.3-0.4,0.4-0.6c0.1-0.2,0.2-0.4,0.2-0.5
52
+ c0-0.2,0.1-0.3,0.1-0.5c0-0.2,0-0.4-0.1-0.6c-0.1-0.2-0.2-0.4-0.3-0.5c-0.1-0.1-0.3-0.3-0.5-0.3s-0.4-0.1-0.6-0.1
53
+ c-0.3,0-0.6,0-0.8,0.1c-0.2,0.1-0.4,0.2-0.6,0.4c-0.2,0.2-0.3,0.4-0.3,0.6c-0.1,0.2-0.1,0.5-0.1,0.8h-1.3c0-0.4,0.1-0.8,0.2-1.1
54
+ s0.3-0.6,0.6-0.9c0.3-0.3,0.6-0.5,1-0.6s0.8-0.2,1.3-0.2c0.4,0,0.8,0.1,1.1,0.2c0.3,0.1,0.6,0.3,0.9,0.5c0.2,0.2,0.4,0.5,0.5,0.8
55
+ s0.2,0.7,0.2,1c0,0.3,0,0.5-0.1,0.8s-0.2,0.5-0.4,0.8c-0.2,0.3-0.3,0.5-0.5,0.8s-0.4,0.5-0.7,0.8l-2.5,2.7h4.6V64.1z"/>
56
+ </g>
57
+ <path d="M188,78H37V44h151V78z M39,76h147V46H39V76z"/>
58
+ <g id="ic_x5F_add_x0D_">
59
+ </g>
60
+ </g>
61
+ <g id="Guides">
62
+ </g>
63
+ </svg>
@@ -0,0 +1,28 @@
1
+ <!doctype html>
2
+ <!--
3
+ @license
4
+ Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
5
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8
+ Code distributed by Google as part of the polymer project is also
9
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10
+ -->
11
+ <html>
12
+ <head>
13
+
14
+ <meta charset="utf-8">
15
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
16
+
17
+ <title>gold-phone-input</title>
18
+
19
+ <script src="../webcomponentsjs/webcomponents-lite.js"></script>
20
+ <link rel="import" href="../iron-component-page/iron-component-page.html">
21
+
22
+ </head>
23
+ <body>
24
+
25
+ <iron-component-page></iron-component-page>
26
+
27
+ </body>
28
+ </html>
@@ -0,0 +1,117 @@
1
+ <!doctype html>
2
+ <!--
3
+ @license
4
+ Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
5
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8
+ Code distributed by Google as part of the polymer project is also
9
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10
+ -->
11
+ <html>
12
+ <head>
13
+
14
+ <title>gold-phone-input tests</title>
15
+
16
+ <meta charset="utf-8">
17
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
18
+ <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
19
+
20
+ <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
21
+
22
+ <script src="../../web-component-tester/browser.js"></script>
23
+ <script src="../../test-fixture/test-fixture-mocha.js"></script>
24
+
25
+ <script src="../../iron-test-helpers/test-helpers.js"></script>
26
+
27
+ <link rel="import" href="../../test-fixture/test-fixture.html">
28
+ <link rel="import" href="../gold-phone-input.html">
29
+
30
+ </head>
31
+ <body>
32
+
33
+ <test-fixture id="basic">
34
+ <template>
35
+ <gold-phone-input></gold-phone-input>
36
+ </template>
37
+ </test-fixture>
38
+
39
+ <test-fixture id="required">
40
+ <template>
41
+ <gold-phone-input auto-validate required error-message="error"></gold-phone-input>
42
+ </template>
43
+ </test-fixture>
44
+
45
+ <script>
46
+
47
+ suite('basic', function() {
48
+ test('input is spaced out correctly', function() {
49
+ var input = fixture('basic');
50
+ input.value='1231112222';
51
+ assert.equal(input.value, '123-111-2222');
52
+ });
53
+
54
+ test('invalid input is not ok', function() {
55
+ var input = fixture('required');
56
+ input.value='1234';
57
+ forceXIfStamp(input);
58
+
59
+ var container = Polymer.dom(input.root).querySelector('paper-input-container');
60
+ assert.ok(container, 'paper-input-container exists');
61
+ assert.isTrue(container.invalid);
62
+ });
63
+
64
+ test('valid input is ok', function() {
65
+ var input = fixture('required');
66
+ input.value='1231112222';
67
+ forceXIfStamp(input);
68
+
69
+ var container = Polymer.dom(input.root).querySelector('paper-input-container');
70
+ assert.ok(container, 'paper-input-container exists');
71
+ assert.isFalse(container.invalid);
72
+ });
73
+
74
+ test('empty required input shows error', function() {
75
+ var input = fixture('required');
76
+ forceXIfStamp(input);
77
+
78
+ var error = Polymer.dom(input.root).querySelector('paper-input-error');
79
+ assert.ok(error, 'paper-input-error exists');
80
+ assert.notEqual(getComputedStyle(error).display, 'none', 'error is not display:none');
81
+ });
82
+
83
+ // TODO: re-enable when PolymerElements/iron-input/issues/24 is fixed.
84
+ // test('caret position is preserved', function() {
85
+ // var input = fixture('required');
86
+ // var ironInput = input.querySelector('input[is="iron-input"]');
87
+ // input.value='111-111-1';
88
+ // ironInput.selectionStart = (2,2);
89
+ // input.value='112-111-11';
90
+ //
91
+ // assert.equal(ironInput.selectionStart, 2, 'selectionStart is preserved');
92
+ // assert.equal(ironInput.selectionEnd, 2, 'selectionEnd is preserved');
93
+ // });
94
+
95
+ suite('a11y', function() {
96
+
97
+ test('has aria-labelledby', function() {
98
+ var input = fixture('basic');
99
+ assert.isTrue(input.inputElement.hasAttribute('aria-labelledby'))
100
+ assert.equal(input.inputElement.getAttribute('aria-labelledby'), Polymer.dom(input.root).querySelector('label').id, 'aria-labelledby points to the label');
101
+ });
102
+
103
+ test('required and error has aria-labelledby', function() {
104
+ var input = fixture('required');
105
+ assert.isTrue(input.inputElement.hasAttribute('aria-labelledby'))
106
+ assert.equal(input.inputElement.getAttribute('aria-labelledby'), Polymer.dom(input.root).querySelector('label').id, 'aria-labelledby points to the label');
107
+ });
108
+
109
+ });
110
+
111
+
112
+ });
113
+
114
+ </script>
115
+
116
+ </body>
117
+ </html>