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