Commit 3fd8b6ff by Greg Price

Merge pull request #1960 from edx/feature/gprice/drupal-reset-buttons

parents 7aa9a6cf d6194508
...@@ -29,12 +29,19 @@ ...@@ -29,12 +29,19 @@
}); });
(function() { (function() {
$(document).delegate('#login-form', 'ajax:success', function(data, json, xhr) { toggleSubmitButton(true);
$(this).find('.form-actions #submit').addClass('is-disabled');
$('#login-form').on('submit', function() {
toggleSubmitButton(false);
});
$('#login-form').on('ajax:complete', function() {
toggleSubmitButton(true);
});
$('#login-form').on('ajax:success', function(event, 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) {
...@@ -44,23 +51,25 @@ ...@@ -44,23 +51,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);
function toggleSubmitButton(e) { function toggleSubmitButton(enable) {
var $msgError = $('form .status.submission-error');
var $submitButton = $('form .form-actions #submit'); var $submitButton = $('form .form-actions #submit');
var $submitButtonCopy = $submitButton.html();
if(!$msgError.hasClass('is-shown')) { if(enable) {
$submitButton.prop('disabled', true).html('Processing your account information …'); $submitButton.
removeClass('is-disabled').
removeProp('disabled').
html('Log into My edX Account <span class="orn-plus">+</span> Access My Courses');
} }
else { else {
$submitButton.prop('disabled', false).html($submitButtonCopy); $submitButton.
addClass('is-disabled').
prop('disabled', true).
html('Processing your account information &hellip;');
} }
} }
</script> </script>
...@@ -132,7 +141,7 @@ ...@@ -132,7 +141,7 @@
% endif % endif
<div class="form-actions"> <div class="form-actions">
<button name="submit" type="submit" id="submit" class="action action-primary action-update">Log into My edX Account <span class="orn-plus">+</span> Access My Courses</button> <button name="submit" type="submit" id="submit" class="action action-primary action-update"></button>
</div> </div>
</form> </form>
</section> </section>
......
...@@ -35,13 +35,20 @@ ...@@ -35,13 +35,20 @@
}); });
(function() { (function() {
$(document).delegate('#register-form', 'ajax:success', function(data, json, xhr) { toggleSubmitButton(true);
$(this).find('.form-actions #submit').addClass('is-disabled');
if(json.success) { $('#register-form').on('submit', function() {
$('.message.submission-error').removeClass('is-shown'); toggleSubmitButton(false);
toggleSubmitButton(); });
location.href="${reverse('dashboard')}";
$('#register-form').on('ajax:complete', function() {
toggleSubmitButton(true);
});
$('#register-form').on('ajax:success', function(event, json, xhr) {
if(json.success) {
$('.message.submission-error').removeClass('is-shown');
location.href="${reverse('dashboard')}";
} else { } else {
$('.status.message.submission-error').addClass('is-shown'); $('.status.message.submission-error').addClass('is-shown');
$('.status.message.submission-error .message-copy').html(json.value).stop().css("display", "block"); $('.status.message.submission-error .message-copy').html(json.value).stop().css("display", "block");
...@@ -51,17 +58,20 @@ ...@@ -51,17 +58,20 @@
}); });
})(this); })(this);
function toggleSubmitButton(e) { function toggleSubmitButton(enable) {
var $msgError = $('form .status.submission-error'); var $submitButton = $('form .form-actions #submit');
var $submitButton = $('form .form-actions #submit').prop('disabled', true);
var $submitButtonCopy = $submitButton.html();
if(!$msgError.hasClass('is-shown')) { if(enable) {
$submitButton.prop('disabled', true).html('Processing your registration &hellip;'); $submitButton.
removeClass('is-disabled').
removeProp('disabled').
html('Log into My edX Account <span class="orn-plus">+</span> Access My Courses');
} }
else { else {
$submitButton.prop('disabled', false).html($submitButtonCopy); $submitButton.
addClass('is-disabled').
prop('disabled', true).
html('Processing your account information &hellip;');
} }
} }
</script> </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