OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <!-- |
| 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 <html> |
| 11 <head> |
| 12 |
| 13 <title>iron-page-url</title> |
| 14 |
| 15 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 16 <link rel="import" href="../../polymer/polymer.html"> |
| 17 <link rel="import" href="../iron-page-url.html"> |
| 18 <link rel="import" href="../../paper-styles/typography.html"> |
| 19 <link rel="import" href="../../iron-flex-layout/iron-flex-layout.html"> |
| 20 <link rel="import" href="../../paper-input/paper-input.html"> |
| 21 <link rel="import" href="../../paper-slider/paper-slider.html"> |
| 22 <link rel="stylesheet" href="../../paper-styles/demo.css"> |
| 23 </head> |
| 24 <body> |
| 25 |
| 26 <dom-module id="iron-page-url-demo"> |
| 27 <template> |
| 28 <style> |
| 29 div.inputs { |
| 30 margin-bottom: 15px; |
| 31 } |
| 32 label { |
| 33 display: inline-block; |
| 34 width: 100px; |
| 35 } |
| 36 |
| 37 h3 { |
| 38 padding: 0; |
| 39 margin: 0; |
| 40 } |
| 41 |
| 42 .inputs, .history_entries { |
| 43 @apply(--layout-vertical); |
| 44 @apply(--layout-flex); |
| 45 padding: 20px; |
| 46 max-width: 500px; |
| 47 } |
| 48 |
| 49 .container { |
| 50 @apply(--layout-horizontal); |
| 51 } |
| 52 </style> |
| 53 <iron-page-url path="{{path}}" hash="{{hash}}" query="{{query}}" |
| 54 dwell-time="{{dwellTime}}"> |
| 55 </iron-page-url> |
| 56 |
| 57 <div class="container"> |
| 58 <div class="inputs"> |
| 59 <h3>URL</h3> |
| 60 <paper-input label="path" value="{{path}}" always-float-label> |
| 61 </paper-input> |
| 62 <paper-input label="hash" value="{{hash}}" always-float-label> |
| 63 </paper-input> |
| 64 <paper-input label='query' value='{{query}}' always-float-label> |
| 65 </paper-input> |
| 66 </div> |
| 67 <div class="history_entries"> |
| 68 <h3>Dwell Time</h3> |
| 69 <p> |
| 70 iron-page-url won't add extraneous entries to the browser's history |
| 71 when changes come in quick successino. |
| 72 </p> |
| 73 <p> |
| 74 A new history entry will only be added if iron-query-url stays in |
| 75 the same state longer than dwellTime. |
| 76 </p> |
| 77 <div> |
| 78 <label>History added: </label> |
| 79 {{historyElementsAdded}} entries |
| 80 </div> |
| 81 <div> |
| 82 <label>Dwell time:</label> |
| 83 {{inSeconds(dwellTime)}}s |
| 84 </div> |
| 85 <paper-slider min="-1" max="5000" value="2000" step="100" |
| 86 immediate-value="{{dwellTime}}"> |
| 87 </paper-slider> |
| 88 </div> |
| 89 </div> |
| 90 </template> |
| 91 <script> |
| 92 Polymer({ |
| 93 is: 'iron-page-url-demo', |
| 94 properties: { |
| 95 historyElementsAdded: { |
| 96 type: Number |
| 97 } |
| 98 }, |
| 99 observers: [ |
| 100 'checkHistorySize(path, hash, query, startingHistoryLength)' |
| 101 ], |
| 102 ready: function() { |
| 103 this.startingHistoryLength = window.history.length; |
| 104 }, |
| 105 checkHistorySize: function() { |
| 106 this.historyElementsAdded = |
| 107 window.history.length - this.startingHistoryLength; |
| 108 }, |
| 109 inSeconds: function(dwellTime) { |
| 110 if (dwellTime === -1) { |
| 111 return -1; |
| 112 } |
| 113 return (Math.round(dwellTime / 100) / 10) |
| 114 } |
| 115 }); |
| 116 </script> |
| 117 </dom-module> |
| 118 |
| 119 <iron-page-url-demo></iron-page-url-demo> |
| 120 </body> |
| 121 </html> |
OLD | NEW |