From 14bda0e08c2168f4a9df143d8896c92bfdb9b47c Mon Sep 17 00:00:00 2001 From: fschneider Date: Wed, 19 Aug 2015 13:20:29 +0200 Subject: Responsive Design for most C --- pdf-as-web/src/main/webapp/assets/js/dragNdrop.js | 58 +++++++++++---- .../src/main/webapp/assets/js/pdf.js/web/app.js | 87 +++++++++++++++++++--- .../main/webapp/assets/js/pdf.js/web/viewer.html | 5 +- .../src/main/webapp/assets/js/pdf.js/web/viewer.js | 24 +++--- 4 files changed, 137 insertions(+), 37 deletions(-) (limited to 'pdf-as-web/src/main/webapp/assets/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 f7310fe8..f581efc9 100644 --- a/pdf-as-web/src/main/webapp/assets/js/dragNdrop.js +++ b/pdf-as-web/src/main/webapp/assets/js/dragNdrop.js @@ -112,9 +112,13 @@ function registerEventListeners() { }); - $("#placeSignatureExtern").bind("click", function(evt) { + $("#QuickSign").bind("click", function(evt) { - $("#iFrame").contents().find("#placeSignature").click(); + console.log("quick sign..") + $("#iFrame").contents().find("#delSignature").click(); + $("#SignStepButton").click(); + // If you are going back from Finish to Place there should be a Signature again! + // Maybe even where you left it before!! }); $("#delSignatureExtern").bind("click", function(evt) { @@ -168,33 +172,34 @@ function registerEventListeners() { case "upload": $("#DropContainer").show(); $("#UploadStepButton").addClass("active"); - $("#PlaceStepButton").prop("style", "pointer-events:none;"); - $("#SignStepButton").prop("style", "pointer-events:none;"); - $("#FinishStepButton").prop("style", "pointer-events:none;"); + $("#PlaceStepButton").css("pointer-events", "none"); + $("#SignStepButton").css("pointer-events", "none"); + $("#FinishStepButton").css("pointer-events", "none"); $("#uploadNavText").show(); break; case "place": $("#ViewContainer").show(); $("#PlaceStepButton").addClass("active"); - $("#PlaceStepButton").prop("style", ""); - $("#SignStepButton").prop("style", "pointer-events:none;"); - $("#FinishStepButton").prop("style", "pointer-events:none;"); + $("#PlaceStepButton").css("pointer-events", "auto"); + $("#SignStepButton").css("pointer-events", "none"); + $("#FinishStepButton").css("pointer-events", "none"); $("#placeNavText").show(); break; case "sign": $("#SignContainer").show(); $("#SignStepButton").addClass("active"); - $("#SignStepButton").prop("style", ""); - $("#FinishStepButton").prop("style", "pointer-events:none;"); + $("#SignStepButton").css("pointer-events", "auto"); + $("#PlaceStepButton").css("pointer-events", "auto"); + $("#FinishStepButton").css("pointer-events", "none"); $("#signNavText").show(); break; case "finish": $("#DownloadContainer").show(); $("#FinishStepButton").addClass("active"); - $("#SignStepButton").prop("style", ""); + $("#SignStepButton").css("pointer-events", "auto"); $("#downloadNavText").show(); break; } @@ -216,6 +221,7 @@ function registerEventListeners() { }); + function checkPDF(to_check) { // Read the local file into a Uint8Array. @@ -271,6 +277,8 @@ function registerEventListeners() { $("#noPdfMessage").show(); + $("#FormDefine").css("margin-bottom", "2.2em"); + $("#uploadContinue").prop("disabled", true); } @@ -291,6 +299,8 @@ function registerEventListeners() { $("#noPdfMessage").hide(); + $("#FormDefine").css("margin-bottom", ""); + $("#uploadContinue").prop("disabled", false); previewFile(file); @@ -308,6 +318,25 @@ function registerEventListeners() { $("#btnSign").bind("click", function(evt) { sign(file, connector, locale); }); + + $("#MobilePhoneSubmit").bind("click", function(evt) { + + $("#mobileBKU").click(); + sign(file, connector, locale); + + }); + + $("#LocalBKUSubmit").bind("click", function(evt) { + + $("#localBKU").click(); + sign(file, connector, locale); + }); + + $("#KeystoreSubmit").bind("click", function(evt) { + + $("#jks").click(); + sign(file, connector, locale); + }); } // @@ -350,8 +379,11 @@ function sign(file, connector, locale) { withCredentials: true }, success: function(response) { - $("html").empty(); - $("html").html(response); + console.log("hello there, response is: " + response); + $("#DownloadResultButton").attr("onclick", "window.open('" + response + "')"); + $("#FinishStepButton").click(); + //$("html").empty(); + //$("html").html(response); /* $("#fade").remove(); $("#popup").remove(); diff --git a/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/app.js b/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/app.js index d44dab43..be33e35d 100644 --- a/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/app.js +++ b/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/app.js @@ -140,7 +140,7 @@ function registerSignaturePlacementEventHandlers() { //if a user scrolls too far away from the page where the signature has //been placed. To address this issue the following function is used. //Every time a page is rendered, it is checked whether it is true that - //a signautre has been placed manually but is currently not in the DOM Tree. + //a signature has been placed manually but is currently not in the DOM Tree. //In that case we have to check whether the page we placed the signature on //is in the DOM tree. If thats true, we can restore the signature on that page. // @@ -241,9 +241,11 @@ function placeSignature(evt, page_to_place, s) { posy: (s === defaultSignature) ? "0" : global_status.getSignature().posy, sig: $(".cl_signature") }); - updateSignaturePosition(global_status.getSignature()); + updateSignaturePosition(global_status.getSignature(), null, null, false); makeSignatureDraggable(global_status.getSignature()); + $("#pageFitOption").click(); + $("#scaleSelect").change(); //console.log("left: " + $("#img_signature").css("left") + " top: " + $("#img_signature").css("top")); @@ -256,10 +258,26 @@ function placeSignature(evt, page_to_place, s) { function makeSignatureDraggable(signature) { signature.sig.draggable({ drag: function() { - updateSignaturePosition(signature) + console.log("drag"); + updateSignaturePosition(signature, null, null, false) }, containment: "parent" }); + + $("#img_signature").on("touchmove", function(e) { + console.log("signature touchmove... x: " + e.originalEvent.touches[0].pageX + " y: " +e.originalEvent.touches[0].pageY); + updateSignaturePosition(signature, e.originalEvent.touches[0].pageX, e.originalEvent.touches[0].pageY, true); + + }); + + $(window).on("touchmove", function(e) { + console.log("preventing default!"); + e.preventDefault(); + }); + + $("#img_signature").on("contextmenu", function(e) { + e.preventDefault(); + }); } // @@ -267,15 +285,53 @@ function makeSignatureDraggable(signature) { //The position is is saved in the html attributes 'data-pos-x' and 'data-pos-y' of the //signature element. // -function updateSignaturePosition(signature) { +function updateSignaturePosition(signature, xpos, ypos, mobile) { var page = signature.page; var canvas_height = $("#page" + page.toString()).attr("height"); var current_scale = PDFViewerApplication.pdfViewer.currentScale; var thisPos = $(signature.sig).position(); - var x = thisPos.left; - var y = thisPos.top; - signature.posx = (Math.floor(x / current_scale / (4.0/3.0))).toString(); - signature.posy = Math.floor((parseInt(canvas_height) - (thisPos.top)) / current_scale / (4.0/3.0)).toString(); + var x; + var y; + + var mobile_x_offset = -parseInt($("#img_signature").css("width")) / 1.5; + var mobile_y_offset = -parseInt($("#img_signature").css("height")); + + //console.log("canvas-height: " + parseInt(canvas_height)); + if(mobile) + { + + x = xpos; + y = ypos;// (parseInt(canvas_height) - ypos); + //console.log("changing x: " + x + " y: "+ y); + } + else + { + x = thisPos.left; + y = thisPos.top; + } + + if(mobile) + { + signature.posx = (x + mobile_x_offset).toString(); + signature.posy = (y + mobile_y_offset).toString(); + } + else + { + signature.posx = Math.floor(x / current_scale / (4.0/3.0)).toString(); + signature.posy = Math.floor((parseInt(canvas_height) - (y)) / current_scale / (4.0/3.0)).toString(); + } + + + + + + if(mobile) + { + $("#img_signature").css("left", signature.posx + "px"); + $("#img_signature").css("top", signature.posy + "px"); + } + + console.log("signature. posx: " + signature.posx + " posy: " + signature.posy); //console.log("last x: last y: " + $("#img_signature").css("left") + " " + $("#img_signature").css("top")); @@ -439,8 +495,11 @@ function quickSign(connector, pdfurl) { }, type: "POST", success: function(response) { - $("html").empty(); - $("html").html(response); + console.log("hello there, response is: " + response); + $("#DownloadResultButton").prop("href", response); + $("#FinishStepButton").click(); + //$("html").empty(); + //$("html").html(response); } }); } @@ -494,8 +553,12 @@ function sign(statusObj) { withCredentials: true }, success: function(response) { - $("html").empty(); - $("html").html(response); + console.log("hello there, response is: " + response); + $("#DownloadResultButton").prop("href", response); + $("#FinishStepButton").click(); + + //$("html").empty(); + //$("html").html(response); /* $("#fade").remove(); $("#popup").remove(); diff --git a/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.html b/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.html index ec9fce96..e44b78c5 100644 --- a/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.html +++ b/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.html @@ -220,7 +220,7 @@ http://sourceforge.net/adobe/cmap/wiki/License/ -
+