Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
change script ordering, fixes #26.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Sep 18, 2013
1 parent 460dcf4 commit 1997548
Showing 1 changed file with 48 additions and 45 deletions.
93 changes: 48 additions & 45 deletions polymer-google-jsapi/polymer-google-jsapi.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,55 @@
-->
<polymer-element name="polymer-google-jsapi">
<script>
Polymer('polymer-google-jsapi', {
created: function() {
switch (state) {
case '':
load();
state = 'pending';
case 'pending':
instances.push(this);
break;
case 'ready':
this.provide();
break;
}
},
provide: function() {
this.asyncMethod('notify');
},
notify: function() {
this.fire('polymer-google-jsapi-loaded');
},
get google() {
return api;
(function() {
var state = '', instances = [], f;
function load() {
f = document.createElement('iframe');
f.style.display = 'none';
document.body.appendChild(f);
var d = f.contentWindow ? f.contentWindow.document : (f.contentDocument.document ? f.contentDocument.document : f.contentDocument);
d.open();
d.write(loader);
d.close();
}
var api;
loaded = function(google) {
window.__polymer_google_jsapi = undefined;
window.google = api = google;
instances.forEach(function(i) {
i.notify();
});
}
});
var state = '', instances = [], f;
function load() {
f = document.createElement('iframe');
f.style.display = 'none';
document.body.appendChild(f);
var d = f.contentWindow ? f.contentWindow.document : (f.contentDocument.document ? f.contentDocument.document : f.contentDocument);
d.open();
d.write(loader);
d.close();
}
var api;
loaded = function(google) {
window.__polymer_google_jsapi = undefined;
window.google = api = google;
instances.forEach(function(i) {
i.notify();
var loader =
'<script type="text/javascript" src="https://www.google.com/jsapi"></scr' + 'ipt>' +
'<script>top.__polymer_google_jsapi(google);</scr' + 'ipt>'
;
window.__polymer_google_jsapi = loaded;

Polymer('polymer-google-jsapi', {
created: function() {
switch (state) {
case '':
load();
state = 'pending';
case 'pending':
instances.push(this);
break;
case 'ready':
this.provide();
break;
}
},
provide: function() {
this.asyncMethod('notify');
},
notify: function() {
this.fire('polymer-google-jsapi-loaded');
},
get google() {
return api;
}
});
}
var loader =
'<script type="text/javascript" src="https://www.google.com/jsapi"></scr' + 'ipt>' +
'<script>top.__polymer_google_jsapi(google);</scr' + 'ipt>'
;
window.__polymer_google_jsapi = loaded;
})();
</script>
</polymer-element>

0 comments on commit 1997548

Please sign in to comment.