Fix scripts load order to prevent reference error, using query callback to prevent google api call before loaded
This commit is contained in:
parent
0470a266fd
commit
c22791610c
1 changed files with 14 additions and 6 deletions
|
@ -1242,6 +1242,8 @@ if (DROPBOX_APP_KEY) {
|
||||||
.attr('src', 'https://www.dropbox.com/static/api/2/dropins.js')
|
.attr('src', 'https://www.dropbox.com/static/api/2/dropins.js')
|
||||||
.attr('id', 'dropboxjs')
|
.attr('id', 'dropboxjs')
|
||||||
.attr('data-app-key', DROPBOX_APP_KEY)
|
.attr('data-app-key', DROPBOX_APP_KEY)
|
||||||
|
.prop('async', true)
|
||||||
|
.prop('defer', true)
|
||||||
.appendTo('body');
|
.appendTo('body');
|
||||||
} else {
|
} else {
|
||||||
ui.toolbar.import.dropbox.hide();
|
ui.toolbar.import.dropbox.hide();
|
||||||
|
@ -1252,18 +1254,24 @@ if (DROPBOX_APP_KEY) {
|
||||||
if (GOOGLE_API_KEY && GOOGLE_CLIENT_ID) {
|
if (GOOGLE_API_KEY && GOOGLE_CLIENT_ID) {
|
||||||
$('<script>')
|
$('<script>')
|
||||||
.attr('type', 'text/javascript')
|
.attr('type', 'text/javascript')
|
||||||
.attr('src', 'https://www.google.com/jsapi')
|
.attr('src', 'https://www.google.com/jsapi?callback=onGoogleAPILoaded')
|
||||||
.appendTo('body');
|
.prop('async', true)
|
||||||
|
.prop('defer', true)
|
||||||
$('<script>')
|
|
||||||
.attr('type', 'text/javascript')
|
|
||||||
.attr('src', 'https://apis.google.com/js/client:plusone.js?onload=onGoogleClientLoaded')
|
|
||||||
.appendTo('body');
|
.appendTo('body');
|
||||||
} else {
|
} else {
|
||||||
ui.toolbar.import.googleDrive.hide();
|
ui.toolbar.import.googleDrive.hide();
|
||||||
ui.toolbar.export.googleDrive.hide();
|
ui.toolbar.export.googleDrive.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onGoogleAPILoaded() {
|
||||||
|
$('<script>')
|
||||||
|
.attr('type', 'text/javascript')
|
||||||
|
.attr('src', 'https://apis.google.com/js/client:plusone.js?onload=onGoogleClientLoaded')
|
||||||
|
.prop('async', true)
|
||||||
|
.prop('defer', true)
|
||||||
|
.appendTo('body');
|
||||||
|
}
|
||||||
|
|
||||||
//button actions
|
//button actions
|
||||||
//share
|
//share
|
||||||
ui.toolbar.publish.attr("href", noteurl + "/publish");
|
ui.toolbar.publish.attr("href", noteurl + "/publish");
|
||||||
|
|
Loading…
Reference in a new issue