From 27b65d53ac66e67692edcc4ec591c2da92ad4d66 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 30 Oct 2015 11:00:32 +0000 Subject: [PATCH] Keep anchor (i.e. to a specific issue note) throughout login (#21110). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Patch by Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@14767 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/views/account/login.html.erb | 2 +- public/javascripts/application.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index 41018c871..f1b96bae3 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -1,6 +1,6 @@ <%= call_hook :view_account_login_top %>
-<%= form_tag(signin_path) do %> +<%= form_tag(signin_path, onsubmit: 'return keepAnchorOnSignIn(this);') do %> <%= back_url_hidden_field_tag %> diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 32261e07c..610cb60e7 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -651,6 +651,17 @@ $(document).ready(function(){ toggleDisabledInit(); }); +function keepAnchorOnSignIn(form){ + var hash = decodeURIComponent(self.document.location.hash); + if (hash) { + if (hash.indexOf("#") === -1) { + hash = "#" + hash; + } + form.action = form.action + hash; + } + return true; +} + $(document).ready(setupAjaxIndicator); $(document).ready(hideOnLoad); $(document).ready(addFormObserversForDoubleSubmit); -- 2.39.5