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 <title>iron-ajax</title> |
| 15 |
| 16 <script src="../../webcomponentsjs/webcomponents-lite.js"></script> |
| 17 <link rel="import" href="../iron-ajax.html"> |
| 18 <link rel="import" href="../../iron-image/iron-image.html"> |
| 19 <link rel="import" href="../../paper-styles/demo-pages.html"> |
| 20 <style> |
| 21 iron-image { |
| 22 background-color: lightgray; |
| 23 margin: 1em; |
| 24 } |
| 25 .horizontal-section { |
| 26 max-width: 300px; |
| 27 margin-bottom: 24px; |
| 28 } |
| 29 </style> |
| 30 </head> |
| 31 <body unresolved> |
| 32 <h1>Video Feed</h1> |
| 33 <div class="horizontal-section-container"> |
| 34 <template is="dom-bind" id="app"> |
| 35 <iron-ajax auto |
| 36 url="https://www.googleapis.com/youtube/v3/search" |
| 37 params='{"part":"snippet", "q":"polymer", "key": "AIzaSyAuecFZ9xJXbGDk
QYWBmYrtzOGJD-iDIgI", "type": "video"}' |
| 38 handle-as="json" |
| 39 last-response="{{ajaxResponse}}"></iron-ajax> |
| 40 |
| 41 <template is="dom-repeat" items="[[ajaxResponse.items]]"> |
| 42 <div class="horizontal-section"> |
| 43 <h2><a href="[[url(item.id.videoId)]]" target="_blank">[[item.snippe
t.title]]</a></h2> |
| 44 <iron-image src="[[item.snippet.thumbnails.high.url]]" width="256" h
eight="256" sizing="cover" preload fade></iron-image> |
| 45 <p>[[item.snippet.description]]</p> |
| 46 </div> |
| 47 </template> |
| 48 |
| 49 </template> |
| 50 </div> |
| 51 |
| 52 <script> |
| 53 var app = document.querySelector('#app'); |
| 54 |
| 55 app.url = function (videoId) { |
| 56 return 'https://www.youtube.com/watch?v=' + videoId; |
| 57 }; |
| 58 </script> |
| 59 </body> |
| 60 </html> |
OLD | NEW |