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 |
| 11 <link rel="import" href="../polymer/polymer.html"> |
| 12 |
| 13 <script> |
| 14 /** |
| 15 Polymer.IronFormElementBehavior enables a custom element to be included |
| 16 in an `iron-form`. |
| 17 |
| 18 @demo demo/index.html |
| 19 @polymerBehavior |
| 20 */ |
| 21 Polymer.IronFormElementBehavior = { |
| 22 |
| 23 properties: { |
| 24 /** |
| 25 * Fired when the element is added to an `iron-form`. |
| 26 * |
| 27 * @event iron-form-element-register |
| 28 */ |
| 29 |
| 30 /** |
| 31 * Fired when the element is removed from an `iron-form`. |
| 32 * |
| 33 * @event iron-form-element-unregister |
| 34 */ |
| 35 |
| 36 /** |
| 37 * The name of this element. |
| 38 */ |
| 39 name: { |
| 40 type: String |
| 41 }, |
| 42 |
| 43 /** |
| 44 * The value for this element. |
| 45 */ |
| 46 value: { |
| 47 notify: true, |
| 48 type: String |
| 49 }, |
| 50 |
| 51 /** |
| 52 * Set to true to mark the input as required. If used in a form, a |
| 53 * custom element that uses this behavior should also use |
| 54 * Polymer.IronValidatableBehavior and define a custom validation method. |
| 55 * Otherwise, a `required` element will always be considered valid. |
| 56 * It's also strongly recommended to provide a visual style for the elemen
t |
| 57 * when its value is invalid. |
| 58 */ |
| 59 required: { |
| 60 type: Boolean, |
| 61 value: false |
| 62 }, |
| 63 |
| 64 /** |
| 65 * The form that the element is registered to. |
| 66 */ |
| 67 _parentForm: { |
| 68 type: Object |
| 69 } |
| 70 }, |
| 71 |
| 72 attached: function() { |
| 73 // Note: the iron-form that this element belongs to will set this |
| 74 // element's _parentForm property when handling this event. |
| 75 this.fire('iron-form-element-register'); |
| 76 }, |
| 77 |
| 78 detached: function() { |
| 79 if (this._parentForm) { |
| 80 this._parentForm.fire('iron-form-element-unregister', {target: this}); |
| 81 } |
| 82 } |
| 83 |
| 84 }; |
| 85 |
| 86 </script> |
OLD | NEW |