edx.org - added necessary JS and Sass to disabled login/register button when form is submitting
This commit is contained in:
@@ -392,6 +392,7 @@
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.3;
|
||||
cursor: default !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,16 +26,13 @@
|
||||
}).blur(function() {
|
||||
$("label").parent().removeClass("is-focused");
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
$(document).delegate('#login-form', 'ajax:success', function(data, json, xhr) {
|
||||
if(json.success) {
|
||||
$('.message.submission-error').removeClass('is-shown');
|
||||
toggleSubmitButton();
|
||||
var u=decodeURI(window.location.search);
|
||||
next=u.split("next=")[1];
|
||||
if (next) {
|
||||
@@ -45,12 +42,25 @@
|
||||
}
|
||||
} else {
|
||||
$('.message.submission-error').addClass('is-shown');
|
||||
toggleSubmitButton();
|
||||
$('.message.submission-error .message-copy').html(json.value);
|
||||
}
|
||||
});
|
||||
})(this)
|
||||
</script>
|
||||
})(this);
|
||||
|
||||
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>
|
||||
|
||||
<section class="introduction">
|
||||
|
||||
@@ -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>
|
||||
</%block>
|
||||
|
||||
@@ -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>
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
</section>
|
||||
Reference in New Issue
Block a user