fixed hardcoded group name in uploader + cleanup

v1.18.x
psychobunny 9 years ago
parent ef20141e8f
commit a4cae65732

@ -1,13 +1,14 @@
"use strict"; "use strict";
/* globals define, socket, ajaxify, app, bootbox, utils */ /* globals define, socket, ajaxify, app, bootbox, utils, RELATIVE_PATH */
define('forum/groups/details', [ define('forum/groups/details', [
'forum/groups/memberlist', 'forum/groups/memberlist',
'iconSelect', 'iconSelect',
'components', 'components',
'coverPhoto', 'coverPhoto',
'uploader',
'vendor/colorpicker/colorpicker' 'vendor/colorpicker/colorpicker'
], function(memberList, iconSelect, components, coverPhoto) { ], function(memberList, iconSelect, components, coverPhoto, uploader) {
var Details = {}; var Details = {};
var groupName; var groupName;
@ -24,14 +25,19 @@ define('forum/groups/details', [
function(callback) { function(callback) {
socket.emit('groups.cover.get', { socket.emit('groups.cover.get', {
groupName: groupName groupName: groupName
}, callback) }, callback);
}, },
function(imageData, position, callback) { function(imageData, position, callback) {
socket.emit('groups.cover.update', { socket.emit('groups.cover.update', {
groupName: groupName, groupName: groupName,
imageData: coverPhoto.newCover || undefined, imageData: imageData,
position: components.get('groups/cover').css('background-position') position: position
}, callback); }, callback);
},
function() {
uploader.open(RELATIVE_PATH + '/api/groups/uploadpicture', { groupName: groupName }, 0, function(imageUrlOnServer) {
components.get('groups/cover').css('background-image', 'url(' + imageUrlOnServer + ')');
});
} }
); );
} }

@ -1,10 +1,9 @@
"use strict"; "use strict";
/* globals define, app, RELATIVE_PATH */ /* globals define, app */
define('coverPhoto', [ define('coverPhoto', [
'uploader',
'vendor/jquery/draggable-background/backgroundDraggable' 'vendor/jquery/draggable-background/backgroundDraggable'
], function(uploader) { ], function() {
var coverPhoto = { var coverPhoto = {
coverEl: null, coverEl: null,
@ -12,16 +11,12 @@ define('coverPhoto', [
saveFn: null saveFn: null
}; };
coverPhoto.init = function(coverEl, getFn, saveFn) { coverPhoto.init = function(coverEl, getFn, saveFn, uploadFn) {
coverPhoto.coverEl = coverEl; coverPhoto.coverEl = coverEl;
coverPhoto.getFn = getFn; coverPhoto.getFn = getFn;
coverPhoto.saveFn = saveFn; coverPhoto.saveFn = saveFn;
coverEl.find('.upload').on('click', function() { coverEl.find('.upload').on('click', uploadFn);
uploader.open(RELATIVE_PATH + '/api/groups/uploadpicture', { groupName: 'administrators' }, 0, function(imageUrlOnServer) {
coverPhoto.coverEl.css('background-image', 'url(' + imageUrlOnServer + '?' + new Date().getTime() + ')');
});
});
coverEl.find('.resize').on('click', function() { coverEl.find('.resize').on('click', function() {
coverEl coverEl

Loading…
Cancel
Save