From 1e4a0af51ff6b90cca57791b698433d36febb2a5 Mon Sep 17 00:00:00 2001 From: fschneider Date: Thu, 6 Aug 2015 11:58:40 +0200 Subject: Moved dropzone and file browser --- pdf-as-web/src/main/webapp/assets/css/style.css | 9 ++++++ pdf-as-web/src/main/webapp/assets/js/dragNdrop.js | 39 ++++++++++++++++++----- pdf-as-web/src/main/webapp/index.jsp | 23 +++++++------ 3 files changed, 54 insertions(+), 17 deletions(-) diff --git a/pdf-as-web/src/main/webapp/assets/css/style.css b/pdf-as-web/src/main/webapp/assets/css/style.css index 56bfbe67..8ef67ebf 100644 --- a/pdf-as-web/src/main/webapp/assets/css/style.css +++ b/pdf-as-web/src/main/webapp/assets/css/style.css @@ -41,6 +41,15 @@ iframe { margin: 0px; } +#borderBox { + height: 815px; + width: 750px; + float: center; + margin: 20px; + border: 2px dashed; + border-color: black; +} + #content { clear: both; height: 863px; diff --git a/pdf-as-web/src/main/webapp/assets/js/dragNdrop.js b/pdf-as-web/src/main/webapp/assets/js/dragNdrop.js index d7f8cfb9..c3f340d6 100644 --- a/pdf-as-web/src/main/webapp/assets/js/dragNdrop.js +++ b/pdf-as-web/src/main/webapp/assets/js/dragNdrop.js @@ -17,32 +17,32 @@ function registerEventListeners() { evt.preventDefault(); }); - $("#dropzone").bind("dragenter", function(evt) { + $("#borderBox").bind("dragenter", function(evt) { evt.preventDefault(); evt.stopPropagation(); highlightDropzone(); }); - $("#dropzone").bind("dragover", function(evt) { + $("#borderBox").bind("dragover", function(evt) { evt.preventDefault(); evt.stopPropagation(); - highlightDropzone(); // test + highlightDropzone(); }); - $("#dropzone").bind("dragleave", function(evt) { + $("#borderBox").bind("dragleave", function(evt) { evt.preventDefault(); evt.stopPropagation(); unhighlightDropzone(); }); - $("#dropzone").bind("dragend", function(evt) { + $("#borderBox").bind("dragend", function(evt) { evt.preventDefault(); evt.stopPropagation(); unhighlightDropzone(); }); - $("#dropzone").bind("drop", function(evt) { + $("#borderBox").bind("drop", function(evt) { evt.preventDefault(); evt.stopPropagation(); unhighlightDropzone(); @@ -50,10 +50,33 @@ function registerEventListeners() { if(files == null || files.length === 0) { return; } + else if(files[0].name.indexOf(".pdf") < 0) + { + window.alert("The file type must be PDF"); + return; + } + file = files[0]; previewFile(); }); +/* $("#main").bind("drop", function(evt) { + evt.preventDefault(); + evt.stopPropagation(); + var files = evt.originalEvent.dataTransfer.files; + if(files == null || files.length === 0) { + return; + } + else if(files[0].name.indexOf(".pdf") < 0) + { + window.alert("The file type must be PDF"); + return; + } + + file = files[0]; + previewFile(); + }); */ + $("#pdf-file").bind("change", function(evt) { file_event = evt; var files = evt.target.files; @@ -139,14 +162,14 @@ function sign(file, connector, locale) { //Changes color if the user drags a file over the dropzone // function highlightDropzone() { - $("#dropzone").css("background", "#D8FFD8"); + $("#borderBox").css("background", "#D8FFD8"); } // //Changes color back to original, if the user stops dragging a file over the dropzone (or drops the file) // function unhighlightDropzone() { - $("#dropzone").css("background", "#E8F4FF"); + $("#borderBox").css("background", "#E8F4FF"); } // diff --git a/pdf-as-web/src/main/webapp/index.jsp b/pdf-as-web/src/main/webapp/index.jsp index 58102ebf..abc2ece1 100644 --- a/pdf-as-web/src/main/webapp/index.jsp +++ b/pdf-as-web/src/main/webapp/index.jsp @@ -18,13 +18,14 @@