Skip to content

Node.js based forum software built for the modern web

user profile changing logic

Julian Lamc2da45c2f099
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js
index d1d7ecb4be..90532490d1 100644
--- a/public/src/ajaxify.js
+++ b/public/src/ajaxify.js
@@ -182,12 +182,12 @@ $(document).ready(function() {
return url;
};
- ajaxify.refresh = function(e) {
+ ajaxify.refresh = function(e, callback) {
if (e && e instanceof jQuery.Event) {
e.preventDefault();
}
- ajaxify.go(ajaxify.currentPage, null, true);
+ ajaxify.go(ajaxify.currentPage, callback, true);
};
ajaxify.loadScript = function(tpl_url, callback) {
diff --git a/public/src/client/account/edit.js b/public/src/client/account/edit.js
index 59b8a311ab..6b4159d9d9 100644
--- a/public/src/client/account/edit.js
+++ b/public/src/client/account/edit.js
@@ -73,20 +73,25 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
$('#confirm-email').removeClass('hide');
}
- updateHeader(data.picture, userData.username, data.userslug);
+ updateHeader(userData.username, data.userslug);
});
return false;
}
- function updateHeader(picture, username, userslug) {
+ function updateHeader(username, userslug) {
require(['components'], function(components) {
if (parseInt(ajaxify.data.theirid, 10) !== parseInt(ajaxify.data.yourid, 10)) {
return;
}
- if (picture) {
- components.get('header/userpicture').attr('src', picture);
+ // Update the picture
+ if (ajaxify.data.picture !== null) {
+ components.get('header/usericon').hide();
+ components.get('header/userpicture').prop('src', ajaxify.data.picture).show();
+ } else {
+ components.get('header/userpicture').hide();
+ components.get('header/usericon').show();
}
if (username && userslug) {
@@ -132,14 +137,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
return app.alertError(err.message);
}
- if (selectedImageType === 'default') {
- console.log('update pictures here');
- // $('#user-current-picture').attr('src', defaultPicture);
- // updateHeader(defaultPicture);
- } else if (selectedImageType === 'uploaded') {
- $('#user-current-picture').attr('src', uploadedPicture);
- updateHeader(uploadedPicture);
- }
+ ajaxify.refresh(null, updateHeader);
});
});
}
@@ -178,7 +176,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
$('#user-current-picture').attr('src', urlOnServer);
$('#user-uploaded-picture').attr('src', urlOnServer);
- updateHeader(urlOnServer);
+ updateHeader();
uploadedPicture = urlOnServer;
$('#removeUploadedPictureBtn').removeClass('hide');
}
@@ -186,7 +184,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
function onRemoveComplete(urlOnServer) {
$('#user-current-picture').attr('src', urlOnServer);
$('#user-uploaded-picture').attr('src', '');
- updateHeader(urlOnServer);
+ updateHeader();
uploadedPicture = '';
$('#removeUploadedPictureBtn').addClass('hide');
}