fixed cover image editing on all profile pages

v1.18.x
psychobunny 10 years ago
parent f4bfcc7351
commit ce4df8f22b

@ -1,12 +1,25 @@
'use strict';
/* globals define, app, ajaxify */
/* globals define, app, ajaxify, socket, RELATIVE_PATH */
define('forum/account/header', function() {
var AccountHeader = {};
define('forum/account/header', [
'coverPhoto',
'uploader',
'components'
], function(coverPhoto, uploader, components) {
var AccountHeader = {},
yourid,
theirid;
AccountHeader.init = function() {
yourid = ajaxify.data.yourid;
theirid = ajaxify.data.theirid;
hidePrivateLinks();
selectActivePill();
if (parseInt(yourid, 10) === parseInt(theirid, 10)) {
setupCoverPhoto();
}
};
function hidePrivateLinks() {
@ -26,5 +39,22 @@ define('forum/account/header', function() {
});
}
function setupCoverPhoto() {
coverPhoto.init(components.get('account/cover'),
function(imageData, position, callback) {
socket.emit('user.updateCover', {
uid: yourid,
imageData: imageData,
position: position
}, callback);
},
function() {
uploader.open(RELATIVE_PATH + '/api/user/uploadcover', { uid: yourid }, 0, function(imageUrlOnServer) {
components.get('account/cover').css('background-image', 'url(' + imageUrlOnServer + ')');
});
}
);
}
return AccountHeader;
});

@ -1,15 +1,13 @@
'use strict';
/* globals define, ajaxify, app, utils, socket, bootbox */
/* globals define, ajaxify, app, socket, bootbox */
define('forum/account/profile', [
'forum/account/header',
'forum/infinitescroll',
'translator',
'coverPhoto',
'uploader',
'components'
], function(header, infinitescroll, translator, coverPhoto, uploader, components) {
], function(header, infinitescroll, translator) {
var Account = {},
yourid,
theirid,
@ -48,10 +46,6 @@ define('forum/account/profile', [
socket.on('event:user_status_change', onUserStatusChange);
infinitescroll.init(loadMorePosts);
if (parseInt(yourid, 10) === parseInt(theirid, 10)) {
setupCoverPhoto();
}
};
function processPage() {
@ -172,22 +166,5 @@ define('forum/account/profile', [
});
}
function setupCoverPhoto() {
coverPhoto.init(components.get('account/cover'),
function(imageData, position, callback) {
socket.emit('user.updateCover', {
uid: yourid,
imageData: imageData,
position: position
}, callback);
},
function() {
uploader.open(RELATIVE_PATH + '/api/user/uploadcover', { uid: yourid }, 0, function(imageUrlOnServer) {
components.get('account/cover').css('background-image', 'url(' + imageUrlOnServer + ')');
});
}
);
}
return Account;
});

Loading…
Cancel
Save