From 399096e21435170201ab85e58a20bfcfa9d4912f Mon Sep 17 00:00:00 2001 From: fschneider Date: Thu, 13 Aug 2015 16:17:19 +0200 Subject: Improvements --- .../src/main/webapp/assets/js/pdf.js/web/app.js | 50 +++++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) (limited to 'pdf-as-web/src/main/webapp/assets/js/pdf.js/web/app.js') 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 af161a14..d44dab43 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 @@ -122,11 +122,6 @@ function displayPdf() { console.log("now finished"); } -/*$("#placeSignatureExtern").bind("click", function(evt) { - console.log("PLACE SIGNATURE EXTERN"); - $("#placeSignature").click(); - -}); */ // //Attaches event handlers to the signature placement icons @@ -194,10 +189,44 @@ function isSignaturePlaced() { //Places signature given by parameter s on the page provided by the page_to_place parameter or on the current page if no such //parameter is provided. If the parameter s is omitted a default signature is placed. // + +var last_left; +var last_top; + function placeSignature(evt, page_to_place, s) { + + //check if properties are already assigned + + // get properties (if assigned) from last placement + + var left_pos; + var top_pos; + + //console.log("last left: " + last_left + " last top: " + last_top); + + if(typeof last_left != 'undefined') + { + //console.log("not undefined"); + left_pos = last_left; + top_pos = last_top; + } + else // otherwise set default position + { + //console.log("first time set left and top"); + left_pos = "30%"; + top_pos = "20%"; + } + + var image_width = "30%"; + var image_height = "9%"; + + var current_scale = PDFViewerApplication.pdfViewer.currentScale; var sig_size = Math.floor(96 * current_scale); - var defaultSignature = "Signature"; + //var image_source = global_status.applicationContext + "/visblock?r=" + sig_size.toString(); + var image_source = '../../../img/signature.png'; + var defaultSignature = "Signature"; if (typeof page_to_place === 'undefined') { page_to_place = PDFView.page;} if (typeof s === 'undefined') { s = defaultSignature} @@ -214,6 +243,10 @@ function placeSignature(evt, page_to_place, s) { }); updateSignaturePosition(global_status.getSignature()); makeSignatureDraggable(global_status.getSignature()); + +//console.log("left: " + $("#img_signature").css("left") + " top: " + $("#img_signature").css("top")); + + } // @@ -243,6 +276,11 @@ function updateSignaturePosition(signature) { 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(); + + //console.log("last x: last y: " + $("#img_signature").css("left") + " " + $("#img_signature").css("top")); + + last_left = $("#img_signature").css("left"); + last_top = $("#img_signature").css("top"); } // -- cgit v1.2.3