fixed hardcoded group name in uploader + cleanup

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

@ -1,13 +1,14 @@
"use strict";
/* globals define, socket, ajaxify, app, bootbox, utils */
/* globals define, socket, ajaxify, app, bootbox, utils, RELATIVE_PATH */
define('forum/groups/details', [
'forum/groups/memberlist',
'iconSelect',
'components',
'coverPhoto',
'uploader',
'vendor/colorpicker/colorpicker'
], function(memberList, iconSelect, components, coverPhoto) {
], function(memberList, iconSelect, components, coverPhoto, uploader) {
var Details = {};
var groupName;
@ -24,14 +25,19 @@ define('forum/groups/details', [
function(callback) {
socket.emit('groups.cover.get', {
groupName: groupName
}, callback)
}, callback);
},
function(imageData, position, callback) {
socket.emit('groups.cover.update', {
groupName: groupName,
imageData: coverPhoto.newCover || undefined,
position: components.get('groups/cover').css('background-position')
imageData: imageData,
position: position
}, 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";
/* globals define, app, RELATIVE_PATH */
/* globals define, app */
define('coverPhoto', [
'uploader',
'vendor/jquery/draggable-background/backgroundDraggable'
], function(uploader) {
], function() {
var coverPhoto = {
coverEl: null,
@ -12,16 +11,12 @@ define('coverPhoto', [
saveFn: null
};
coverPhoto.init = function(coverEl, getFn, saveFn) {
coverPhoto.init = function(coverEl, getFn, saveFn, uploadFn) {
coverPhoto.coverEl = coverEl;
coverPhoto.getFn = getFn;
coverPhoto.saveFn = saveFn;
coverEl.find('.upload').on('click', function() {
uploader.open(RELATIVE_PATH + '/api/groups/uploadpicture', { groupName: 'administrators' }, 0, function(imageUrlOnServer) {
coverPhoto.coverEl.css('background-image', 'url(' + imageUrlOnServer + '?' + new Date().getTime() + ')');
});
});
coverEl.find('.upload').on('click', uploadFn);
coverEl.find('.resize').on('click', function() {
coverEl

Loading…
Cancel
Save