X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/9dd5dabf869e76cc00698e12b284400e570098c0..bf9dd8f350ca1b54afb79dda79506d980ccb5738:/app/assets/javascripts/login.js diff --git a/app/assets/javascripts/login.js b/app/assets/javascripts/login.js index 755c3bf65..74b226bf6 100644 --- a/app/assets/javascripts/login.js +++ b/app/assets/javascripts/login.js @@ -1,11 +1,22 @@ -$(document).ready(function() { +//= querystring + +$(document).ready(function () { + var querystring = require("querystring-component"); + // Preserve location hash in referer if (window.location.hash) { $("#referer").val($("#referer").val() + window.location.hash); } + // Attach referer to authentication buttons + $(".auth_button").each(function () { + var params = querystring.parse(this.search.substring(1)); + params.referer = $("#referer").val(); + this.search = querystring.stringify(params); + }); + // Add click handler to show OpenID field - $("#openid_open_url").click(function() { + $("#openid_open_url").click(function () { $("#openid_url").val("http://"); $("#login_auth_buttons").hide(); $("#login_openid_url").show(); @@ -15,4 +26,18 @@ $(document).ready(function() { // Hide OpenID field for now $("#login_openid_url").hide(); $("#login_openid_submit").hide(); + + // Handle OpenID submission by redirecting to omniauth + $("#openid_login_form").submit(function () { + var action = $(this).prop("action"), + openid_url = $(this).find("#openid_url").val(), + referer = $(this).find("#openid_referer").val(), + args = {}; + args.openid_url = openid_url; + if (referer) { + args.referer = referer; + } + window.location = action + "?" + querystring.stringify(args); + return false; + }); });