From a6796479bfe8c9aa7cdbe4659549d3e429a8842a Mon Sep 17 00:00:00 2001 From: psychobunny Date: Wed, 28 Oct 2015 15:46:48 -0400 Subject: [PATCH] fixed drag and drop image upload --- public/src/modules/coverPhoto.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/public/src/modules/coverPhoto.js b/public/src/modules/coverPhoto.js index d5ca6c0142..2c8f2db96b 100644 --- a/public/src/modules/coverPhoto.js +++ b/public/src/modules/coverPhoto.js @@ -17,22 +17,25 @@ define('coverPhoto', [ coverPhoto.getFn = getFn; coverPhoto.saveFn = saveFn; - coverEl.find('.change').on('click', function() { + coverEl.find('.upload').on('click', function() { uploader.open(RELATIVE_PATH + '/api/groups/uploadpicture', { groupName: 'administrators' }, 0, function(imageUrlOnServer) { - console.log(imageUrlOnServer); coverPhoto.coverEl.css('background-image', 'url(' + imageUrlOnServer + '?' + new Date().getTime() + ')'); }); + }); - return; - coverEl.toggleClass('active', 1); - coverEl.backgroundDraggable({ - axis: 'y', - units: 'percent' - }); - coverEl.on('dragover', coverPhoto.onDragOver); - coverEl.on('drop', coverPhoto.onDrop); + coverEl.find('.resize').on('click', function() { + coverEl + .toggleClass('active', 1) + .backgroundDraggable({ + axis: 'y', + units: 'percent' + }) }); + coverEl + .on('dragover', coverPhoto.onDragOver) + .on('drop', coverPhoto.onDrop); + coverEl.find('.save').on('click', coverPhoto.save); coverEl.addClass('initialised'); }; @@ -75,6 +78,13 @@ define('coverPhoto', [ }; reader.readAsDataURL(files[0]); + + coverPhoto.coverEl + .addClass('active', 1) + .backgroundDraggable({ + axis: 'y', + units: 'percent' + }) } };