Lazy load Google and Persona login stuff
This commit is contained in:
@ -1,5 +1,13 @@
|
||||
[% IF c.user_exists %]
|
||||
|
||||
[% IF c.user.type == 'google' %]
|
||||
<script src="https://apis.google.com/js/platform.js" async="1" defer="1"></script>
|
||||
[% END %]
|
||||
|
||||
[% IF c.user.type == 'persona' %]
|
||||
<script src="https://login.persona.org/include.js"></script>
|
||||
[% END %]
|
||||
|
||||
<script>
|
||||
function finishSignOut() {
|
||||
$.post("[% c.uri_for('/logout') %]")
|
||||
@ -65,6 +73,15 @@
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#sign-in-menu").on("click", function() {
|
||||
[% IF c.config.enable_google_login %]
|
||||
$.getScript("https://apis.google.com/js/platform.js");
|
||||
[% END %]
|
||||
[% IF c.config.enable_persona %]
|
||||
$.getScript("https://login.persona.org/include.js");
|
||||
[% END %]
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
[% IF c.config.enable_google_login %]
|
||||
@ -79,30 +96,33 @@
|
||||
}
|
||||
});
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
$("#google-signin").click(function() {
|
||||
$(".g-signin2:first-child > div").click();
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
||||
[% IF c.config.enable_persona %]
|
||||
<script>
|
||||
$("#persona-signin").click(function() {
|
||||
|
||||
navigator.id.watch({
|
||||
onlogin: function(assertion) {
|
||||
requestJSON({
|
||||
url: "[% c.uri_for('/persona-login') %]",
|
||||
data: "assertion=" + assertion,
|
||||
type: 'POST',
|
||||
success: function(data) { window.location.reload(); },
|
||||
postError: function() { navigator.id.logout(); }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
navigator.id.request({ siteName: 'Hydra' });
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
||||
[% END %]
|
||||
|
||||
[% IF c.config.enable_persona %]
|
||||
<script src="https://login.persona.org/include.js"></script>
|
||||
|
||||
<script>
|
||||
navigator.id.watch({
|
||||
onlogin: function(assertion) {
|
||||
requestJSON({
|
||||
url: "[% c.uri_for('/persona-login') %]",
|
||||
data: "assertion=" + assertion,
|
||||
type: 'POST',
|
||||
success: function(data) { window.location.reload(); },
|
||||
postError: function() { navigator.id.logout(); }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#persona-signin").click(function() {
|
||||
navigator.id.request({ siteName: 'Hydra' });
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
Reference in New Issue
Block a user