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.
- checksums.yaml +7 -0
- data/README.md +36 -0
- data/Rakefile +1 -0
- data/app/assets/components/gold-cc-cvc-input/README.md +24 -0
- data/app/assets/components/gold-cc-cvc-input/bower.json +39 -0
- data/app/assets/components/gold-cc-cvc-input/cvc_hint.png +0 -0
- data/app/assets/components/gold-cc-cvc-input/cvc_hint_amex.png +0 -0
- data/app/assets/components/gold-cc-cvc-input/demo/index.html +54 -0
- data/app/assets/components/gold-cc-cvc-input/gold-cc-cvc-input.html +195 -0
- data/app/assets/components/gold-cc-cvc-input/hero.svg +36 -0
- data/app/assets/components/gold-cc-cvc-input/index.html +26 -0
- data/app/assets/components/gold-cc-cvc-input/test/basic.html +125 -0
- data/app/assets/components/gold-cc-cvc-input/test/index.html +25 -0
- data/app/assets/components/gold-cc-expiration-input/README.md +10 -0
- data/app/assets/components/gold-cc-expiration-input/bower.json +40 -0
- data/app/assets/components/gold-cc-expiration-input/date-input.html +157 -0
- data/app/assets/components/gold-cc-expiration-input/date-validator.html +38 -0
- data/app/assets/components/gold-cc-expiration-input/demo/index.html +53 -0
- data/app/assets/components/gold-cc-expiration-input/gold-cc-expiration-input.html +131 -0
- data/app/assets/components/gold-cc-expiration-input/hero.svg +58 -0
- data/app/assets/components/gold-cc-expiration-input/index.html +28 -0
- data/app/assets/components/gold-cc-expiration-input/test/basic.html +126 -0
- data/app/assets/components/gold-cc-expiration-input/test/index.html +25 -0
- data/app/assets/components/gold-cc-input/README.md +9 -0
- data/app/assets/components/gold-cc-input/bower.json +39 -0
- data/app/assets/components/gold-cc-input/cc-validator.js +192 -0
- data/app/assets/components/gold-cc-input/demo/index.html +48 -0
- data/app/assets/components/gold-cc-input/gold-cc-input.html +215 -0
- data/app/assets/components/gold-cc-input/hero.svg +52 -0
- data/app/assets/components/gold-cc-input/images/amex.png +0 -0
- data/app/assets/components/gold-cc-input/images/diners_club.png +0 -0
- data/app/assets/components/gold-cc-input/images/discover.png +0 -0
- data/app/assets/components/gold-cc-input/images/jcb.png +0 -0
- data/app/assets/components/gold-cc-input/images/mastercard.png +0 -0
- data/app/assets/components/gold-cc-input/images/visa.png +0 -0
- data/app/assets/components/gold-cc-input/index.html +28 -0
- data/app/assets/components/gold-cc-input/test/basic.html +136 -0
- data/app/assets/components/gold-cc-input/test/index.html +25 -0
- data/app/assets/components/gold-elements/README.md +12 -0
- data/app/assets/components/gold-elements/bower.json +42 -0
- data/app/assets/components/gold-elements/demo/complex-form.html +127 -0
- data/app/assets/components/gold-elements/demo/index.html +94 -0
- data/app/assets/components/gold-elements/demo/item-card.html +59 -0
- data/app/assets/components/gold-elements/demo/simple-form.css +55 -0
- data/app/assets/components/gold-elements/demo/simple-form.html +93 -0
- data/app/assets/components/gold-elements/screenshot.png +0 -0
- data/app/assets/components/gold-email-input/README.md +8 -0
- data/app/assets/components/gold-email-input/bower.json +40 -0
- data/app/assets/components/gold-email-input/demo/index.html +46 -0
- data/app/assets/components/gold-email-input/email-validator.html +31 -0
- data/app/assets/components/gold-email-input/gold-email-input.html +108 -0
- data/app/assets/components/gold-email-input/hero.svg +59 -0
- data/app/assets/components/gold-email-input/index.html +28 -0
- data/app/assets/components/gold-email-input/test/basic.html +97 -0
- data/app/assets/components/gold-email-input/test/index.html +25 -0
- data/app/assets/components/gold-phone-input/README.md +13 -0
- data/app/assets/components/gold-phone-input/bower.json +39 -0
- data/app/assets/components/gold-phone-input/demo/index.html +53 -0
- data/app/assets/components/gold-phone-input/gold-phone-input.html +197 -0
- data/app/assets/components/gold-phone-input/hero.svg +63 -0
- data/app/assets/components/gold-phone-input/index.html +28 -0
- data/app/assets/components/gold-phone-input/test/basic.html +117 -0
- data/app/assets/components/gold-phone-input/test/index.html +25 -0
- data/app/assets/components/gold-zip-input/README.md +8 -0
- data/app/assets/components/gold-zip-input/bower.json +40 -0
- data/app/assets/components/gold-zip-input/demo/index.html +54 -0
- data/app/assets/components/gold-zip-input/gold-zip-input.html +113 -0
- data/app/assets/components/gold-zip-input/hero.svg +43 -0
- data/app/assets/components/gold-zip-input/index.html +28 -0
- data/app/assets/components/gold-zip-input/test/basic.html +116 -0
- data/app/assets/components/gold-zip-input/test/index.html +25 -0
- data/app/assets/components/gold-zip-input/zip-validator.html +32 -0
- data/app/assets/components/iron-autogrow-textarea/README.md +24 -0
- data/app/assets/components/iron-autogrow-textarea/bower.json +37 -0
- data/app/assets/components/iron-autogrow-textarea/demo/index.html +81 -0
- data/app/assets/components/iron-autogrow-textarea/hero.svg +33 -0
- data/app/assets/components/iron-autogrow-textarea/index.html +30 -0
- data/app/assets/components/iron-autogrow-textarea/iron-autogrow-textarea.html +263 -0
- data/app/assets/components/iron-autogrow-textarea/test/basic.html +94 -0
- data/app/assets/components/iron-autogrow-textarea/test/index.html +25 -0
- data/app/assets/components/iron-flex-layout/README.md +4 -0
- data/app/assets/components/iron-flex-layout/bower.json +21 -0
- data/app/assets/components/iron-flex-layout/classes/iron-flex-layout.html +307 -0
- data/app/assets/components/iron-flex-layout/classes/iron-shadow-flex-layout.html +302 -0
- data/app/assets/components/iron-flex-layout/demo/index.html +40 -0
- data/app/assets/components/iron-flex-layout/demo/x-app.html +106 -0
- data/app/assets/components/iron-flex-layout/iron-flex-layout.html +313 -0
- data/app/assets/components/iron-form-element-behavior/README.md +2 -0
- data/app/assets/components/iron-form-element-behavior/bower.json +27 -0
- data/app/assets/components/iron-form-element-behavior/demo/index.html +53 -0
- data/app/assets/components/iron-form-element-behavior/demo/simple-element.html +27 -0
- data/app/assets/components/iron-form-element-behavior/demo/simple-form.html +42 -0
- data/app/assets/components/iron-form-element-behavior/index.html +30 -0
- data/app/assets/components/iron-form-element-behavior/iron-form-element-behavior.html +50 -0
- data/app/assets/components/iron-icon/README.md +56 -0
- data/app/assets/components/iron-icon/bower.json +29 -0
- data/app/assets/components/iron-icon/demo/index.html +28 -0
- data/app/assets/components/iron-icon/demo/location.png +0 -0
- data/app/assets/components/iron-icon/hero.svg +19 -0
- data/app/assets/components/iron-icon/index.html +26 -0
- data/app/assets/components/iron-icon/iron-icon.html +187 -0
- data/app/assets/components/iron-icon/test/index.html +31 -0
- data/app/assets/components/iron-icon/test/iron-icon.html +120 -0
- data/app/assets/components/iron-input/README.md +16 -0
- data/app/assets/components/iron-input/bower.json +36 -0
- data/app/assets/components/iron-input/demo/index.html +87 -0
- data/app/assets/components/iron-input/hero.svg +19 -0
- data/app/assets/components/iron-input/index.html +30 -0
- data/app/assets/components/iron-input/iron-input.html +235 -0
- data/app/assets/components/iron-input/test/index.html +24 -0
- data/app/assets/components/iron-input/test/iron-input.html +139 -0
- data/app/assets/components/iron-input/test/letters-only.html +30 -0
- data/app/assets/components/iron-meta/README.md +46 -0
- data/app/assets/components/iron-meta/bower.json +28 -0
- data/app/assets/components/iron-meta/demo/index.html +45 -0
- data/app/assets/components/iron-meta/hero.svg +33 -0
- data/app/assets/components/iron-meta/index.html +27 -0
- data/app/assets/components/iron-meta/iron-meta.html +352 -0
- data/app/assets/components/iron-meta/test/basic.html +48 -0
- data/app/assets/components/iron-meta/test/index.html +30 -0
- data/app/assets/components/iron-meta/test/iron-meta.html +186 -0
- data/app/assets/components/iron-validatable-behavior/README.md +3 -0
- data/app/assets/components/iron-validatable-behavior/bower.json +35 -0
- data/app/assets/components/iron-validatable-behavior/demo/cats-only.html +46 -0
- data/app/assets/components/iron-validatable-behavior/demo/index.html +71 -0
- data/app/assets/components/iron-validatable-behavior/demo/validatable-input.html +46 -0
- data/app/assets/components/iron-validatable-behavior/index.html +30 -0
- data/app/assets/components/iron-validatable-behavior/iron-validatable-behavior.html +101 -0
- data/app/assets/components/iron-validatable-behavior/test/index.html +35 -0
- data/app/assets/components/iron-validatable-behavior/test/iron-validatable-behavior.html +52 -0
- data/app/assets/components/iron-validatable-behavior/test/test-validatable.html +28 -0
- data/app/assets/components/iron-validator-behavior/README.md +4 -0
- data/app/assets/components/iron-validator-behavior/bower.json +34 -0
- data/app/assets/components/iron-validator-behavior/demo/cats-only.html +46 -0
- data/app/assets/components/iron-validator-behavior/demo/index.html +144 -0
- data/app/assets/components/iron-validator-behavior/index.html +30 -0
- data/app/assets/components/iron-validator-behavior/iron-validator-behavior.html +61 -0
- data/app/assets/components/iron-validator-behavior/test/index.html +34 -0
- data/app/assets/components/iron-validator-behavior/test/iron-validator-behavior.html +47 -0
- data/app/assets/components/iron-validator-behavior/test/simple-validator.html +26 -0
- data/app/assets/components/paper-input/README.md +5 -0
- data/app/assets/components/paper-input/all-imports.html +12 -0
- data/app/assets/components/paper-input/bower.json +44 -0
- data/app/assets/components/paper-input/demo/index.html +96 -0
- data/app/assets/components/paper-input/demo/ssn-input.html +94 -0
- data/app/assets/components/paper-input/demo/ssn-validator.html +31 -0
- data/app/assets/components/paper-input/hero.svg +19 -0
- data/app/assets/components/paper-input/index.html +28 -0
- data/app/assets/components/paper-input/paper-input-addon-behavior.html +47 -0
- data/app/assets/components/paper-input/paper-input-behavior.html +317 -0
- data/app/assets/components/paper-input/paper-input-char-counter.html +95 -0
- data/app/assets/components/paper-input/paper-input-container.html +495 -0
- data/app/assets/components/paper-input/paper-input-error.html +99 -0
- data/app/assets/components/paper-input/paper-input.html +126 -0
- data/app/assets/components/paper-input/paper-textarea.html +106 -0
- data/app/assets/components/paper-input/test/index.html +28 -0
- data/app/assets/components/paper-input/test/letters-only.html +30 -0
- data/app/assets/components/paper-input/test/paper-input-char-counter.html +112 -0
- data/app/assets/components/paper-input/test/paper-input-container.html +237 -0
- data/app/assets/components/paper-input/test/paper-input-error.html +60 -0
- data/app/assets/components/paper-input/test/paper-input.html +213 -0
- data/app/assets/components/paper-input/test/paper-textarea.html +169 -0
- data/app/assets/components/paper-styles/README.md +3 -0
- data/app/assets/components/paper-styles/bower.json +27 -0
- data/app/assets/components/paper-styles/classes/global.html +96 -0
- data/app/assets/components/paper-styles/classes/shadow-layout.html +302 -0
- data/app/assets/components/paper-styles/classes/shadow.html +39 -0
- data/app/assets/components/paper-styles/classes/typography.html +171 -0
- data/app/assets/components/paper-styles/color.html +333 -0
- data/app/assets/components/paper-styles/default-theme.html +39 -0
- data/app/assets/components/paper-styles/demo-pages.html +72 -0
- data/app/assets/components/paper-styles/demo.css +25 -0
- data/app/assets/components/paper-styles/paper-styles-classes.html +14 -0
- data/app/assets/components/paper-styles/paper-styles.html +17 -0
- data/app/assets/components/paper-styles/shadow.html +61 -0
- data/app/assets/components/paper-styles/typography.html +240 -0
- data/app/assets/components/polymer/LICENSE.txt +27 -0
- data/app/assets/components/polymer/bower.json +26 -0
- data/app/assets/components/polymer/build.log +27 -0
- data/app/assets/components/polymer/polymer-micro.html +523 -0
- data/app/assets/components/polymer/polymer-mini.html +1368 -0
- data/app/assets/components/polymer/polymer.html +3768 -0
- data/app/assets/components/webcomponentsjs/CustomElements.js +956 -0
- data/app/assets/components/webcomponentsjs/CustomElements.min.js +11 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.js +1078 -0
- data/app/assets/components/webcomponentsjs/HTMLImports.min.js +11 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.js +344 -0
- data/app/assets/components/webcomponentsjs/MutationObserver.min.js +11 -0
- data/app/assets/components/webcomponentsjs/README.md +125 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.js +4414 -0
- data/app/assets/components/webcomponentsjs/ShadowDOM.min.js +15 -0
- data/app/assets/components/webcomponentsjs/bower.json +14 -0
- data/app/assets/components/webcomponentsjs/build.log +33 -0
- data/app/assets/components/webcomponentsjs/package.json +31 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.js +2300 -0
- data/app/assets/components/webcomponentsjs/webcomponents-lite.min.js +13 -0
- data/app/assets/components/webcomponentsjs/webcomponents.js +7112 -0
- data/app/assets/components/webcomponentsjs/webcomponents.min.js +15 -0
- data/lib/polymer-gold-rails.rb +2 -0
- data/lib/polymer-gold-rails/enigne.rb +4 -0
- data/lib/polymer-gold-rails/version.rb +3 -0
- metadata +312 -0
@@ -0,0 +1,48 @@
|
|
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-cc-input demo</title>
|
19
|
+
|
20
|
+
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
21
|
+
<link rel="import" href="../gold-cc-input.html">
|
22
|
+
|
23
|
+
<link rel="stylesheet" href="../../paper-styles/paper-styles.html">
|
24
|
+
<link rel="import" href="../../paper-styles/demo-pages.html">
|
25
|
+
|
26
|
+
</head>
|
27
|
+
<body>
|
28
|
+
<div class="vertical-section-container centered">
|
29
|
+
<h4>Standard</h4>
|
30
|
+
<div class="vertical-section">
|
31
|
+
<gold-cc-input></gold-cc-input>
|
32
|
+
<gold-cc-input auto-validate label="Auto-validating"></gold-cc-input>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<h4>Pre-validated</h4>
|
36
|
+
<div class="vertical-section">
|
37
|
+
<gold-cc-input label="Visa" value="4000 0000 0000 0002" auto-validate></gold-cc-input>
|
38
|
+
<gold-cc-input label= "MasterCard" value="5100 0000 0000 0008" auto-validate></gold-cc-input>
|
39
|
+
<gold-cc-input label="Discover" value="6011 0000 0000 0004" auto-validate></gold-cc-input>
|
40
|
+
<gold-cc-input label="Invalid Discover Card" value="6011 0000 0000 1233" auto-validate></gold-cc-input>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<h4>Custom error message</h4>
|
44
|
+
<div class="vertical-section">
|
45
|
+
<gold-cc-input auto-validate label="Cats only" error-message="needs more cats" required></gold-cc-input>
|
46
|
+
<div>
|
47
|
+
</div>
|
48
|
+
</body>
|
@@ -0,0 +1,215 @@
|
|
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="../iron-flex-layout/classes/iron-flex-layout.html">
|
12
|
+
<link rel="import" href="../paper-input/paper-input-behavior.html">
|
13
|
+
<link rel="import" href="../paper-input/paper-input-container.html">
|
14
|
+
<link rel="import" href="../paper-input/paper-input-error.html">
|
15
|
+
<link rel="import" href="../iron-input/iron-input.html">
|
16
|
+
<link rel="import" href="../iron-form-element-behavior/iron-form-element-behavior.html">
|
17
|
+
<link rel="import" href="../iron-icon/iron-icon.html">
|
18
|
+
|
19
|
+
<script src="cc-validator.js"></script>
|
20
|
+
|
21
|
+
<!--
|
22
|
+
`gold-cc-input` is a single-line text field with Material Design styling
|
23
|
+
for entering a credit card number. As the user types, the number will be
|
24
|
+
formatted by adding a space every 4 digits.
|
25
|
+
|
26
|
+
<gold-cc-input></gold-cc-input>
|
27
|
+
|
28
|
+
It may include an optional label, which by default is "Card number".
|
29
|
+
|
30
|
+
<gold-cc-input label="CC"></gold-cc-input>
|
31
|
+
|
32
|
+
### Validation
|
33
|
+
|
34
|
+
The input can detect whether a credit card number is valid, and the type
|
35
|
+
of credit card it is, using the Luhn checksum. See `http://jquerycreditcardvalidator.com/`
|
36
|
+
for more information.
|
37
|
+
|
38
|
+
The input can be automatically validated as the user is typing by using
|
39
|
+
the `auto-validate` and `required` attributes. For manual validation, the
|
40
|
+
element also has a `validate()` method, which returns the validity of the
|
41
|
+
input as well sets any appropriate error messages and styles.
|
42
|
+
|
43
|
+
See `Polymer.PaperInputBehavior` for more API docs.
|
44
|
+
|
45
|
+
### Styling
|
46
|
+
|
47
|
+
See `Polymer.PaperInputContainer` for a list of custom properties used to
|
48
|
+
style this element.
|
49
|
+
|
50
|
+
@group Gold Elements
|
51
|
+
@hero hero.svg
|
52
|
+
@demo demo/index.html
|
53
|
+
@class gold-cc-input
|
54
|
+
-->
|
55
|
+
|
56
|
+
<dom-module id="gold-cc-input">
|
57
|
+
<style is="custom-style">
|
58
|
+
:host {
|
59
|
+
display: block;
|
60
|
+
}
|
61
|
+
|
62
|
+
/* Use a container so that when hiding the icon, the layout doesn't jump around. */
|
63
|
+
.icon-container {
|
64
|
+
margin-left: 10px;
|
65
|
+
height: 27px;
|
66
|
+
}
|
67
|
+
|
68
|
+
iron-icon {
|
69
|
+
--iron-icon-width: 40px;
|
70
|
+
--iron-icon-height: 24px;
|
71
|
+
}
|
72
|
+
</style>
|
73
|
+
|
74
|
+
<template>
|
75
|
+
|
76
|
+
<paper-input-container id="container"
|
77
|
+
disabled$="[[disabled]]"
|
78
|
+
no-label-float="[[noLabelFloat]]"
|
79
|
+
always-float-label="[[_computeAlwaysFloatLabel(alwaysFloatLabel,placeholder)]]"
|
80
|
+
invalid="[[invalid]]">
|
81
|
+
|
82
|
+
<label hidden$="[[!label]]">[[label]]</label>
|
83
|
+
|
84
|
+
<div class="horizontal layout">
|
85
|
+
<input is="iron-input" id="input"
|
86
|
+
aria-labelledby$="[[_ariaLabelledBy]]"
|
87
|
+
aria-describedby$="[[_ariaDescribedBy]]"
|
88
|
+
bind-value="{{value}}"
|
89
|
+
type="tel"
|
90
|
+
maxlength="30"
|
91
|
+
required$="[[required]]"
|
92
|
+
allowed-pattern="[0-9 ]"
|
93
|
+
prevent-invalid-input
|
94
|
+
autocomplete="cc-number"
|
95
|
+
name$="[[name]]"
|
96
|
+
disabled$="[[disabled]]"
|
97
|
+
invalid="{{invalid}}"
|
98
|
+
autofocus$="[[autofocus]]"
|
99
|
+
inputmode$="[[inputmode]]"
|
100
|
+
placeholder$="[[placeholder]]"
|
101
|
+
readonly$="[[readonly]]"
|
102
|
+
size$="[[size]]">
|
103
|
+
<div class="icon-container"><iron-icon id="icon"></iron-icon></div>
|
104
|
+
</div>
|
105
|
+
|
106
|
+
<template is="dom-if" if="[[errorMessage]]">
|
107
|
+
<paper-input-error>[[errorMessage]]</paper-input-error>
|
108
|
+
</template>
|
109
|
+
|
110
|
+
</paper-input-container>
|
111
|
+
</template>
|
112
|
+
|
113
|
+
</dom-module>
|
114
|
+
|
115
|
+
<script>
|
116
|
+
(function() {
|
117
|
+
Polymer({
|
118
|
+
|
119
|
+
is: 'gold-cc-input',
|
120
|
+
|
121
|
+
behaviors: [
|
122
|
+
Polymer.PaperInputBehavior,
|
123
|
+
Polymer.IronValidatableBehavior,
|
124
|
+
Polymer.IronFormElementBehavior
|
125
|
+
],
|
126
|
+
|
127
|
+
properties: {
|
128
|
+
/**
|
129
|
+
* The label for this input.
|
130
|
+
*/
|
131
|
+
label: {
|
132
|
+
type: String,
|
133
|
+
value: "Card number"
|
134
|
+
},
|
135
|
+
|
136
|
+
/**
|
137
|
+
* The type of the credit card, if it is valid. Empty otherwise.
|
138
|
+
*/
|
139
|
+
cardType: {
|
140
|
+
type: String,
|
141
|
+
notify: true
|
142
|
+
},
|
143
|
+
},
|
144
|
+
|
145
|
+
observers: [
|
146
|
+
'_computeValue(value)'
|
147
|
+
],
|
148
|
+
|
149
|
+
_computeValue: function(value) {
|
150
|
+
var start = this.$.input.selectionStart;
|
151
|
+
var previousCharASpace = this.value.charAt(start - 1) == ' ';
|
152
|
+
|
153
|
+
value = value.replace(/\s+/g, '');
|
154
|
+
var formattedValue = '';
|
155
|
+
for (var i = 0; i < value.length; i++) {
|
156
|
+
// Add a space after every 4 characters.
|
157
|
+
if ((i != 0) && (i % 4 == 0)) {
|
158
|
+
formattedValue += ' ';
|
159
|
+
}
|
160
|
+
formattedValue += value[i];
|
161
|
+
}
|
162
|
+
this.value = formattedValue.trim();
|
163
|
+
|
164
|
+
if (this.autoValidate)
|
165
|
+
this.validate();
|
166
|
+
|
167
|
+
// The cursor automatically jumps to the end after re-setting the value,
|
168
|
+
// so restore it to its original position.
|
169
|
+
this.$.input.selectionStart = start;
|
170
|
+
this.$.input.selectionEnd = start;
|
171
|
+
|
172
|
+
// If the character right before the selection is a newly inserted
|
173
|
+
// space, we need to advance the selection to maintain the caret position.
|
174
|
+
if (!previousCharASpace && this.value.charAt(start - 1) == ' ') {
|
175
|
+
this.$.input.selectionStart = start+1;
|
176
|
+
this.$.input.selectionEnd = start+1;
|
177
|
+
}
|
178
|
+
},
|
179
|
+
|
180
|
+
validate: function() {
|
181
|
+
// Empty, non-required input is valid.
|
182
|
+
if (!this.required && this.value == '') {
|
183
|
+
return true;
|
184
|
+
}
|
185
|
+
|
186
|
+
var result = CreditCardValidator.validate(this.value);
|
187
|
+
var valid = result.valid && result.length_valid;
|
188
|
+
this.cardType = valid ? result.card_type.name : '';
|
189
|
+
|
190
|
+
// Update the container and its addons (i.e. the custom error-message).
|
191
|
+
this.$.container.invalid = !valid;
|
192
|
+
this.$.container.updateAddons({
|
193
|
+
inputElement: this.$.input,
|
194
|
+
value: this.value,
|
195
|
+
invalid: !valid
|
196
|
+
});
|
197
|
+
|
198
|
+
// We don't have icons for all the card types.
|
199
|
+
if (valid && result.card_type.icon) {
|
200
|
+
this.$.icon.src = this.resolveUrl(result.card_type.icon);
|
201
|
+
this.$.icon.alt = this.cardType;
|
202
|
+
this.$.icon.hidden = false;
|
203
|
+
} else {
|
204
|
+
this.$.icon.src = null;
|
205
|
+
this.$.icon.alt = '';
|
206
|
+
this.$.icon.hidden = true;
|
207
|
+
}
|
208
|
+
|
209
|
+
return valid;
|
210
|
+
}
|
211
|
+
})
|
212
|
+
|
213
|
+
})();
|
214
|
+
|
215
|
+
</script>
|
@@ -0,0 +1,52 @@
|
|
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="38" y="68" width="33" height="2"/>
|
13
|
+
<rect x="77" y="68" width="33" height="2"/>
|
14
|
+
<rect x="116" y="68" width="33" height="2"/>
|
15
|
+
<rect x="155" y="68" width="33" height="2"/>
|
16
|
+
<g>
|
17
|
+
<path d="M42.3,58.4l2-3.6h1.5l-2.8,4.6l2.9,4.7h-1.5l-2.1-3.6l-2.1,3.6h-1.5l2.9-4.7l-2.8-4.6h1.5L42.3,58.4z"/>
|
18
|
+
<path d="M50.1,58.4l2-3.6h1.5l-2.8,4.6l2.9,4.7h-1.5l-2.1-3.6l-2.1,3.6h-1.5l2.9-4.7l-2.8-4.6h1.5L50.1,58.4z"/>
|
19
|
+
<path d="M57.9,58.4l2-3.6h1.5l-2.8,4.6l2.9,4.7H60L58,60.5l-2.1,3.6h-1.5l2.9-4.7l-2.8-4.6h1.5L57.9,58.4z"/>
|
20
|
+
<path d="M65.7,58.4l2-3.6h1.5l-2.8,4.6l2.9,4.7h-1.5l-2.1-3.6l-2.1,3.6h-1.5l2.9-4.7l-2.8-4.6h1.5L65.7,58.4z"/>
|
21
|
+
<path d="M81.3,58.4l2-3.6h1.5l-2.8,4.6l2.9,4.7h-1.5l-2.1-3.6l-2.1,3.6h-1.5l2.9-4.7l-2.8-4.6h1.5L81.3,58.4z"/>
|
22
|
+
<path d="M89.1,58.4l2-3.6h1.5l-2.8,4.6l2.9,4.7h-1.5l-2.1-3.6l-2.1,3.6h-1.5l2.9-4.7l-2.8-4.6h1.5L89.1,58.4z"/>
|
23
|
+
<path d="M96.9,58.4l2-3.6h1.5l-2.8,4.6l2.9,4.7H99L97,60.5l-2.1,3.6h-1.5l2.9-4.7l-2.8-4.6h1.5L96.9,58.4z"/>
|
24
|
+
<path d="M104.7,58.4l2-3.6h1.5l-2.8,4.6l2.9,4.7h-1.5l-2.1-3.6l-2.1,3.6h-1.5l2.9-4.7l-2.8-4.6h1.5L104.7,58.4z"/>
|
25
|
+
<path d="M120.3,58.4l2-3.6h1.5l-2.8,4.6l2.9,4.7h-1.5l-2.1-3.6l-2.1,3.6h-1.5l2.9-4.7l-2.8-4.6h1.5L120.3,58.4z"/>
|
26
|
+
<path d="M128.1,58.4l2-3.6h1.5l-2.8,4.6l2.9,4.7h-1.5l-2.1-3.6l-2.1,3.6h-1.5l2.9-4.7l-2.8-4.6h1.5L128.1,58.4z"/>
|
27
|
+
<path d="M135.9,58.4l2-3.6h1.5l-2.8,4.6l2.9,4.7H138l-2.1-3.6l-2.1,3.6h-1.5l2.9-4.7l-2.8-4.6h1.5L135.9,58.4z"/>
|
28
|
+
<path d="M143.7,58.4l2-3.6h1.5l-2.8,4.6l2.9,4.7h-1.5l-2.1-3.6l-2.1,3.6h-1.5l2.9-4.7l-2.8-4.6h1.5L143.7,58.4z"/>
|
29
|
+
<path d="M156.8,63h1.9v-6.6l-2,0.7V56l3.2-1.2h0.1V63h1.8v1.1h-5V63z"/>
|
30
|
+
<path d="M170,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
|
31
|
+
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
|
32
|
+
c-0.3,0-0.6,0-0.8,0.1s-0.4,0.2-0.6,0.4c-0.2,0.2-0.3,0.4-0.3,0.6s-0.1,0.5-0.1,0.8h-1.3c0-0.4,0.1-0.8,0.2-1.1s0.3-0.6,0.6-0.9
|
33
|
+
c0.3-0.3,0.6-0.5,1-0.6c0.4-0.2,0.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.5s0.4,0.5,0.5,0.8s0.2,0.7,0.2,1
|
34
|
+
c0,0.3,0,0.5-0.1,0.8c-0.1,0.3-0.2,0.5-0.4,0.8c-0.2,0.3-0.3,0.5-0.5,0.8c-0.2,0.3-0.4,0.5-0.7,0.8l-2.5,2.7h4.6V64.1z"/>
|
35
|
+
<path d="M173.5,58.9h0.9c0.3,0,0.6,0,0.8-0.1s0.4-0.2,0.5-0.3c0.1-0.1,0.3-0.3,0.3-0.5c0.1-0.2,0.1-0.4,0.1-0.6
|
36
|
+
c0-1.1-0.5-1.6-1.5-1.6c-0.2,0-0.5,0-0.7,0.1c-0.2,0.1-0.4,0.2-0.5,0.3c-0.1,0.1-0.2,0.3-0.3,0.5s-0.1,0.4-0.1,0.6h-1.3
|
37
|
+
c0-0.3,0.1-0.7,0.2-1s0.3-0.6,0.6-0.8c0.2-0.2,0.6-0.4,0.9-0.5c0.4-0.1,0.7-0.2,1.2-0.2c0.4,0,0.8,0.1,1.1,0.2s0.6,0.3,0.9,0.5
|
38
|
+
c0.2,0.2,0.4,0.5,0.6,0.8s0.2,0.7,0.2,1.1c0,0.2,0,0.3-0.1,0.5s-0.1,0.4-0.2,0.6s-0.3,0.3-0.4,0.5c-0.2,0.2-0.4,0.3-0.6,0.4
|
39
|
+
c0.3,0.1,0.6,0.2,0.8,0.4c0.2,0.2,0.3,0.3,0.5,0.5s0.2,0.4,0.2,0.6c0,0.2,0.1,0.4,0.1,0.6c0,0.4-0.1,0.8-0.2,1.2
|
40
|
+
c-0.2,0.3-0.4,0.6-0.6,0.9s-0.6,0.4-0.9,0.5c-0.4,0.1-0.8,0.2-1.2,0.2c-0.4,0-0.8-0.1-1.1-0.2c-0.4-0.1-0.7-0.3-0.9-0.5
|
41
|
+
s-0.5-0.5-0.6-0.8s-0.2-0.7-0.2-1.1h1.3c0,0.2,0,0.4,0.1,0.6c0.1,0.2,0.2,0.4,0.3,0.5c0.1,0.1,0.3,0.2,0.5,0.3s0.4,0.1,0.7,0.1
|
42
|
+
c0.3,0,0.5,0,0.7-0.1c0.2-0.1,0.4-0.2,0.5-0.3c0.1-0.1,0.3-0.3,0.3-0.5c0.1-0.2,0.1-0.5,0.1-0.7c0-0.3,0-0.5-0.1-0.7
|
43
|
+
s-0.2-0.4-0.4-0.5c-0.2-0.1-0.4-0.2-0.6-0.3c-0.2-0.1-0.5-0.1-0.8-0.1h-0.9V58.9z"/>
|
44
|
+
<path d="M184.7,61h1.3v1h-1.3v2.1h-1.3V62h-4.2v-0.7l4.1-6.4h1.3V61z M180.7,61h2.8v-4.4l-0.2,0.3L180.7,61z"/>
|
45
|
+
</g>
|
46
|
+
<path d="M194,78H31V44h163V78z M33,76h159V46H33V76z"/>
|
47
|
+
<g id="ic_x5F_add_x0D_">
|
48
|
+
</g>
|
49
|
+
</g>
|
50
|
+
<g id="Guides">
|
51
|
+
</g>
|
52
|
+
</svg>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -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-cc-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,136 @@
|
|
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-cc-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-cc-input.html">
|
29
|
+
|
30
|
+
</head>
|
31
|
+
<body>
|
32
|
+
|
33
|
+
<test-fixture id="basic">
|
34
|
+
<template>
|
35
|
+
<gold-cc-input></gold-cc-input>
|
36
|
+
</template>
|
37
|
+
</test-fixture>
|
38
|
+
|
39
|
+
<test-fixture id="ErrorWithoutAutoValidate">
|
40
|
+
<template>
|
41
|
+
<gold-cc-input required error-message="error"></gold-cc-input>
|
42
|
+
</template>
|
43
|
+
</test-fixture>
|
44
|
+
|
45
|
+
<test-fixture id="required">
|
46
|
+
<template>
|
47
|
+
<gold-cc-input auto-validate required error-message="error"></gold-cc-input>
|
48
|
+
</template>
|
49
|
+
</test-fixture>
|
50
|
+
|
51
|
+
<script>
|
52
|
+
|
53
|
+
suite('basic', function() {
|
54
|
+
test('input is spaced out correctly', function() {
|
55
|
+
var input = fixture('basic');
|
56
|
+
input.value='12345678';
|
57
|
+
assert.equal(input.value, '1234 5678');
|
58
|
+
});
|
59
|
+
|
60
|
+
test('invalid input is not ok', function() {
|
61
|
+
var input = fixture('required');
|
62
|
+
input.value='1234';
|
63
|
+
forceXIfStamp(input);
|
64
|
+
|
65
|
+
var container = Polymer.dom(input.root).querySelector('paper-input-container');
|
66
|
+
assert.ok(container, 'paper-input-container exists');
|
67
|
+
assert.isTrue(container.invalid);
|
68
|
+
assert.equal(input.cardType, '');
|
69
|
+
});
|
70
|
+
|
71
|
+
test('valid input is ok', function() {
|
72
|
+
var input = fixture('required');
|
73
|
+
input.value='4000000000000002';
|
74
|
+
forceXIfStamp(input);
|
75
|
+
|
76
|
+
var container = Polymer.dom(input.root).querySelector('paper-input-container');
|
77
|
+
assert.ok(container, 'paper-input-container exists');
|
78
|
+
assert.isFalse(container.invalid);
|
79
|
+
assert.equal(input.cardType, 'visa');
|
80
|
+
});
|
81
|
+
|
82
|
+
test('empty required input shows error', function() {
|
83
|
+
var input = fixture('required');
|
84
|
+
forceXIfStamp(input);
|
85
|
+
|
86
|
+
var error = Polymer.dom(input.root).querySelector('paper-input-error');
|
87
|
+
assert.ok(error, 'paper-input-error exists');
|
88
|
+
assert.notEqual(getComputedStyle(error).display, 'none', 'error is not display:none');
|
89
|
+
});
|
90
|
+
|
91
|
+
test('invalid input shows error message after manual validation', function() {
|
92
|
+
var input = fixture('ErrorWithoutAutoValidate');
|
93
|
+
forceXIfStamp(input);
|
94
|
+
var error = Polymer.dom(input.root).querySelector('paper-input-error');
|
95
|
+
assert.ok(error, 'paper-input-error exists');
|
96
|
+
|
97
|
+
// The error message is only displayed after manual validation.
|
98
|
+
assert.equal(getComputedStyle(error).display, 'none', 'error is not display:none');
|
99
|
+
input.validate();
|
100
|
+
assert.notEqual(getComputedStyle(error).display, 'none', 'error is not display:none');
|
101
|
+
});
|
102
|
+
|
103
|
+
test('caret position is preserved', function() {
|
104
|
+
var input = fixture('required');
|
105
|
+
var ironInput = Polymer.dom(input.root).querySelector('input[is="iron-input"]');
|
106
|
+
input.value='1111 1111';
|
107
|
+
ironInput.selectionStart = 2;
|
108
|
+
ironInput.selectionEnd = 2;
|
109
|
+
input._computeValue('1122 1111 11');
|
110
|
+
|
111
|
+
assert.equal(ironInput.selectionStart, 2, 'selectionStart is preserved');
|
112
|
+
assert.equal(ironInput.selectionEnd, 2, 'selectionEnd is preserved');
|
113
|
+
});
|
114
|
+
|
115
|
+
});
|
116
|
+
|
117
|
+
suite('a11y', function() {
|
118
|
+
|
119
|
+
test('has aria-labelledby', function() {
|
120
|
+
var input = fixture('basic');
|
121
|
+
assert.isTrue(input.inputElement.hasAttribute('aria-labelledby'))
|
122
|
+
assert.equal(input.inputElement.getAttribute('aria-labelledby'), Polymer.dom(input.root).querySelector('label').id, 'aria-labelledby points to the label');
|
123
|
+
});
|
124
|
+
|
125
|
+
test('required and error has aria-labelledby', function() {
|
126
|
+
var input = fixture('required');
|
127
|
+
assert.isTrue(input.inputElement.hasAttribute('aria-labelledby'))
|
128
|
+
assert.equal(input.inputElement.getAttribute('aria-labelledby'), Polymer.dom(input.root).querySelector('label').id, 'aria-labelledby points to the label');
|
129
|
+
});
|
130
|
+
|
131
|
+
});
|
132
|
+
|
133
|
+
</script>
|
134
|
+
|
135
|
+
</body>
|
136
|
+
</html>
|