From cb363884c6fe3cffb3d4ea1b06675c4caeec5d98 Mon Sep 17 00:00:00 2001 From: Thomas Felber Date: Sun, 12 Jul 2015 11:17:20 -1000 Subject: introduced statusobject to app.js, file get reqeust parameter now gets handled within app.js and not in viewer.js anymore. fixed a bug where a placed signature would dissappear if the user scrolls too far away. updated some stylesheets. parent and child frame dont talk via postmessage anymore, instead functionality of the DOM is used. added porject report / documentation --- pdf-as-web/src/main/webapp/assets/js/dragNdrop.js | 54 +++++++++++++++-------- 1 file changed, 35 insertions(+), 19 deletions(-) (limited to 'pdf-as-web/src/main/webapp/assets/js/dragNdrop.js') 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 = "
"; + var popup_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(""); } -- cgit v1.2.3