Skip to content

Commit 11756f3

Browse files
committed
Merge pull request #28 from GoogleWebComponents/fix15
Add API docs
2 parents 29c669f + 5f7d162 commit 11756f3

File tree

7 files changed

+98
-12
lines changed

7 files changed

+98
-12
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "google-apis",
3-
"version": "0.3.4",
3+
"version": "0.3.5",
44
"homepage": "http://googlewebcomponents.github.io/google-apis",
55
"description": "Web components to load Google API libraries",
66
"main": "google-apis.html",

google-client-api.html

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,45 @@
1515
1616
Any number of components can use `<google-client-api>` elements, and the library will only be loaded once.
1717
18+
##### Example
19+
20+
<google-client-api></google-client-api>
21+
<script>
22+
var client = document.querySelector('google-client-api');
23+
client.addEventListener('api-load', function(e) {
24+
// this.api === gapi.client
25+
// this.auth === gapi.auth
26+
});
27+
</script>
28+
1829
@element google-client-api
1930
@extends core-shared-lib
31+
@homepage https://googlewebcomponents.github.io/google-apis
2032
-->
2133
<polymer-element name="google-client-api" extends="core-shared-lib">
2234
<script>
2335
Polymer({
2436
defaultUrl: 'https://apis.google.com/js/client.js?onload=%%callback%%',
37+
38+
/**
39+
* Fired when the API library is loaded and available.
40+
* @event api-load
41+
*/
2542
notifyEvent: 'api-load',
43+
44+
/**
45+
* Wrapper for `gapi.client`.
46+
* @property api
47+
* @type gapi.client
48+
*/
2649
get api() {
2750
return gapi.client;
2851
},
52+
/**
53+
* Wrapper for `gapi.auth`.
54+
* @property auth
55+
* @type gapi.auth
56+
*/
2957
get auth() {
3058
return gapi.auth;
3159
}
@@ -38,21 +66,24 @@
3866
3967
##### Example
4068
41-
<google-api-loader id="shortener" name="urlshortener" version="v1">
42-
</google-api-loader>
69+
<google-api-loader id="shortener" name="urlshortener"
70+
version="v1"></google-api-loader>
4371
4472
<script>
4573
var shortener = document.getElementById('shortener');
4674
shortener.addEventListener('google-api-load', function(event) {
47-
var request = shortener.api.url.get({'shortUrl': 'http://goo.gl/fbsS'});
48-
request.execute(function(resp) { console.log(resp); });
75+
var request = shortener.api.url.get({
76+
shortUrl: 'http://goo.gl/fbsS'
77+
});
78+
request.execute(function(resp) {
79+
console.log(resp);
80+
});
4981
});
5082
</script>
5183
5284
@element google-api-loader
53-
@status alpha
5485
@extends google-client-api
55-
@homepage http://polymerlabs.github.io/google-apis
86+
@homepage https://googlewebcomponents.github.io/google-apis
5687
-->
5788
<polymer-element name="google-api-loader"
5889
attributes="name version appId root"
@@ -73,12 +104,14 @@
73104

74105
Polymer('google-api-loader', {
75106
/**
76-
* Fired when the requested API is loaded.
107+
* Fired when the requested API is loaded. Override this name
108+
* by setting `successEventName`.
77109
* @event google-api-load
78110
*/
79111

80112
/**
81-
* Fired if an error occurs while loading the requested API.
113+
* Fired if an error occurs while loading the requested API. Override this name
114+
* by setting `errorEventName`.
82115
* @event google-api-load-error
83116
*/
84117

@@ -123,12 +156,26 @@
123156
// core-shared-lib.
124157
waiting: false,
125158

159+
/**
160+
* Used to override the event that is fired when the API lib is successfully loaded.
161+
* @property successEventName
162+
* @type string
163+
* @default 'google-api-load'
164+
*/
126165
successEventName: 'google-api-load',
166+
167+
/**
168+
* Used to override the event that is fired when there is an error loading the API.
169+
* @property errorEventName
170+
* @type string
171+
* @default 'google-api-load-error'
172+
*/
127173
errorEventName: 'google-api-load-error',
128174

129175
/**
130176
* Returns the loaded API.
131-
* @method api
177+
* @property api
178+
* @type gapi.client
132179
*/
133180
get api() {
134181
if (window.gapi && window.gapi.client &&

google-jsapi.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,24 @@
1717
Any number of components can use `<google-jsapi>` elements, and the library will only be loaded once.
1818
1919
@element google-jsapi
20+
@extends core-shared-lib
21+
@homepage https://googlewebcomponents.github.io/google-apis
2022
-->
2123
<polymer-element name="google-jsapi" extends="core-shared-lib">
2224
<script>
2325
Polymer({
2426
defaultUrl: 'https://www.google.com/jsapi?callback=%%callback%%',
27+
28+
/**
29+
* Fired when the API library is loaded and available.
30+
* @event api-load
31+
*/
2532
notifyEvent: 'api-load',
33+
34+
/**
35+
* Wrapper for `google` API namespace.
36+
* @property api
37+
*/
2638
get api() {
2739
return google;
2840
}

google-maps-api.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
2828
@element google-maps-api
2929
@blurb Element wrapper around Google Maps API.
30-
@homepage github.io
30+
@homepage https://googlewebcomponents.github.io/google-apis
3131
@extends core-shared-lib
3232
-->
3333
<!--

google-plusone-api.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,23 @@
1717
1818
@element google-plusone-api
1919
@extends core-shared-lib
20+
@homepage https://googlewebcomponents.github.io/google-apis
2021
-->
2122
<polymer-element name="google-plusone-api" extends="core-shared-lib">
2223
<script>
2324
Polymer({
2425
defaultUrl: 'https://apis.google.com/js/plusone.js?onload=%%callback%%',
26+
/**
27+
* Fired when the API library is loaded and available.
28+
* @event api-load
29+
*/
2530
notifyEvent: 'api-load',
31+
32+
/**
33+
* Wrapper for `gapi`.
34+
* @property api
35+
* @type gapi
36+
*/
2637
get api() {
2738
return gapi;
2839
}

google-youtube-api.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,26 @@
1616
Any number of components can use `<google-youtube-api>` elements, and the library will only be loaded once.
1717
1818
@element google-youtube-api
19+
@extends core-shared-lib
20+
@homepage https://googlewebcomponents.github.io/google-apis
1921
-->
2022
<polymer-element name="google-youtube-api" extends="core-shared-lib">
2123
<script>
2224
Polymer({
2325
defaultUrl: 'https://www.youtube.com/iframe_api',
26+
/**
27+
* Fired when the API library is loaded and available.
28+
* @event api-load
29+
*/
2430
notifyEvent: 'api-load',
31+
2532
callbackName: 'onYouTubeIframeAPIReady',
33+
34+
/**
35+
* Wrapper for `YT` API object.
36+
* @property api
37+
* @type YT
38+
*/
2639
get api() {
2740
return YT;
2841
}

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
</head>
1010
<body unresolved>
1111

12-
<core-component-page></core-component-page>
12+
<core-component-page
13+
moduleName="google-apis"
14+
sources='["google-client-api.html", "google-jsapi.html", "google-maps-api.html", "google-plusone-api.html", "google-youtube-api.html"]'>
15+
</core-component-page>
1316

1417
</body>
1518
</html>

0 commit comments

Comments
 (0)