From: Stas Vilchik Date: Fri, 24 Jun 2016 09:43:52 +0000 (+0200) Subject: SONAR-7761 improve submitting of login form X-Git-Tag: 6.0-RC1~238 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=cd8f9c0a390181fb1bf25a6e9e3bab509dd7ebc7;p=sonarqube.git SONAR-7761 improve submitting of login form --- diff --git a/server/sonar-web/src/main/js/libs/application.js b/server/sonar-web/src/main/js/libs/application.js index 43a1492ca2d..95e2b9685d5 100644 --- a/server/sonar-web/src/main/js/libs/application.js +++ b/server/sonar-web/src/main/js/libs/application.js @@ -187,7 +187,7 @@ function openModalWindow (url, options) { return this.each(function () { var obj = jQuery(this); obj.submit(function () { - jQuery('input[type=submit]', this).attr('disabled', 'disabled'); + jQuery('input[type=submit], button', this).attr('disabled', 'disabled'); jQuery.ajax(jQuery.extend({ type: 'POST', url: obj.attr('action'), @@ -202,7 +202,7 @@ function openModalWindow (url, options) { // Hide all loading images jQuery('.loading-image').addClass('hidden'); // Re activate submit button - jQuery('input[type=submit]', obj).removeAttr('disabled'); + jQuery('input[type=submit], button', obj).removeAttr('disabled'); errorElt.show(); errorElt.html(jQuery('
').html(xhr.responseText).text()); } else { diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/sessions/_form.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/sessions/_form.html.erb index 26a6e7378dc..4495fffa997 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/sessions/_form.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/sessions/_form.html.erb @@ -56,14 +56,18 @@ if (!returnToAnchor.val()) { returnToAnchor.val(window.location.hash); } - })(window.jQuery); - $j("#login_form").modalForm({ - success: function () { - window.location = '<%= ApplicationController.root_context + h(@return_to) -%>' + $j('[name="return_to_anchor"]').val(); - }, - error: function () { - jQuery('.alert').removeClass('hidden'); - } - }); + $("#login_form").modalForm({ + success: function () { + window.location = '<%= h(@return_to) -%>' + $('[name="return_to_anchor"]').val(); + }, + error: function () { + $('.alert').removeClass('hidden'); + $('button').prop('disabled', false); + }, + statusCode: { + 401: null + } + }); + })(window.jQuery);