aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web/src/main/webapp/assets/js
diff options
context:
space:
mode:
authorfschneider <florian.schneider@student.tugraz.at>2015-08-19 13:20:29 +0200
committerfschneider <florian.schneider@student.tugraz.at>2015-08-19 13:20:29 +0200
commit14bda0e08c2168f4a9df143d8896c92bfdb9b47c (patch)
tree74b4bd099d1e883bb3ff00330dae75ae44dd6a03 /pdf-as-web/src/main/webapp/assets/js
parent399096e21435170201ab85e58a20bfcfa9d4912f (diff)
downloadpdf-as-4-14bda0e08c2168f4a9df143d8896c92bfdb9b47c.tar.gz
pdf-as-4-14bda0e08c2168f4a9df143d8896c92bfdb9b47c.tar.bz2
pdf-as-4-14bda0e08c2168f4a9df143d8896c92bfdb9b47c.zip
Responsive Design for most C
Diffstat (limited to 'pdf-as-web/src/main/webapp/assets/js')
-rw-r--r--pdf-as-web/src/main/webapp/assets/js/dragNdrop.js58
-rw-r--r--pdf-as-web/src/main/webapp/assets/js/pdf.js/web/app.js87
-rw-r--r--pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.html5
-rw-r--r--pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.js24
4 files changed, 137 insertions, 37 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 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/
<span id="numPages" class="toolbarLabel"></span>
</div>
- <div id="toolbarViewerRight">
+ <div id="toolbarViewerRight" style="display:none;">
<div class="splitToolbarButton">
<button id="zoomOut" class="toolbarButton zoomOut" title="Zoom Out" tabindex="21" data-l10n-id="zoom_out">
@@ -233,9 +233,9 @@ http://sourceforge.net/adobe/cmap/wiki/License/
</div>
<span id="scaleSelectContainer" class="dropdownToolbarButton">
<select id="scaleSelect" title="Zoom" tabindex="23" data-l10n-id="zoom">
+ <option id="pageFitOption" title="" value="page-fit" selected="selected" data-l10n-id="page_scale_fit">Fit Page</option>
<option id="pageAutoOption" title="" value="auto" data-l10n-id="page_scale_auto">Automatic Zoom</option>
<option id="pageActualOption" title="" value="page-actual" data-l10n-id="page_scale_actual">Actual Size</option>
- <option id="pageFitOption" title="" value="page-fit" selected="selected" data-l10n-id="page_scale_fit">Fit Page</option>
<option id="pageWidthOption" title="" value="page-width" data-l10n-id="page_scale_width">Full Width</option>
<option id="customScaleOption" title="" value="custom"></option>
<option title="" value="0.5" data-l10n-id="page_scale_percent" data-l10n-args='{ "scale": 50 }'>50%</option>
@@ -253,7 +253,6 @@ http://sourceforge.net/adobe/cmap/wiki/License/
<span data-l10n-id="presentation_mode_label">Presentation Mode</span>
</button>
-
<button style="display:none;" id="placeSignature" class="toolbarButton placeSignature hiddenLargeView" title="Place Signature on current Page" tabindex="30" data-l10n-id="place_signature">
<span data-l10n-id="place_signature_label">Place Signature</span>
</button>
diff --git a/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.js b/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.js
index e5563ba5..e26d544a 100644
--- a/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.js
+++ b/pdf-as-web/src/main/webapp/assets/js/pdf.js/web/viewer.js
@@ -46,7 +46,7 @@ var mozL10n = document.mozL10n || document.webL10n;
var CSS_UNITS = 96.0 / 72.0;
-var DEFAULT_SCALE = 'auto';
+var DEFAULT_SCALE = 'page-fit';
var UNKNOWN_SCALE = 0;
var MAX_AUTO_SCALE = 1.25;
var SCROLLBAR_PADDING = 40;
@@ -2284,7 +2284,7 @@ var GrabToPan = (function GrabToPanClosure() {
activate: function GrabToPan_activate() {
if (!this.active) {
this.active = true;
- this.element.addEventListener('mousedown', this._onmousedown, true);
+ // this.element.addEventListener('mousedown', this._onmousedown, true);
this.element.classList.add(this.CSS_CLASS_GRAB);
if (this.onActiveChanged) {
this.onActiveChanged(true);
@@ -2473,7 +2473,7 @@ var HandTool = {
window.addEventListener('localized', function (evt) {
Preferences.get('enableHandToolOnLoad').then(function resolved(value) {
if (value) {
- this.handTool.activate();
+ this.handTool.deactivate();
}
}.bind(this), function rejected(reason) {});
}.bind(this));
@@ -2481,7 +2481,7 @@ var HandTool = {
},
toggle: function handToolToggle() {
- this.handTool.toggle();
+ this.handTool.deactivate();
SecondaryToolbar.close();
},
@@ -2495,7 +2495,7 @@ var HandTool = {
exitPresentationMode: function handToolExitPresentationMode() {
if (this.wasActive) {
this.wasActive = null;
- this.handTool.activate();
+ this.handTool.deactivate();
}
}
};
@@ -6266,6 +6266,7 @@ var PDFViewerApplication = {
console.error(reason);
self.setInitialView(null, scale);
});
+
});
pagesPromise.then(function() {
@@ -6371,11 +6372,15 @@ var PDFViewerApplication = {
self.fallback(PDFJS.UNSUPPORTED_FEATURES.forms);
}
-
+ console.log("pdfview just finished loading");
+ $("#pageFitOption").click();
+ $("#scaleSelect").change();
});
- console.log("pdfview just finished loading");
+
+
+ $("#pageFitOption").click();
},
@@ -6912,7 +6917,7 @@ function webViewerInitialized() {
document.getElementById('scaleSelect').addEventListener('change',
function() {
- PDFViewerApplication.setScale(this.value, false);
+ PDFViewerApplication.setScale("page-fit", false); // former: this.value
});
document.getElementById('presentationMode').addEventListener('click',
@@ -7002,6 +7007,7 @@ function updateViewarea() {
return;
}
PDFViewerApplication.pdfViewer.update();
+
}
window.addEventListener('updateviewarea', function () {
@@ -7048,7 +7054,7 @@ window.addEventListener('resize', function webViewerResize(evt) {
document.getElementById('pageFitOption').selected ||
document.getElementById('pageWidthOption').selected)) {
var selectedScale = document.getElementById('scaleSelect').value;
- PDFViewerApplication.setScale(selectedScale, false);
+ PDFViewerApplication.setScale("page-fit", false); // former: selectedScale
}
updateViewarea();