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