v1.18.x
barisusakli 9 years ago
parent 6516b70f9a
commit 9eb64aa3fa

@ -216,11 +216,7 @@ $(document).ready(function() {
return url; return url;
}; };
ajaxify.refresh = function(e, callback) { ajaxify.refresh = function(callback) {
if (e && e instanceof jQuery.Event) {
e.preventDefault();
}
ajaxify.go(ajaxify.currentPage + window.location.search + window.location.hash, callback, true); ajaxify.go(ajaxify.currentPage + window.location.search + window.location.hash, callback, true);
}; };

@ -2,12 +2,10 @@
/* globals define, ajaxify, socket, app, config, templates, bootbox */ /* globals define, ajaxify, socket, app, config, templates, bootbox */
define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'], function(header, uploader, translator) { define('forum/account/edit', ['forum/account/header', 'uploader', 'translator', 'components'], function(header, uploader, translator, components) {
var AccountEdit = {}, var AccountEdit = {};
uploadedPicture = '';
AccountEdit.init = function() { AccountEdit.init = function() {
uploadedPicture = ajaxify.data.uploadedpicture;
header.init(); header.init();
@ -59,17 +57,15 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
} }
function updateHeader(picture) { function updateHeader(picture) {
require(['components'], function(components) { if (parseInt(ajaxify.data.theirid, 10) !== parseInt(ajaxify.data.yourid, 10)) {
if (parseInt(ajaxify.data.theirid, 10) !== parseInt(ajaxify.data.yourid, 10)) { return;
return; }
}
components.get('header/userpicture')[picture ? 'show' : 'hide'](); components.get('header/userpicture')[picture ? 'show' : 'hide']();
components.get('header/usericon')[!picture ? 'show' : 'hide'](); components.get('header/usericon')[!picture ? 'show' : 'hide']();
if (picture) { if (picture) {
components.get('header/userpicture').attr('src', picture); components.get('header/userpicture').attr('src', picture);
} }
});
} }
function handleImageChange() { function handleImageChange() {
@ -137,8 +133,8 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
} }
function saveSelection() { function saveSelection() {
var type = modal.find('.list-group-item.active').attr('data-type'), var type = modal.find('.list-group-item.active').attr('data-type');
src = modal.find('.list-group-item.active img').attr('src');
changeUserPicture(type, function(err) { changeUserPicture(type, function(err) {
if (err) { if (err) {
return app.alertError(err.message); return app.alertError(err.message);
@ -176,7 +172,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
if (err) { if (err) {
return app.alertError(err.message); return app.alertError(err.message);
} }
window.location.href = config.relative_path + '/'; window.location.href = config.relative_path + '/';
}); });
} }
@ -192,15 +188,17 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
function handleImageUpload(modal) { function handleImageUpload(modal) {
function onUploadComplete(urlOnServer) { function onUploadComplete(urlOnServer) {
urlOnServer = urlOnServer + '?' + new Date().getTime(); urlOnServer = urlOnServer + '?' + Date.now();
updateHeader(urlOnServer); updateHeader(urlOnServer);
if (ajaxify.data.picture.length) { if (ajaxify.data.picture.length) {
$('#user-current-picture, img.avatar').attr('src', urlOnServer); $('#user-current-picture, img.avatar').attr('src', urlOnServer);
uploadedPicture = urlOnServer; ajaxify.data.uploadedpicture = urlOnServer;
} else { } else {
ajaxify.refresh(); ajaxify.refresh(function() {
$('#user-current-picture, img.avatar').attr('src', urlOnServer);
});
} }
} }

Loading…
Cancel
Save