|
|
|
@ -4,8 +4,7 @@
|
|
|
|
|
|
|
|
|
|
define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'], function(header, uploader, translator) {
|
|
|
|
|
var AccountEdit = {},
|
|
|
|
|
uploadedPicture = '',
|
|
|
|
|
selectedImageType = '';
|
|
|
|
|
uploadedPicture = '';
|
|
|
|
|
|
|
|
|
|
AccountEdit.init = function() {
|
|
|
|
|
uploadedPicture = ajaxify.data.uploadedpicture;
|
|
|
|
@ -81,9 +80,9 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
|
|
|
|
|
|
|
|
|
|
// boolean to signify whether an uploaded picture is present in the pictures list
|
|
|
|
|
var uploaded = pictures.reduce(function(memo, cur) {
|
|
|
|
|
return memo || cur.type === 'uploaded'
|
|
|
|
|
return memo || cur.type === 'uploaded';
|
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates.parse('partials/modals/change_picture_modal', {
|
|
|
|
|
pictures: pictures,
|
|
|
|
|
uploaded: uploaded,
|
|
|
|
@ -109,12 +108,15 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modal.on('shown.bs.modal', updateImages);
|
|
|
|
|
modal.on('click', '.list-group-item', selectImageType);
|
|
|
|
|
modal.on('click', '.list-group-item', function selectImageType() {
|
|
|
|
|
modal.find('.list-group-item').removeClass('active');
|
|
|
|
|
$(this).addClass('active');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
handleImageUpload(modal);
|
|
|
|
|
|
|
|
|
|
function updateImages() {
|
|
|
|
|
var currentPicture = $('#user-current-picture').attr('src'),
|
|
|
|
|
userIcon = modal.find('.user-icon');
|
|
|
|
|
var userIcon = modal.find('.user-icon');
|
|
|
|
|
|
|
|
|
|
userIcon
|
|
|
|
|
.css('background-color', ajaxify.data['icon:bgColor'])
|
|
|
|
@ -128,15 +130,10 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
|
|
|
|
|
if (this.getAttribute('src') === ajaxify.data.picture) {
|
|
|
|
|
$(this).parents('.list-group-item').addClass('active');
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function selectImageType() {
|
|
|
|
|
modal.find('.list-group-item').removeClass('active');
|
|
|
|
|
$(this).addClass('active');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function saveSelection() {
|
|
|
|
|
var type = modal.find('.list-group-item.active').attr('data-type'),
|
|
|
|
|
src = modal.find('.list-group-item.active img').attr('src');
|
|
|
|
@ -213,7 +210,15 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
|
|
|
|
|
|
|
|
|
|
modal.find('[data-action="upload"]').on('click', function() {
|
|
|
|
|
modal.modal('hide');
|
|
|
|
|
uploader.open(config.relative_path + '/api/user/' + ajaxify.data.userslug + '/uploadpicture', {}, ajaxify.data.maximumProfileImageSize, function(imageUrlOnServer) {
|
|
|
|
|
|
|
|
|
|
uploader.show({
|
|
|
|
|
route: config.relative_path + '/api/user/' + ajaxify.data.userslug + '/uploadpicture',
|
|
|
|
|
params: {},
|
|
|
|
|
fileSize: ajaxify.data.maximumProfileImageSize,
|
|
|
|
|
title: '[[user:upload_picture]]',
|
|
|
|
|
description: '[[user:upload_a_picture]]',
|
|
|
|
|
accept: '.png,.jpg,.bmp'
|
|
|
|
|
}, function(imageUrlOnServer) {
|
|
|
|
|
onUploadComplete(imageUrlOnServer);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|