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