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="../iron-input/iron-input.html"> |
| 12 <link rel="import" href="paper-input-container.html"> |
| 13 <link rel="import" href="paper-input-error.html"> |
| 14 <link rel="import" href="paper-input-char-counter.html"> |
| 15 |
| 16 <!-- |
| 17 `<paper-input>` is a text field. |
| 18 --> |
| 19 |
| 20 <dom-module id="paper-input"> |
| 21 |
| 22 <template> |
| 23 |
| 24 <paper-input-container no-label-float$="[[noLabelFloat]]" auto-validate$="[[
autoValidate]]"> |
| 25 |
| 26 <template is="x-if" if="[[label]]"> |
| 27 <label>[[parent.label]]</label> |
| 28 </template> |
| 29 |
| 30 <input is="iron-input" id="input" bind-value="{{value}}" prevent-invalid-i
nput="[[preventInvalidInput]]" type$="[[type]]" pattern$="[[pattern]]" maxlength
$="[[maxlength]]" required$="[[required]]"> |
| 31 |
| 32 <template is="x-if" if="[[errorMessage]]"> |
| 33 <paper-input-error>[[parent.errorMessage]]</paper-input-error> |
| 34 </template> |
| 35 |
| 36 <template is="x-if" if="[[charCounter]]"> |
| 37 <paper-input-char-counter></paper-input-char-counter> |
| 38 </template> |
| 39 |
| 40 </paper-input-container> |
| 41 |
| 42 </template> |
| 43 |
| 44 </dom-module> |
| 45 |
| 46 <script> |
| 47 |
| 48 (function() { |
| 49 |
| 50 Polymer({ |
| 51 |
| 52 is: 'paper-input', |
| 53 |
| 54 properties: { |
| 55 |
| 56 /** |
| 57 * The label for this input. |
| 58 */ |
| 59 label: { |
| 60 type: String |
| 61 }, |
| 62 |
| 63 /** |
| 64 * The value for this input. |
| 65 */ |
| 66 value: { |
| 67 notify: true, |
| 68 type: String |
| 69 }, |
| 70 |
| 71 /** |
| 72 * Set to true to prevent the user from entering invalid input. |
| 73 */ |
| 74 preventInvalidInput: { |
| 75 type: Boolean |
| 76 }, |
| 77 |
| 78 /** |
| 79 * The type of the input. The supported types are `text`, `number` and `pa
ssword`. |
| 80 */ |
| 81 type: { |
| 82 type: String |
| 83 }, |
| 84 |
| 85 /** |
| 86 * A pattern to validate the `input` with. |
| 87 */ |
| 88 pattern: { |
| 89 type: String |
| 90 }, |
| 91 |
| 92 /** |
| 93 * Set to true to mark the input as required. |
| 94 */ |
| 95 required: { |
| 96 type: Boolean, |
| 97 value: false |
| 98 }, |
| 99 |
| 100 /** |
| 101 * The maximum length of the input value. |
| 102 */ |
| 103 maxlength: { |
| 104 type: Number |
| 105 }, |
| 106 |
| 107 /** |
| 108 * The error message to display when the input is invalid. |
| 109 */ |
| 110 errorMessage: { |
| 111 type: String |
| 112 }, |
| 113 |
| 114 /** |
| 115 * Set to true to show a character counter. |
| 116 */ |
| 117 charCounter: { |
| 118 type: Boolean, |
| 119 value: false |
| 120 }, |
| 121 |
| 122 /** |
| 123 * Set to true to disable the floating label. |
| 124 */ |
| 125 noLabelFloat: { |
| 126 type: Boolean, |
| 127 value: false |
| 128 }, |
| 129 |
| 130 /** |
| 131 * Set to true to auto-validate the input value. |
| 132 */ |
| 133 autoValidate: { |
| 134 type: Boolean, |
| 135 value: false |
| 136 } |
| 137 |
| 138 }, |
| 139 |
| 140 /** |
| 141 * Returns a reference to the input element. |
| 142 */ |
| 143 get inputElement() { |
| 144 return this.$.input; |
| 145 } |
| 146 |
| 147 }) |
| 148 |
| 149 })(); |
| 150 |
| 151 </script> |
OLD | NEW |