From 718b771eb3f6a763bcd38865557d0cae6872a804 Mon Sep 17 00:00:00 2001 From: Evan Theurer Date: Tue, 2 Sep 2014 16:11:51 +0200 Subject: [PATCH 1/2] Implement a complete reset for buddyPictureUpload on cancel and save. --- static/js/directives/buddypictureupload.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/static/js/directives/buddypictureupload.js b/static/js/directives/buddypictureupload.js index ff2b6571..1c672bba 100644 --- a/static/js/directives/buddypictureupload.js +++ b/static/js/directives/buddypictureupload.js @@ -118,6 +118,13 @@ define(['jquery', 'underscore', 'text!partials/buddypictureupload.html', 'bootst //console.log('writeUploadToCanvas', dim); }; + var clearPicture = function() { + $(".file-input-name").get(0).innerHTML = ""; + $scope.imgData = null; + $scope.prevImage.src = ""; + $scope.prevImage.style.cssText = null; + }; + $scope.usePicture = function() { writeUploadToCanvas($scope.canvasPic, $scope.prevImage); $scope.user.buddyPicture = $scope.canvasPic.toDataURL("image/jpeg"); @@ -128,6 +135,7 @@ define(['jquery', 'underscore', 'text!partials/buddypictureupload.html', 'bootst $scope.reset = function() { $scope.showUploadPicture = false; $scope.previewUpload = false; + clearPicture(); }; $scope.handleUpload = function(event) { From b25a78650b12d3bd9c980d42d8fcb3911143d9d3 Mon Sep 17 00:00:00 2001 From: Evan Theurer Date: Thu, 4 Sep 2014 15:58:45 +0200 Subject: [PATCH 2/2] Rework clearing of file text. --- static/js/directives/buddypictureupload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/directives/buddypictureupload.js b/static/js/directives/buddypictureupload.js index 1c672bba..f9294fe5 100644 --- a/static/js/directives/buddypictureupload.js +++ b/static/js/directives/buddypictureupload.js @@ -119,7 +119,7 @@ define(['jquery', 'underscore', 'text!partials/buddypictureupload.html', 'bootst }; var clearPicture = function() { - $(".file-input-name").get(0).innerHTML = ""; + $(".file-input-name").empty(); $scope.imgData = null; $scope.prevImage.src = ""; $scope.prevImage.style.cssText = null;