From 78c7512200608cf0c4f24287b792b51e314a007e Mon Sep 17 00:00:00 2001 From: fnuesse Date: Sat, 15 Dec 2018 13:59:21 +0100 Subject: implemented icon upload in icon-picker Signed-off-by: fnuesse --- js/app/directives/iconpicker.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'js/app/directives/iconpicker.js') diff --git a/js/app/directives/iconpicker.js b/js/app/directives/iconpicker.js index 2fabf176..bf2e8c03 100644 --- a/js/app/directives/iconpicker.js +++ b/js/app/directives/iconpicker.js @@ -93,7 +93,32 @@ return false; }; - scope.useIcon = function() { + $('#iconPicker-CustomIcon').on('change', function(ev) { + + console.log("upload"); + scope.customIcon = {}; + + var f = ev.target.files[0]; + var fr = new FileReader(); + + fr.onload = function(ev2) { + scope.customIcon.data=ev2.target.result; + scope.$apply(); + }; + + fr.readAsDataURL(f); + }); + + scope.useIcon = function() { + + if(scope.customIcon){ + var data = scope.customIcon.data; + scope.credential.icon.type = data.substring(data.lastIndexOf(":")+1,data.lastIndexOf(";")); + scope.credential.icon.content = data.substring(data.lastIndexOf(",")+1, data.length); + $('#iconPicker').dialog('close'); + return; + } + $http.get(scope.selectedIcon.url).then(function(result) { var base64Data = window.btoa(result.data); var mimeType = 'svg+xml'; -- cgit v1.2.3