diff options
Diffstat (limited to 'pdf-as-web/src/main/webapp/assets/js/dragNdrop.js')
-rw-r--r-- | pdf-as-web/src/main/webapp/assets/js/dragNdrop.js | 54 |
1 files changed, 35 insertions, 19 deletions
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 b66073e6..940804bd 100644 --- a/pdf-as-web/src/main/webapp/assets/js/dragNdrop.js +++ b/pdf-as-web/src/main/webapp/assets/js/dragNdrop.js @@ -9,11 +9,6 @@ function registerEventListeners() { var locale = "EN"; var connector = "mobilebku"; - window.addEventListener("message", function receiveMessage(evt) { - var iframewindow = document.getElementById("iFrame"); - iframewindow.contentWindow.postMessage(file, "*"); - }, false); - $(document).bind("dragover", function(evt) { evt.preventDefault(); }); @@ -49,12 +44,10 @@ function registerEventListeners() { evt.preventDefault(); evt.stopPropagation(); unhighlightDropzone(); - var files = evt.originalEvent.dataTransfer.files; if(files == null || files.length === 0) { return; } - file = files[0]; previewFile(); }); @@ -65,7 +58,6 @@ function registerEventListeners() { if(files == null || files.length === 0) { return; } - file = files[0]; previewFile(file); }); @@ -83,31 +75,34 @@ function registerEventListeners() { }); } +// +//Creates an PDF.js instance within the PDF preview section and displays +//the user selected PDF document. +// function previewFile() { clearContentDiv(); createIframe(); } +// +//Calls the sign servlet with the provided file and the provided connector and locale +// function sign(file, connector, locale) { if(file == null) { alert("No file selected"); return } - var fd = new FormData(); fd.append("source", "internal"); fd.append("pdf-file", file); fd.append("connector", connector); fd.append("locale", locale); - signature_overlay = $("#iFrame").contents().find(".cl_signature"); - if(signature_overlay.length > 0) { - var sig_pos_x = $("#iFrame").contents().find(".cl_signature").attr("data-pos-x"); - var sig_pos_y = $("#iFrame").contents().find(".cl_signature").attr("data-pos-y"); - var sig_pos_p = $("#iFrame").contents().find(".cl_signature").attr("data-page"); - fd.append("sig-pos-x", sig_pos_x); - fd.append("sig-pos-y", sig_pos_y); - fd.append("sig-pos-p", sig_pos_p); + ifr = document.getElementById('iFrame').contentWindow; + if(ifr.isSignaturePlaced()) { //Signature has been manually placed + fd.append("sig-pos-x", ifr.global_status.getSignature().posx); + fd.append("sig-pos-y", ifr.global_status.getSignature().posy); + fd.append("sig-pos-p", ifr.global_status.getSignature().page); } $.ajax({ @@ -117,24 +112,45 @@ function sign(file, connector, locale) { contentType: false, type: "POST", success: function(response) { - $("html").empty(); - $("html").html(response); + $("#fade").remove(); + $("#popup").remove(); + var fade_div = "<div id='fade' class='black_overlay'></div>"; + var popup_div = "<div id='popup' class='white_content'><a href='javascript:void(0)' id='closelink'>Close</a><div id='resp'></div></div>" + $("body").append(fade_div); + $("body").append(popup_div); + $("#resp").html(response); + $("#closelink").bind("click", function(evt) { + $("#fade").remove(); + $("#popup").remove(); + }); } }); } +// +//Changes color if the user drags a file over the dropzone +// function highlightDropzone() { $("#dropzone").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"); } +// +//Removes all content that is inside of the PDF Preview section +// function clearContentDiv() { $("#content").empty(); } +// +//Inserts an Iframe with a PDF.js instance into the PDF Preview section +// function createIframe() { $("#content").append("<iframe src='assets/js/pdf.js/web/viewer.html' height='863px' width='800px' id='iFrame'></iframe>"); } |