OLD | NEW |
(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-form-element-behavior/iron-form-element-behavio
r.html"> |
| 16 <link rel="import" href="zip-validator.html"> |
| 17 |
| 18 <!-- |
| 19 `gold-zip-input` is a single-line text field with Material Design styling |
| 20 for entering a US zip code. |
| 21 |
| 22 <gold-zip-input></gold-zip-input> |
| 23 |
| 24 It may include an optional label, which by default is "Zip Code". |
| 25 |
| 26 <gold-zip-input label="Mailing zip code"></gold-zip-input> |
| 27 |
| 28 ### Validation |
| 29 |
| 30 The input supports both 5 digit zip codes (90210) or the full 9 digit ones, |
| 31 separated by a dash (90210-9999). |
| 32 |
| 33 The input can be automatically validated as the user is typing by using |
| 34 the `auto-validate` and `required` attributes. For manual validation, the |
| 35 element also has a `validate()` method, which returns the validity of the |
| 36 input as well sets any appropriate error messages and styles. |
| 37 |
| 38 See `Polymer.PaperInputBehavior` for more API docs. |
| 39 |
| 40 ### Styling |
| 41 |
| 42 See `Polymer.PaperInputContainer` for a list of custom properties used to |
| 43 style this element. |
| 44 |
| 45 @group Gold Elements |
| 46 @hero hero.svg |
| 47 @demo demo/index.html |
| 48 @class gold-zip-input |
| 49 --> |
| 50 |
| 51 <dom-module id="gold-zip-input"> |
| 52 <style> |
| 53 :host { |
| 54 display: block; |
| 55 } |
| 56 </style> |
| 57 |
| 58 <template> |
| 59 |
| 60 <paper-input-container id="container" |
| 61 auto-validate="[[autoValidate]]" |
| 62 attr-for-value="bind-value"> |
| 63 |
| 64 <label hidden$="[[!label]]">[[label]]</label> |
| 65 |
| 66 <zip-validator></zip-validator> |
| 67 |
| 68 <input is="iron-input" id="input" |
| 69 aria-labelledby$="[[_ariaLabelledBy]]" |
| 70 aria-describedby$="[[_ariaDescribedBy]]" |
| 71 required$="[[required]]" |
| 72 validator="zip-validator" |
| 73 type="tel" |
| 74 maxlength="10" |
| 75 bind-value="{{value}}" |
| 76 autocomplete="postal-code" |
| 77 name$="[[name]]"> |
| 78 |
| 79 <template is="dom-if" if="[[errorMessage]]"> |
| 80 <paper-input-error id="error">[[errorMessage]]</paper-input-error> |
| 81 </template> |
| 82 |
| 83 </paper-input-container> |
| 84 </template> |
| 85 |
| 86 </dom-module> |
| 87 |
| 88 <script> |
| 89 (function() { |
| 90 Polymer({ |
| 91 |
| 92 is: 'gold-zip-input', |
| 93 |
| 94 behaviors: [ |
| 95 Polymer.PaperInputBehavior, |
| 96 Polymer.IronFormElementBehavior |
| 97 ], |
| 98 |
| 99 properties: { |
| 100 /** |
| 101 * The label for this input. |
| 102 */ |
| 103 label: { |
| 104 type: String, |
| 105 value: "Zip Code" |
| 106 } |
| 107 } |
| 108 |
| 109 }) |
| 110 |
| 111 })(); |
| 112 |
| 113 </script> |
OLD | NEW |