diff --git a/frontend/app/map/import/import.js b/frontend/app/map/import/import.js new file mode 100644 index 00000000..063dee2e --- /dev/null +++ b/frontend/app/map/import/import.js @@ -0,0 +1,47 @@ +(function(fp, $, ng, undefined) { + + fp.app.factory("fpMapImport", function($q) { + return function(map) { + var fileEl = $('').css("display", "none").appendTo("body"); + + fileEl.one("change", function() { + fpMapImport.importFiles(fileEl.prop("files")); + }); + + map.el.on("dragenter", false); + map.el.on("dragover", false); + map.el.on("drop", function(e) { + e.preventDefault(); + + fpMapImport.importFiles(e.originalEvent.dataTransfer.files); + }); + + var fpMapImport = { + openImportDialog: function() { + fileEl.click(); + }, + + importFiles: function(files) { + var readers = [ ]; + + for(var i=0; i 0) - scope.showResult(results[0]); - }); - } + fpMapSearch.search(); }; scope.showResult = function(result) { @@ -30,6 +20,30 @@ var el = $($templateCache.get("map/search/search.html")).insertAfter(map.map.getContainer()); $compile(el)(scope); scope.$evalAsync(); // $compile only replaces variables on next digest + + var fpMapSearch = { + search: function(query) { + if(query != null) + scope.searchString = query; + + scope.searchResults = null; + if(scope.searchString.trim() != "") { + map.loadStart(); + fpNameFinder.find(scope.searchString).then(function(results) { + map.loadEnd(); + scope.searchResults = results; + + if(results.length > 0) + scope.showResult(results[0]); + }); + } + }, + + showFiles: function(files) { + console.log("showFiles", files); + } + }; + return fpMapSearch; }; }); diff --git a/frontend/app/map/toolbox/toolbox.html b/frontend/app/map/toolbox/toolbox.html index 7228b816..01ed3ae7 100644 --- a/frontend/app/map/toolbox/toolbox.html +++ b/frontend/app/map/toolbox/toolbox.html @@ -38,6 +38,7 @@ Tools