| OLD | NEW |
| (Empty) | |
| 1 |
| 2 <!doctype html> |
| 3 <!-- |
| 4 @license |
| 5 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 6 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 7 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 8 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 9 Code distributed by Google as part of the polymer project is also |
| 10 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 11 --> |
| 12 <html> |
| 13 <head> |
| 14 |
| 15 <title>iron-localstorage</title> |
| 16 |
| 17 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 18 |
| 19 <link rel="import" href="../../paper-styles/paper-styles.html"> |
| 20 <link rel="import" href="../../paper-styles/demo-pages.html"> |
| 21 <link rel="import" href="../../paper-checkbox/paper-checkbox.html"> |
| 22 |
| 23 <link rel="import" href="../iron-localstorage.html"> |
| 24 <style is="custom-style"> |
| 25 input { |
| 26 padding: 0.4em; |
| 27 font-size: 16px; |
| 28 margin: 15px 0; |
| 29 } |
| 30 </style> |
| 31 </head> |
| 32 <body> |
| 33 |
| 34 <div class="vertical-section vertical-section-container centered"> |
| 35 |
| 36 <template is="dom-bind"> |
| 37 <iron-localstorage |
| 38 name="polymer-localstorage-x-test1" |
| 39 value="{{value}}" |
| 40 on-iron-localstorage-load-empty="initializeDefaultValue" |
| 41 ></iron-localstorage> |
| 42 <p>Form element below will be kept in sync with <code>localStorage</code>.
</p> |
| 43 <p>Demo source also shows how to initialize storage to default value</p> |
| 44 <p>If you open another window with this test, changes in one window will p
ropagate to |
| 45 the other immediately.</p> |
| 46 <p>Name: <input value="{{value.name::change}}" placeholder="Enter words"><
/p> |
| 47 <paper-checkbox checked="{{value.hasEars::change}}">Has ears</paper-checkb
ox> |
| 48 </template> |
| 49 |
| 50 </div> |
| 51 |
| 52 <script> |
| 53 document.querySelector('template').initializeDefaultValue = function(ev) { |
| 54 console.log("initializeTemplate"); |
| 55 this.value = { |
| 56 name: "Mickey", |
| 57 hasEars: true |
| 58 } |
| 59 } |
| 60 </script> |
| 61 </body> |
| 62 </html> |
| OLD | NEW |