| OLD | NEW |
| (Empty) | |
| 1 <!-- |
| 2 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 3 This code may only be used under the BSD style license found at https://polymer.
github.io/LICENSE.txt |
| 4 The complete set of authors may be found at https://polymer.github.io/AUTHORS.tx
t |
| 5 The complete set of contributors may be found at https://polymer.github.io/CONTR
IBUTORS.txt |
| 6 Code distributed by Google as part of the polymer project is also |
| 7 subject to an additional IP rights grant found at https://polymer.github.io/PATE
NTS.txt |
| 8 --> |
| 9 |
| 10 <link rel="import" href="../polymer/polymer.html"> |
| 11 <link rel="import" href="../iron-jsonp-library/iron-jsonp-library.html"> |
| 12 |
| 13 <script> |
| 14 /** |
| 15 Dynamically loads Google JavaScript API `gapi`, firing the `js-api-load` event w
hen ready. |
| 16 |
| 17 Any number of components can use `<google-js-api>` elements, and the library wil
l only be loaded once. |
| 18 |
| 19 ##### Example |
| 20 |
| 21 <google-js-api></google-js-api> |
| 22 <script> |
| 23 var api = document.querySelector('google-js-api'); |
| 24 api.addEventListener('js-api-load', function(e) { |
| 25 console.log('API loaded', gapi); |
| 26 }); |
| 27 < /script> |
| 28 |
| 29 */ |
| 30 Polymer({ |
| 31 |
| 32 is: 'google-js-api', |
| 33 |
| 34 behaviors: [ |
| 35 Polymer.IronJsonpLibraryBehavior |
| 36 ], |
| 37 |
| 38 properties: { |
| 39 |
| 40 /** @private */ |
| 41 libraryUrl: { |
| 42 type: String, |
| 43 value: 'https://apis.google.com/js/api.js?onload=%%callback%%' |
| 44 }, |
| 45 |
| 46 /** |
| 47 * Fired when the API library is loaded and available. |
| 48 * @event js-api-load |
| 49 */ |
| 50 /** |
| 51 * Name of event fired when library is loaded and available. |
| 52 */ |
| 53 notifyEvent: { |
| 54 type: String, |
| 55 value: 'js-api-load' |
| 56 }, |
| 57 }, |
| 58 |
| 59 get api() { |
| 60 return gapi; |
| 61 } |
| 62 |
| 63 }); |
| 64 </script> |
| OLD | NEW |