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 <!doctype html> |
| 12 <html> |
| 13 <head> |
| 14 |
| 15 <title>iron-list, paper-scroll-header-panel, filltext.com demo</title> |
| 16 |
| 17 <meta charset="utf-8"> |
| 18 <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-
scale=1, user-scalable=yes"> |
| 19 <meta name="mobile-web-app-capable" content="yes"> |
| 20 <meta name="apple-mobile-web-app-capable" content="yes"> |
| 21 |
| 22 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 23 |
| 24 <link rel="import" href="../../polymer/polymer.html"> |
| 25 |
| 26 <link rel="import" href="../../iron-flex-layout/iron-flex-layout.html"> |
| 27 <link rel="import" href="../../paper-toolbar/paper-toolbar.html"> |
| 28 <link rel="import" href="../../paper-scroll-header-panel/paper-scroll-header-p
anel.html"> |
| 29 <link rel="import" href="../../paper-spinner/paper-spinner.html"> |
| 30 |
| 31 <link rel="import" href="../../paper-icon-button/paper-icon-button.html"> |
| 32 <link rel="import" href="../../iron-ajax/iron-ajax.html"> |
| 33 <link rel="import" href="../../iron-icons/iron-icons.html"> |
| 34 |
| 35 <link rel="import" href="../iron-list.html"> |
| 36 |
| 37 <style is="custom-style"> |
| 38 :root { |
| 39 --dark-primary-color: #F57C00; |
| 40 } |
| 41 |
| 42 paper-scroll-header-panel { |
| 43 @apply(--layout-fit); |
| 44 @apply(--layout-vertical); |
| 45 @apply(--paper-font-common-base); |
| 46 } |
| 47 |
| 48 paper-toolbar { |
| 49 background-color: var(--dark-primary-color); |
| 50 } |
| 51 |
| 52 paper-toolbar.tall .title { |
| 53 font-size: 40px; |
| 54 margin-left: 60px; |
| 55 |
| 56 -webkit-transform-origin: left center; |
| 57 transform-origin: left center; |
| 58 overflow: visible; |
| 59 } |
| 60 |
| 61 .middle-container { |
| 62 height: 100%; |
| 63 /*margin-left: 60px;*/ |
| 64 } |
| 65 |
| 66 .bottom { |
| 67 padding-left: 62px; |
| 68 } |
| 69 |
| 70 iron-list { |
| 71 background-color: var(--paper-grey-200, #eee); |
| 72 padding-bottom: 16px; |
| 73 } |
| 74 |
| 75 .item { |
| 76 @apply(--layout-horizontal); |
| 77 |
| 78 margin: 16px 16px 0 16px; |
| 79 padding: 20px; |
| 80 |
| 81 border-radius: 8px; |
| 82 background-color: white; |
| 83 border: 1px solid #ddd; |
| 84 } |
| 85 |
| 86 .pad { |
| 87 padding: 0 16px; |
| 88 @apply(--layout-flex); |
| 89 @apply(--layout-vertical); |
| 90 } |
| 91 |
| 92 .primary { |
| 93 font-size: 16px; |
| 94 font-weight: bold; |
| 95 } |
| 96 |
| 97 .secondary { |
| 98 font-size: 14px; |
| 99 } |
| 100 |
| 101 .dim { |
| 102 color: gray; |
| 103 } |
| 104 |
| 105 /* Small */ |
| 106 @media (max-width: 600px) { |
| 107 paper-toolbar.tall .title { |
| 108 font-size: 20px; |
| 109 } |
| 110 } |
| 111 |
| 112 .index { |
| 113 width: 30px; |
| 114 } |
| 115 |
| 116 </style> |
| 117 |
| 118 </head> |
| 119 <body unresolved> |
| 120 |
| 121 <template is="dom-bind" id="app"> |
| 122 <iron-ajax id="get_filltext_ajax" auto |
| 123 url="//www.filltext.com/" |
| 124 params='{"rows": "1000", "fname":"{firstName}", "lname": "{lastName}", "ad
dress": "{streetAddress}", |
| 125 "city": "{city}", "state": "{usState|abb}", "zip": "{zip}", "integer": "{
number|100}", |
| 126 "business": "{business}", "index": "{index}"}' |
| 127 handle-as="json" |
| 128 loading="{{loading}}" |
| 129 last-response="{{people}}"> |
| 130 </iron-ajax> |
| 131 <paper-scroll-header-panel class="fit" condenses keep-condensed-header> |
| 132 <paper-toolbar class="tall"> |
| 133 <paper-icon-button icon="arrow-back"></paper-icon-button> |
| 134 <div class="flex"></div> |
| 135 <paper-icon-button icon="search"></paper-icon-button> |
| 136 <paper-icon-button icon="refresh" on-tap="refreshData"></paper-icon-butt
on> |
| 137 <paper-icon-button icon="more-vert"></paper-icon-button> |
| 138 |
| 139 <div class="middle middle-container center horizontal layout"> |
| 140 <div class="title">iron-list & filltext.com</div> |
| 141 </div> |
| 142 <div class="bottom bottom-container center horizontal layout"> |
| 143 <div class="bottom-title"> |
| 144 <span class="length">Rows: <span>{{people.length}}</span></span> |
| 145 <paper-spinner active="{{loading}}"></paper-spinner> |
| 146 </div> |
| 147 </div> |
| 148 </paper-toolbar> |
| 149 <iron-list items="[[people]]" as="item"> |
| 150 <template> |
| 151 <div> |
| 152 <div class="item"> |
| 153 <div class="primary dim">[[item.index]]</div> |
| 154 <div class="pad"> |
| 155 <div class="primary"><span>[[item.fname]]</span> <span>[[item.ln
ame]]</span></div> |
| 156 <div class="secondary"><span>[[item.address]]</span> <span>[[ite
m.city]]</span></div> |
| 157 <div class="secondary"><span>[[item.city]]</span>, <span>[[item.
state]]</span> <span>[[item.zip]]</span></div> |
| 158 <div class="secondary dim">[[item.business]]</div> |
| 159 </div> |
| 160 <iron-icon icon$="[[iconForItem(item)]]"></iron-icon> |
| 161 </div> |
| 162 </div> |
| 163 </template> |
| 164 </iron-list> |
| 165 </paper-scroll-header-panel> |
| 166 </template> |
| 167 |
| 168 <script> |
| 169 |
| 170 var app = document.querySelector('#app'); |
| 171 |
| 172 document.querySelector('template[is=dom-bind]').iconForItem = function(item)
{ |
| 173 return item ? (item.integer < 50 ? 'star-border' : 'star') : ''; |
| 174 }; |
| 175 |
| 176 // Custom transformation: scale header's title |
| 177 addEventListener('paper-header-transform', function(e) { |
| 178 var title = document.querySelector('.title'); |
| 179 var middleContainer = document.querySelector('.middle-container'); |
| 180 var bottomContainer = document.querySelector('.bottom-container'); |
| 181 var detail = e.detail; |
| 182 var heightDiff = detail.height - detail.condensedHeight; |
| 183 var yRatio = Math.min(1, detail.y / heightDiff); |
| 184 var maxMiddleScale = 0.50; // title max size when condensed. The smaller
the number the smaller the condensed size. |
| 185 var scaleMiddle = Math.max(maxMiddleScale, (heightDiff - detail.y) / (heig
htDiff / (1-maxMiddleScale)) + maxMiddleScale); |
| 186 var scaleBottom = 1 - yRatio; |
| 187 |
| 188 // Move/translate middleContainer |
| 189 Polymer.Base.transform('translate3d(0,' + yRatio * 100 + '%,0)', middleCon
tainer); |
| 190 |
| 191 // Scale bottomContainer and bottom title to 0 and back |
| 192 Polymer.Base.transform('scale(' + scaleBottom + ') translateZ(0)', bottomC
ontainer); |
| 193 |
| 194 // Scale middle Title |
| 195 Polymer.Base.transform('scale(' + scaleMiddle + ') translateZ(0)', title); |
| 196 }); |
| 197 |
| 198 // Refresh Data |
| 199 app.refreshData = function() { |
| 200 this.$.get_filltext_ajax.generateRequest(); |
| 201 }; |
| 202 |
| 203 </script> |
| 204 </body> |
| 205 </html> |
OLD | NEW |