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

This commit is contained in:
Brian Talbot
2013-03-25 14:52:13 -04:00
parent dc1a7f5d6a
commit e716530692
3 changed files with 46 additions and 24 deletions

View File

@@ -392,6 +392,7 @@
&:disabled {
opacity: 0.3;
cursor: default !important;
}
}

View File

@@ -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">

View File

@@ -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>