Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: polymer_1.0.4/bower_components/gold-cc-cvc-input/gold-cc-cvc-input.html

Issue 1205703007: Add polymer 1.0 to npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Renamed folder to 1.0.4 Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.g ithub.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/CONTRI BUTORS.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/PATEN TS.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-icon/iron-icon.html">
16 <link rel="import" href="../iron-form-element-behavior/iron-form-element-behavio r.html">
17 <link rel="import" href="../iron-flex-layout/classes/iron-flex-layout.html">
18
19 <!--
20 `gold-cc-cvc-input` is a single-line text field with Material Design styling
21 for entering a credit card's CVC (Card Verification Code). It supports both
22 4-digit Amex CVCs and non-Amex 3-digit CVCs
23
24 <gold-cc-cvc-input></gold-cc-cvc-input>
25
26 <gold-cc-cvc-input card-type="amex"></gold-cc-cvc-input>
27
28 It may include an optional label, which by default is "CVC".
29
30 <gold-cc-cvc-input label="Card Verification Value"></gold-cc-cvc-input>
31
32 It can be used together with a `gold-cc-input` by binding the `cardType` propert y:
33
34 <gold-cc-input card-type="{{cardType}}"></gold-cc-input>
35 <gold-cc-cvc-input card-type="[[cardType]]"></gold-cc-cvc-input>
36
37 ### Validation
38
39 The input considers a valid amex CVC to be 4 digits long, and 3 digits otherwise .
40 The `amex` attribute can also be bound to a `gold-cc-input`'s `card-type` attrib ute.
41
42 The input can be automatically validated as the user is typing by using
43 the `auto-validate` and `required` attributes. For manual validation, the
44 element also has a `validate()` method, which returns the validity of the
45 input as well sets any appropriate error messages and styles.
46
47 See `Polymer.PaperInputBehavior` for more API docs.
48
49 ### Styling
50
51 See `Polymer.PaperInputContainer` for a list of custom properties used to
52 style this element.
53
54 @group Gold Elements
55 @hero hero.svg
56 @class gold-cc-cvc-input
57 @demo demo/index.html
58 -->
59
60 <dom-module id="gold-cc-cvc-input">
61 <style>
62 :host {
63 display: block;
64 }
65
66 iron-icon {
67 margin-left: 10px;
68 }
69 </style>
70
71 <template>
72 <paper-input-container id="container"
73 disabled$="[[disabled]]"
74 no-label-float="[[noLabelFloat]]"
75 always-float-label="[[_computeAlwaysFloatLabel(alwaysFloatLabel,placehol der)]]"
76 invalid="[[invalid]]">
77
78 <label hidden$="[[!label]]">[[label]]</label>
79
80 <div class="horizontal layout">
81 <input is="iron-input" id="input" class="flex"
82 aria-labelledby$="[[_ariaLabelledBy]]"
83 aria-describedby$="[[_ariaDescribedBy]]"
84 bind-value="{{value}}"
85 prevent-invalid-input allowed-pattern="[0-9]"
86 required$="[[required]]"
87 type="tel"
88 maxlength$="[[_requiredLength]]"
89 autocomplete="cc-csc"
90 name$="[[name]]"
91 disabled$="[[disabled]]"
92 invalid="{{invalid}}"
93 autofocus$="[[autofocus]]"
94 inputmode$="[[inputmode]]"
95 placeholder$="[[placeholder]]"
96 readonly$="[[readonly]]"
97 size$="[[size]]">
98
99 <iron-icon id="icon" src="cvc_hint.png" hidden$="[[_amex]]" alt="cvc"></ iron-icon>
100 <iron-icon id="amexIcon" hidden$="[[!_amex]]" src="cvc_hint_amex.png" al t="amex cvc"></iron-icon>
101 </div>
102
103 <template is="dom-if" if="[[errorMessage]]">
104 <paper-input-error>[[errorMessage]]</paper-input-error>
105 </template>
106
107 </paper-input-container>
108 </template>
109 </dom-module>
110
111 <script>
112 (function() {
113 Polymer({
114
115 is: 'gold-cc-cvc-input',
116
117 properties: {
118
119 /**
120 * The label for this input.
121 */
122 label: {
123 type: String,
124 value: 'CVC'
125 },
126
127 /**
128 * The type of card that the CVC is for.
129 */
130 cardType: {
131 type: String,
132 value: ''
133 },
134
135 _requiredLength: {
136 type: Number,
137 computed: '_computeRequiredLength(cardType)'
138 },
139
140 _amex: {
141 type: Boolean,
142 computed: '_computeIsAmex(cardType)'
143 }
144 },
145
146 behaviors: [
147 Polymer.PaperInputBehavior,
148 Polymer.IronFormElementBehavior
149 ],
150
151 listeners: {
152 'input': '_onInput'
153 },
154
155 ready: function() {
156 this._onInput();
157 },
158
159 _onInput: function() {
160 if (this.autoValidate) {
161 this.validate();
162 }
163 },
164
165 _computeRequiredLength: function(cardType) {
166 return this._computeIsAmex(cardType) ? 4 : 3;
167 },
168
169 _computeIsAmex: function(cardType) {
170 return cardType.toLowerCase() == 'amex';
171 },
172
173 validate: function() {
174 // Empty, non-required input is valid.
175 if (!this.required && this.value == '') {
176 return true;
177 }
178
179 var valid = this.value.length == this._requiredLength;
180
181 // Update the container and its addons (i.e. the custom error-message).
182 this.$.container.invalid = !valid;
183 this.$.container.updateAddons({
184 inputElement: this.$.input,
185 value: this.value,
186 invalid: !valid
187 });
188
189 return valid;
190 }
191 })
192
193 })();
194
195 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698