Commit e7165306 by Brian Talbot

edx.org - added necessary JS and Sass to disabled login/register button when form is submitting

parent dc1a7f5d
...@@ -392,6 +392,7 @@ ...@@ -392,6 +392,7 @@
&:disabled { &:disabled {
opacity: 0.3; opacity: 0.3;
cursor: default !important;
} }
} }
......
...@@ -26,16 +26,13 @@ ...@@ -26,16 +26,13 @@
}).blur(function() { }).blur(function() {
$("label").parent().removeClass("is-focused"); $("label").parent().removeClass("is-focused");
}); });
}); });
</script>
<script type="text/javascript">
(function() { (function() {
$(document).delegate('#login-form', 'ajax:success', function(data, json, xhr) { $(document).delegate('#login-form', 'ajax:success', function(data, json, xhr) {
if(json.success) { if(json.success) {
$('.message.submission-error').removeClass('is-shown'); $('.message.submission-error').removeClass('is-shown');
toggleSubmitButton();
var u=decodeURI(window.location.search); var u=decodeURI(window.location.search);
next=u.split("next=")[1]; next=u.split("next=")[1];
if (next) { if (next) {
...@@ -45,12 +42,25 @@ ...@@ -45,12 +42,25 @@
} }
} else { } else {
$('.message.submission-error').addClass('is-shown'); $('.message.submission-error').addClass('is-shown');
toggleSubmitButton();
$('.message.submission-error .message-copy').html(json.value); $('.message.submission-error .message-copy').html(json.value);
} }
}); });
})(this) })(this);
</script>
function toggleSubmitButton(e) {
var $msgError = $('form .status.submission-error');
var $submitButton = $('form .form-actions #submit');
if(!$msgError.hasClass('is-shown')) {
$submitButton.prop('disabled', true);
}
else {
$submitButton.prop('disabled', false);
}
}
</script>
</%block> </%block>
<section class="introduction"> <section class="introduction">
......
...@@ -33,6 +33,34 @@ ...@@ -33,6 +33,34 @@
}); });
}); });
(function() {
$(document).delegate('#register-form', 'ajax:success', function(data, json, xhr) {
if(json.success) {
$('.message.submission-error').removeClass('is-shown');
toggleSubmitButton();
location.href="${reverse('dashboard')}";
} else {
$('.status.message.submission-error').addClass('is-shown');
$('.status.message.submission-error .message-copy').html(json.value).stop().css("display", "block");
$(".field-error").removeClass('field-error');
$("[data-field='"+json.field+"']").addClass('field-error')
}
});
})(this);
function toggleSubmitButton(e) {
var $msgError = $('form .status.submission-error');
var $submitButton = $('form .form-actions #submit').prop('disabled', true);
if(!$msgError.hasClass('is-shown')) {
$submitButton.prop('disabled', true);
}
else {
$submitButton.prop('disabled', false);
}
}
</script> </script>
</%block> </%block>
...@@ -208,21 +236,4 @@ ...@@ -208,21 +236,4 @@
<p>Need help in registering with edX? <a href="#">View our FAQs for answers to commonly asked questions</a>. Once registered, most questions can be answered in the course specific discussion forums or through the FAQs.</p> <p>Need help in registering with edX? <a href="#">View our FAQs for answers to commonly asked questions</a>. Once registered, most questions can be answered in the course specific discussion forums or through the FAQs.</p>
</div> </div>
</aside> </aside>
</section> </section>
\ No newline at end of file
<script type="text/javascript">
(function() {
$(document).delegate('#register-form', 'ajax:success', function(data, json, xhr) {
if(json.success) {
location.href="${reverse('dashboard')}";
} else {
$('.status.message.submission-error').addClass('is-shown');
$('.status.message.submission-error .message-copy').html(json.value).stop().css("display", "block");
$(".field-error").removeClass('field-error');
$("[data-field='"+json.field+"']").addClass('field-error')
}
});
})(this)
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment