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