Update user account removeFn

As I did not realise both groups and users call the same
coverPhoto lib, the removeFn has to be in the user client js,
and not in the coverPhoto lib.

... of course, it *could* be in there, but it would be hacky.
This commit is contained in:
Julian Lam
2015-11-06 10:37:42 -05:00
parent 04894b549a
commit 92be63ebe6
2 changed files with 16 additions and 15 deletions

View File

@@ -68,7 +68,8 @@ define('forum/account/header', [
uploader.open(RELATIVE_PATH + '/api/user/' + ajaxify.data.userslug + '/uploadcover', { uid: yourid }, 0, function(imageUrlOnServer) {
components.get('account/cover').css('background-image', 'url(' + imageUrlOnServer + ')');
});
}
},
removeCover
);
}
@@ -132,5 +133,17 @@ define('forum/account/header', [
});
}
function removeCover() {
socket.emit('user.removeCover', {
uid: ajaxify.data.uid
}, function(err) {
if (!err) {
ajaxify.refresh();
} else {
app.alertError(err.message);
}
});
}
return AccountHeader;
});

View File

@@ -10,7 +10,7 @@ define('coverPhoto', [
saveFn: null
};
coverPhoto.init = function(coverEl, saveFn, uploadFn) {
coverPhoto.init = function(coverEl, saveFn, uploadFn, removeFn) {
coverPhoto.coverEl = coverEl;
coverPhoto.saveFn = saveFn;
@@ -23,7 +23,7 @@ define('coverPhoto', [
units: 'percent'
});
});
coverEl.find('.remove').on('click', coverPhoto.remove);
coverEl.find('.remove').on('click', removeFn);
coverEl
.on('dragover', coverPhoto.onDragOver)
@@ -80,17 +80,5 @@ define('coverPhoto', [
});
};
coverPhoto.remove = function() {
socket.emit('user.removeCover', {
uid: ajaxify.data.uid
}, function(err) {
if (!err) {
ajaxify.refresh();
} else {
app.alertError(err.message);
}
});
};
return coverPhoto;
});