VRFS-3047 : Polish Save & Next buttons on profile editing screens.

This commit is contained in:
Steven Miers 2015-05-07 18:01:12 -05:00
parent d964cff2a3
commit 6d6307f9c9
5 changed files with 91 additions and 28 deletions

View File

@ -223,15 +223,10 @@
navToAccount();
return false;
});
$btnSubmit.click(function(evt) {
evt.stopPropagation();
handleUpdateProfile();
return false;
});
$('#account-profile-content-scroller').on('submit', '#account-edit-email-form', function(evt) { evt.stopPropagation(); handleUpdateProfile(); return false; } );
$('#account-profile-content-scroller').on('click', '#account-change-avatar', function(evt) { evt.stopPropagation(); navToAvatar(); return false; } );
enableSubmits();
}
function renderAccountProfile() {
@ -258,6 +253,7 @@
}
function handleUpdateProfile() {
disableSubmits();
resetForm();
var country = getCountryElement().val();
@ -283,6 +279,25 @@
})
.done(postUpdateProfileSuccess)
.fail(postUpdateProfileFailure)
.always(enableSubmits)
}
function enableSubmits() {
$btnSubmit.click(function(evt) {
evt.stopPropagation();
handleUpdateProfile();
return false;
});
$btnSubmit.removeClass("disabled");
$('#account-profile-content-scroller').on('submit', '#account-edit-email-form', function(evt) { evt.stopPropagation(); handleUpdateProfile(); return false; } );
$("#account-edit-email-form").removeClass("disabled");
}
function disableSubmits() {
$("#account-edit-email-form").addClass("disabled")
$("#account-edit-email-form").off("click")
$btnSubmit.addClass("disabled")
$btnSubmit.off("click")
}
function postUpdateProfileSuccess(response) {
@ -339,7 +354,7 @@
}
else {
app.ajaxError(xhr, textStatus, errorMessage)
}
}
}
function handleCountryChanged() {

View File

@ -59,11 +59,21 @@
// wire up main panel clicks
$('#account-profile-avatar-content-scroller').on('click', '#account-edit-avatar-upload', function(evt) { evt.stopPropagation(); handleFilePick(); return false; } );
$('#account-profile-avatar-content-scroller').on('click', '#account-edit-avatar-delete', function(evt) { evt.stopPropagation(); handleDeleteAvatar(); return false; } );
$('#account-profile-avatar-content-scroller').on('click', '#account-edit-avatar-cancel', function(evt) { evt.stopPropagation(); navToEditProfile(); return false; } );
$('#account-profile-avatar-content-scroller').on('click', '#account-edit-avatar-submit', function(evt) { evt.stopPropagation(); handleUpdateAvatar(); return false; } );
$('#account-profile-avatar-content-scroller').on('click', '#account-edit-avatar-cancel', function(evt) { evt.stopPropagation(); navToEditProfile(); return false; } );
enableSubmits()
//$('#account-profile-avatar-content-scroller').on('change', 'input[type=filepicker-dragdrop]', function(evt) { evt.stopPropagation(); afterImageUpload(evt.originalEvent.fpfile); return false; } );
}
function enableSubmits() {
$('#account-profile-avatar-content-scroller').on('click', '#account-edit-avatar-submit', function(evt) { evt.stopPropagation(); handleUpdateAvatar(); return false; } );
$("#account-edit-avatar-submit").removeClass("disabled")
}
function disableSubmits() {
$("#account-edit-avatar-submit").addClass("disabled")
$("#account-edit-avatar-submit").off("click")
}
function handleDeleteAvatar() {
if(self.updatingAvatar) {
@ -277,7 +287,7 @@
}
function handleUpdateAvatar(event) {
disableSubmits()
if(self.updatingAvatar) {
// protect against concurrent update attempts
return;
@ -373,10 +383,11 @@
},
null,
true);
}
}
enableSubmits()
}
function updateAvatarSuccess(response) {
function updateAvatarSuccess(response) {
$.cookie('original_fpfile', null);
self.userDetail = response;

View File

@ -124,12 +124,23 @@
navigateTo('/client#/account/profile/');
return false;
});
$btnSubmit.click(function(evt) {
enableSubmits()
}
function enableSubmits() {
$btnSubmit.on("click", function(evt) {
evt.stopPropagation();
handleUpdateProfile();
return false;
});
$btnSubmit.removeClass("disabled")
}
function disableSubmits() {
$btnSubmit.addClass("disabled")
$btnSubmit.off("click")
}
function renderExperience() {
@ -148,6 +159,7 @@
}
function handleUpdateProfile() {
disableSubmits()
resetForm();
var instruments = getSelectedInstruments();
@ -161,7 +173,8 @@
studio_session_count: $screen.find('select[name=studio_session_count]').val()
})
.done(postUpdateProfileSuccess)
.fail(postUpdateProfileFailure);
.fail(postUpdateProfileFailure)
.always(enableSubmits)
}
function postUpdateProfileSuccess(response) {

View File

@ -189,15 +189,26 @@
return false;
});
$btnSubmit.click(function(evt) {
enableSubmits();
context.JK.dropdown($virtualBandCommitment);
context.JK.dropdown($traditionalBandCommitment);
context.JK.dropdown($cowritingPurpose);
}
function enableSubmits() {
$btnSubmit.on("click", function(evt) {
evt.stopPropagation();
handleUpdateProfile();
return false;
});
context.JK.dropdown($virtualBandCommitment);
context.JK.dropdown($traditionalBandCommitment);
context.JK.dropdown($cowritingPurpose);
$btnSubmit.removeClass("disabled")
}
function disableSubmits() {
$btnSubmit.addClass("disabled")
$btnSubmit.off("click")
}
function renderInterests() {
@ -212,6 +223,7 @@
}
function handleUpdateProfile() {
disableSubmits()
resetForm();
api.updateUser({
@ -237,7 +249,8 @@
cowriting_purpose: $cowritingPurpose.val()
})
.done(postUpdateProfileSuccess)
.fail(postUpdateProfileFailure);
.fail(postUpdateProfileFailure)
.always(enableSubmits);
}
function postUpdateProfileSuccess(response) {

View File

@ -201,12 +201,22 @@
return false;
});
$btnSubmit.click(function(evt) {
if (validate()) {
handleUpdateProfile();
}
enableSubmits();
}
function enableSubmits() {
$btnSubmit.on("click", function(evt) {
evt.stopPropagation();
handleUpdateProfile();
return false;
});
$btnSubmit.removeClass("disabled")
}
function disableSubmits() {
$btnSubmit.addClass("disabled")
$btnSubmit.off("click")
}
function validate() {
@ -259,7 +269,7 @@
}
function handleUpdateProfile() {
disableSubmits()
// extract online presences
var op = [];
var presenceTypes = profileUtils.ONLINE_PRESENCE_TYPES;
@ -284,7 +294,8 @@
performance_samples: ps
})
.done(postUpdateProfileSuccess)
.fail(postUpdateProfileFailure);
.fail(postUpdateProfileFailure)
.always(enableSubmits);
}
function postUpdateProfileSuccess(response) {