1 $(document).ready(function () {
2 // Preserve location hash in referer
3 if (window.location.hash) {
4 $("#referer").val($("#referer").val() + window.location.hash);
7 // Attach referer to authentication buttons
8 $(".auth_button").each(function () {
9 var params = qs.parse(this.search.substring(1));
10 params.referer = $("#referer").val();
11 this.search = qs.stringify(params);
14 // Add click handler to show OpenID field
15 $("#openid_open_url").click(function () {
16 $("#openid_url").val("http://");
17 $("#login_auth_buttons").hide();
18 $("#login_openid_url").show();
19 $("#login_openid_submit").show();
22 // Hide OpenID field for now
23 $("#login_openid_url").hide();
24 $("#login_openid_submit").hide();
26 // Handle OpenID submission by redirecting to omniauth
27 $("#openid_login_form").submit(function () {
28 var action = $(this).prop("action"),
29 openid_url = $(this).find("#openid_url").val(),
30 referer = $(this).find("#openid_referer").val(),
32 args.openid_url = openid_url;
34 args.referer = referer;
36 window.location = action + "?" + qs.stringify(args);