Index: polymer_1.0.4/bower_components/gold-cc-cvc-input/gold-cc-cvc-input.html |
diff --git a/polymer_1.0.4/bower_components/gold-cc-cvc-input/gold-cc-cvc-input.html b/polymer_1.0.4/bower_components/gold-cc-cvc-input/gold-cc-cvc-input.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4ad9ddad0e9f47fa5df1b908d091aeb401538134 |
--- /dev/null |
+++ b/polymer_1.0.4/bower_components/gold-cc-cvc-input/gold-cc-cvc-input.html |
@@ -0,0 +1,195 @@ |
+<!-- |
+@license |
+Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
+This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt |
+The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
+The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt |
+Code distributed by Google as part of the polymer project is also |
+subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt |
+--> |
+<link rel="import" href="../polymer/polymer.html"> |
+<link rel="import" href="../paper-input/paper-input-behavior.html"> |
+<link rel="import" href="../paper-input/paper-input-container.html"> |
+<link rel="import" href="../paper-input/paper-input-error.html"> |
+<link rel="import" href="../iron-input/iron-input.html"> |
+<link rel="import" href="../iron-icon/iron-icon.html"> |
+<link rel="import" href="../iron-form-element-behavior/iron-form-element-behavior.html"> |
+<link rel="import" href="../iron-flex-layout/classes/iron-flex-layout.html"> |
+ |
+<!-- |
+`gold-cc-cvc-input` is a single-line text field with Material Design styling |
+for entering a credit card's CVC (Card Verification Code). It supports both |
+4-digit Amex CVCs and non-Amex 3-digit CVCs |
+ |
+ <gold-cc-cvc-input></gold-cc-cvc-input> |
+ |
+ <gold-cc-cvc-input card-type="amex"></gold-cc-cvc-input> |
+ |
+It may include an optional label, which by default is "CVC". |
+ |
+ <gold-cc-cvc-input label="Card Verification Value"></gold-cc-cvc-input> |
+ |
+It can be used together with a `gold-cc-input` by binding the `cardType` property: |
+ |
+ <gold-cc-input card-type="{{cardType}}"></gold-cc-input> |
+ <gold-cc-cvc-input card-type="[[cardType]]"></gold-cc-cvc-input> |
+ |
+### Validation |
+ |
+The input considers a valid amex CVC to be 4 digits long, and 3 digits otherwise. |
+The `amex` attribute can also be bound to a `gold-cc-input`'s `card-type` attribute. |
+ |
+The input can be automatically validated as the user is typing by using |
+the `auto-validate` and `required` attributes. For manual validation, the |
+element also has a `validate()` method, which returns the validity of the |
+input as well sets any appropriate error messages and styles. |
+ |
+See `Polymer.PaperInputBehavior` for more API docs. |
+ |
+### Styling |
+ |
+See `Polymer.PaperInputContainer` for a list of custom properties used to |
+style this element. |
+ |
+@group Gold Elements |
+@hero hero.svg |
+@class gold-cc-cvc-input |
+@demo demo/index.html |
+--> |
+ |
+<dom-module id="gold-cc-cvc-input"> |
+ <style> |
+ :host { |
+ display: block; |
+ } |
+ |
+ iron-icon { |
+ margin-left: 10px; |
+ } |
+ </style> |
+ |
+ <template> |
+ <paper-input-container id="container" |
+ disabled$="[[disabled]]" |
+ no-label-float="[[noLabelFloat]]" |
+ always-float-label="[[_computeAlwaysFloatLabel(alwaysFloatLabel,placeholder)]]" |
+ invalid="[[invalid]]"> |
+ |
+ <label hidden$="[[!label]]">[[label]]</label> |
+ |
+ <div class="horizontal layout"> |
+ <input is="iron-input" id="input" class="flex" |
+ aria-labelledby$="[[_ariaLabelledBy]]" |
+ aria-describedby$="[[_ariaDescribedBy]]" |
+ bind-value="{{value}}" |
+ prevent-invalid-input allowed-pattern="[0-9]" |
+ required$="[[required]]" |
+ type="tel" |
+ maxlength$="[[_requiredLength]]" |
+ autocomplete="cc-csc" |
+ name$="[[name]]" |
+ disabled$="[[disabled]]" |
+ invalid="{{invalid}}" |
+ autofocus$="[[autofocus]]" |
+ inputmode$="[[inputmode]]" |
+ placeholder$="[[placeholder]]" |
+ readonly$="[[readonly]]" |
+ size$="[[size]]"> |
+ |
+ <iron-icon id="icon" src="cvc_hint.png" hidden$="[[_amex]]" alt="cvc"></iron-icon> |
+ <iron-icon id="amexIcon" hidden$="[[!_amex]]" src="cvc_hint_amex.png" alt="amex cvc"></iron-icon> |
+ </div> |
+ |
+ <template is="dom-if" if="[[errorMessage]]"> |
+ <paper-input-error>[[errorMessage]]</paper-input-error> |
+ </template> |
+ |
+ </paper-input-container> |
+ </template> |
+</dom-module> |
+ |
+<script> |
+(function() { |
+ Polymer({ |
+ |
+ is: 'gold-cc-cvc-input', |
+ |
+ properties: { |
+ |
+ /** |
+ * The label for this input. |
+ */ |
+ label: { |
+ type: String, |
+ value: 'CVC' |
+ }, |
+ |
+ /** |
+ * The type of card that the CVC is for. |
+ */ |
+ cardType: { |
+ type: String, |
+ value: '' |
+ }, |
+ |
+ _requiredLength: { |
+ type: Number, |
+ computed: '_computeRequiredLength(cardType)' |
+ }, |
+ |
+ _amex: { |
+ type: Boolean, |
+ computed: '_computeIsAmex(cardType)' |
+ } |
+ }, |
+ |
+ behaviors: [ |
+ Polymer.PaperInputBehavior, |
+ Polymer.IronFormElementBehavior |
+ ], |
+ |
+ listeners: { |
+ 'input': '_onInput' |
+ }, |
+ |
+ ready: function() { |
+ this._onInput(); |
+ }, |
+ |
+ _onInput: function() { |
+ if (this.autoValidate) { |
+ this.validate(); |
+ } |
+ }, |
+ |
+ _computeRequiredLength: function(cardType) { |
+ return this._computeIsAmex(cardType) ? 4 : 3; |
+ }, |
+ |
+ _computeIsAmex: function(cardType) { |
+ return cardType.toLowerCase() == 'amex'; |
+ }, |
+ |
+ validate: function() { |
+ // Empty, non-required input is valid. |
+ if (!this.required && this.value == '') { |
+ return true; |
+ } |
+ |
+ var valid = this.value.length == this._requiredLength; |
+ |
+ // Update the container and its addons (i.e. the custom error-message). |
+ this.$.container.invalid = !valid; |
+ this.$.container.updateAddons({ |
+ inputElement: this.$.input, |
+ value: this.value, |
+ invalid: !valid |
+ }); |
+ |
+ return valid; |
+ } |
+ }) |
+ |
+})(); |
+ |
+</script> |