| OLD | NEW |
| (Empty) | |
| 1 <!doctype html> |
| 2 <!-- |
| 3 @license |
| 4 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 5 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 6 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 7 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 8 Code distributed by Google as part of the polymer project is also |
| 9 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 10 --> |
| 11 <html> |
| 12 <head> |
| 13 |
| 14 <meta charset="utf-8"> |
| 15 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| 16 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initia
l-scale=1, user-scalable=yes"> |
| 17 |
| 18 <title>iron-autogrow-textarea demo</title> |
| 19 |
| 20 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 21 <link rel="import" href="../iron-autogrow-textarea.html"> |
| 22 |
| 23 <link rel="stylesheet" href="../../paper-styles/paper-styles.html"> |
| 24 <link rel="import" href="../../paper-styles/demo-pages.html"> |
| 25 </head> |
| 26 <style> |
| 27 iron-autogrow-textarea { |
| 28 width: 200px; |
| 29 } |
| 30 </style> |
| 31 <body> |
| 32 <div class="vertical-section-container centered"> |
| 33 <h4>Updating the value imperatively</h4> |
| 34 <template is="dom-bind"> |
| 35 <div class="vertical-section"> |
| 36 <iron-autogrow-textarea bind-value="{{bindValue}}" id="a1"></iron-auto
grow-textarea> |
| 37 <br><br> |
| 38 |
| 39 <code>bind-value</code>: <span>[[bindValue]]</span> |
| 40 |
| 41 <p on-click="setValue"> |
| 42 set <code>bind-value</code> to: <br> |
| 43 <textarea></textarea> |
| 44 <button value="bindValue">set</button> |
| 45 <br><br> |
| 46 |
| 47 set <code>textarea.value</code> to: <br> |
| 48 <textarea></textarea> |
| 49 <button value="value">set</button> |
| 50 </p> |
| 51 </div> |
| 52 </template> |
| 53 |
| 54 <h4>Custom</h4> |
| 55 <div class="vertical-section"> |
| 56 <p>Scrolls after 4 rows:</p> |
| 57 <iron-autogrow-textarea max-rows="4"></iron-autogrow-textarea> |
| 58 <p>Initial height of 4 rows</p> |
| 59 <iron-autogrow-textarea rows="4"></iron-autogrow-textarea> |
| 60 </div> |
| 61 </div> |
| 62 |
| 63 <script> |
| 64 var scope = document.querySelector('template[is=dom-bind]'); |
| 65 |
| 66 scope.setValue = function(event) { |
| 67 if (!(event.target instanceof HTMLButtonElement)) { |
| 68 return; |
| 69 } |
| 70 var inputValue = event.target.previousElementSibling.value; |
| 71 if (event.target.value == "bindValue") { |
| 72 document.querySelector('iron-autogrow-textarea').bindValue = inputValu
e; |
| 73 } else { |
| 74 document.querySelector('iron-autogrow-textarea').textarea.value = inpu
tValue; |
| 75 } |
| 76 |
| 77 } |
| 78 </script> |
| 79 |
| 80 </body> |
| 81 </html> |
| OLD | NEW |