From 1726ef5cd41fbe630c0083079ee723836ffc5794 Mon Sep 17 00:00:00 2001 From: rpiazzi Date: Fri, 23 Sep 2011 15:12:15 +0000 Subject: Comprehensive changes due to reorganization of user interface. The form was organized within div's. Many JavaScripts added for functionality and styling reasons. See the code for further explanations. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@823 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- pdf-as-web/src/main/webapp/jsp/signupload.jsp | 1075 +++++++++++++++++++------ 1 file changed, 828 insertions(+), 247 deletions(-) (limited to 'pdf-as-web/src/main/webapp/jsp') diff --git a/pdf-as-web/src/main/webapp/jsp/signupload.jsp b/pdf-as-web/src/main/webapp/jsp/signupload.jsp index 9bc675f..ebfa339 100644 --- a/pdf-as-web/src/main/webapp/jsp/signupload.jsp +++ b/pdf-as-web/src/main/webapp/jsp/signupload.jsp @@ -1,296 +1,877 @@ -<%@page import="at.gv.egiz.pdfas.web.servlets.UpdateFormServlet"%> <%@page import="at.gv.egiz.pdfas.web.FormFields"%> <%@page import="at.gv.egiz.pdfas.web.session.SessionAttributes"%> <%@ page import="org.apache.commons.lang.StringEscapeUtils" %> <%@ page import="at.gv.egiz.pdfas.api.commons.Constants" %> <%@ page import="at.gv.egiz.pdfas.web.i18n.LanguageDecoratorMapper"%> <%@ page import="org.apache.commons.lang.BooleanUtils"%> +<%@ page import="at.gv.egiz.pdfas.web.i18n.LocaleParamFilter" %> +<%@ page import="java.util.Locale" %> +<%@ page import="at.gv.egiz.pdfas.web.servlets.SignServlet" %> +<%@ page import="at.gv.egiz.pdfas.web.helper.LocalRequestHelper" %> - +<%@ include file="/jsp/language.jsp" %> -<%@ include file="language.jsp" %> + + + <% - boolean testMode = request.getContextPath().startsWith("/test-"); - boolean forceTextualForMocca = false; - final String SIGNATUREPROFILE_DE_nonPDFa = "SIGNATURBLOCK_DE"; - final String SIGNATUREPROFILE_EN_nonPDFa = "SIGNATURBLOCK_EN"; - final String SIGNATUREPROFILE_DE_PDFa = "SIGNATURBLOCK_DE_PDFA"; - final String SIGNATUREPROFILE_EN_PDFa = "SIGNATURBLOCK_EN_PDFA"; + session = request.getSession(); - %> - + session.removeAttribute(SessionAttributes.DOWNLOAD_URL_FOR_SIGNED_PDF_DOCUMENT); + session.removeAttribute(SessionAttributes.SIGNED_PDF_DOCUMENT); + + //Check if application is started within an iframe from an extern application + String extern = (String)request.getParameter("extern"); + boolean startedFromIFrame = false; + + if (extern !=null) { + if (extern.equals("yes")) { + startedFromIFrame = true; + } + } + + //When Change Language link is hit, three parameters are passed with a hidden form + //so that the settings keep the same. Check if this parameters are passed... + String source_mode_request = (String)request.getParameter("source_mode"); + String text_request = (String)request.getParameter("text"); + String lang_request = (String)request.getParameter("newlanguage"); + + if (lang_request!=null) { + if (source_mode_request.equals("file")) { + session.setAttribute(SignServlet.SUBMITFORM_SOURCE_KEY, FormFields.VALUE_SOURCE_FILE); + } + else { + session.setAttribute(SignServlet.SUBMITFORM_SOURCE_KEY, FormFields.VALUE_SOURCE_FREETEXT); + session.setAttribute(SignServlet.SUBMITFORM_FREETEXT_KEY, text_request); + } + if (lang_request.equals("de")) { + session.setAttribute(SessionAttributes.LANGUAGE, "en"); + } + else { + session.setAttribute(SessionAttributes.LANGUAGE, "de"); + } + + } + + + boolean testMode = request.getContextPath().startsWith("/test-"); + //boolean forceTextualForMocca = false; + + String requestLang = (String)request.getParameter("lang"); + String sessionLang = (String)session.getAttribute(SessionAttributes.LANGUAGE); + String language = ""; + + //If language within session... + if (sessionLang!=null) { + //But if language also changed by clicking the change language link + //or passed as parameter with the URL... + if (requestLang!=null) { + //If language has changed, change it also within session + if (!sessionLang.equals(requestLang)) { + session.setAttribute(SessionAttributes.LANGUAGE, requestLang); + } + //else do nothing + } + //else no change + } + //Else still no language within session + else { + //But if language changed by clicking the change language link + //or passed as parameter with the URL... + if (requestLang!=null) { + if (requestLang.equals("de")) { + session.setAttribute(SessionAttributes.LANGUAGE,"de"); + } + else { + session.setAttribute(SessionAttributes.LANGUAGE,"en"); + } + } + //No language here. Set to german + else { + session.setAttribute(SessionAttributes.LANGUAGE,"de"); + } + } + + language = (String)session.getAttribute(SessionAttributes.LANGUAGE); + + + boolean german=true; + + if (language!=null) { + if (language.equals("en")) { + german = false; + } + } + + String sign_freetext = ""; + + //Get the previous settings if user hitted back or back link + //Many of this settings do not apply anymore + String sign_mode = (String)session.getAttribute(SignServlet.SUBMITFORM_SIGNATURE_MODE_KEY); + String source_mode = (String)session.getAttribute(SignServlet.SUBMITFORM_SOURCE_KEY); + String sign_type = (String)session.getAttribute(SignServlet.SUBMITFORM_SIGNATURE_TYPE_KEY); + String sign_pdfa = (String)session.getAttribute(SignServlet.SUBMITFORM_PDFA_KEY); + String sign_note = (String)session.getAttribute(SignServlet.SUBMITFORM_NOTE_KEY); + sign_freetext = (String)session.getAttribute(SignServlet.SUBMITFORM_FREETEXT_KEY); + + if (german) { + %> + <fmt:setLocale value="de"/> + <% } else { %> + <fmt:setLocale value="en"/> + <% } %> + <title> <% - if (testMode) { + if (testMode) { %> <fmt:message key="test.common.title"/> <% } else { %> <fmt:message key="common.title"/> <% } // end if %> - <% session.removeAttribute(SessionAttributes.SIGNED_PDF_DOCUMENT); %> + + <% + //If application called within an IFrame from an external application + //choose template and set session attribute + if (!startedFromIFrame) { + session.setAttribute("extern", "no"); + if (german) { + %> + + + <% } else { %> + + + <% } + } else { + session.setAttribute("extern", "yes"); + %> + + <% } %> + + + + + + - <% - // PRESETS - // signature device - String device = (String) session.getAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_DEVICE_KEY); - if (device == null) { - device = Constants.SIGNATURE_DEVICE_MOC; - session.setAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_DEVICE_KEY, device); - } - // signature mode - String mode = (String) session.getAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_MODE_KEY); - if (forceTextualForMocca && Constants.SIGNATURE_DEVICE_MOC.equals(device)) { - mode = FormFields.VALUE_MODE_TEXTUAL; - session.setAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_MODE_KEY, mode); - } - if (mode == null) { - mode = FormFields.VALUE_MODE_BINARY; - session.setAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_MODE_KEY, mode); - } - - // PDF/A-1b - boolean pdfa = BooleanUtils.toBoolean((String) session.getAttribute(UpdateFormServlet.UPLOADFORM_PDFA_KEY)); - String TYPE_EN; - String TYPE_DE; - if (pdfa) { - TYPE_EN = SIGNATUREPROFILE_EN_PDFa; - TYPE_DE = SIGNATUREPROFILE_DE_PDFa; - } else { - TYPE_EN = SIGNATUREPROFILE_EN_nonPDFa; - TYPE_DE = SIGNATUREPROFILE_DE_nonPDFa; - } - - // signature type - String type = (String) session.getAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_TYPE_KEY); - if (type == null) { - Locale locale = (Locale) session.getAttribute(LocaleParamFilter.LOCALE_SESSION_KEY); - if (locale == null) { - locale = request.getLocale(); - } - type = Locale.GERMAN.getLanguage().equals(locale.getLanguage()) ? TYPE_DE : TYPE_EN; - } else { - if (pdfa) { - if (SIGNATUREPROFILE_DE_nonPDFa.equals(type)) { - type = SIGNATUREPROFILE_DE_PDFa; - } else if (SIGNATUREPROFILE_EN_nonPDFa.equals(type)) { - type = SIGNATUREPROFILE_EN_PDFa; - } - } else { - if (SIGNATUREPROFILE_DE_PDFa.equals(type)) { - type = SIGNATUREPROFILE_DE_nonPDFa; - } else if (SIGNATUREPROFILE_EN_PDFa.equals(type)) { - type = SIGNATUREPROFILE_EN_nonPDFa; - } - } - } - session.setAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_TYPE_KEY, type); - - // source - String source = (String) session.getAttribute(UpdateFormServlet.UPLOADFORM_SOURCE_KEY); - if (source == null) { - source = FormFields.VALUE_SOURCE_FILE; - } - session.setAttribute(UpdateFormServlet.UPLOADFORM_SOURCE_KEY, source); - boolean freeText = FormFields.VALUE_SOURCE_FREETEXT.equals(source); - - // freetext - String freeTextValue = (String) session.getAttribute(UpdateFormServlet.UPLOADFORM_FREETEXT_KEY); - if (freeTextValue == null) { - freeTextValue = ""; - } - session.setAttribute(UpdateFormServlet.UPLOADFORM_FREETEXT_KEY, freeTextValue); - %> + //Function to show the textarea if freetext mode is choosen or the file upload + //field if file is choosen + function showTextarea() { + var file = document.submitform.source.options[0].selected; + if (!file) { + document.getElementById('freetext').style.display='block'; + document.getElementById('fileupload').style.display='none'; + document.getElementById('fakefile').style.display='none'; + document.getElementById('labeldocument').style.display='none'; + document.getElementById('labeltext').style.display='block'; + document.getElementById('descriptionbeforedocument').style.display='none'; + document.getElementById('descriptionbeforefreetext').style.display='block'; + if (document.getElementById('error').style.display=='block') { + document.getElementById('error').style.display='none'; + document.getElementById('errordocument').style.display='none'; + document.getElementById('errorspace').style.display='none'; + document.getElementById('fakefile').style.borderColor='#e6f2fa'; + } + } + else { + document.getElementById('freetext').style.display='none'; + document.getElementById('fileupload').style.display='block'; + document.getElementById('fakefile').style.display='block'; + document.getElementById('labeldocument').style.display='block'; + document.getElementById('labeltext').style.display='none'; + document.getElementById('descriptionbeforedocument').style.display='block'; + document.getElementById('descriptionbeforefreetext').style.display='none'; + if (document.getElementById('error').style.display=='block') { + document.getElementById('error').style.display='none'; + document.getElementById('errorfreetext').style.display='none'; + document.getElementById('errorspace').style.display='none'; + document.getElementById('freetext').style.borderColor='#e6f2fa'; + } + } + //showAdvice(); + } + + //Shows the advice when for example choosing textual signature. Not used anymore + /*function showAdvice() { + var file = document.submitform.source.options[0].selected; + //var textual = document.submitform.textual.checked; + //var binary = document.submitform.binary.checked; + var pdfa = document.submitform.pdfa.checked; + + var textual = false; + var binary = true; + + var hinweise = new Array("hinweispdfa", "hinweistextfile", "hinweistext", "hinweistextfilepdfa", "hinweistextpdfa"); + + //Check which hinweis now showed + for (var i=0; i==true) { + fakeButton.value = 'Durchsuchen'; + } + else { + fakeButton.value = 'Browse'; + } + fakeButton.id = 'fakebutton'; + fakeButton.name = 'fakebutton'; + fakeButton.alt = 'Choose file'; + fakeButton.style.verticalAlign = 'top'; + + //fakeFileUpload.appendChild(img); + fakeFileUpload.appendChild(fakeButton); + + var normalFileUpload = document.getElementById('fileupload'); + normalFileUpload.className = 'fileuploadinvisible'; + var clone = fakeFileUpload.cloneNode(true); + normalFileUpload.parentNode.appendChild(clone); + normalFileUpload.relatedElement = clone.getElementsByTagName('input')[0]; + normalFileUpload.onchange = normalFileUpload.onmouseout = function () { + this.relatedElement.value = this.value; + } + } + + //Check the height of the IFrame to be shown for adjusting the high + //of the currently showed div's as well as of those of other pages + function checkHeight() { + var sign = document.getElementById('sign'); + var signiframe = document.getElementById('signiframe'); + var localbku = document.getElementById('localbku'); + var signaturesettings = document.getElementById('signaturesettings'); + sign.style.display='none'; + signiframe.style.display='block'; + localbku.style.display='block'; + var height = signiframe.offsetHeight; + sign.style.height=height+'px'; + signaturesettings.style.height=height+'px'; + signiframe.style.display='none'; + localbku.style.display='none'; + sign.style.display='block'; + document.submitform.<%=FormFields.FIELD_HEIGHT_SIGNDIV%>.value=height+'px'; + } + + //Show the fake image/button as it would be focused (mouse over) + function focusButton() { + document.getElementById('buttonimage').src = 'https://www.buergerkarte.at/test-pdf-as/images/durchsuchen_aktiv.png'; + } + + //Show the fake image/button as it would be unfocused (mouse out) + function unfocusButton() { + document.getElementById('buttonimage').src = 'https://www.buergerkarte.at/test-pdf-as/images/durchsuchen.png'; + } + + //Change some size settings when IE7 is found + function detectBrowser() { + if ((navigator.appName.indexOf('Internet Explorer')!=-1) && (navigator.appVersion.indexOf('MSIE 7.0')!=-1)) { + document.getElementById('signintern').className='rechtsinhaltinternetexplorer'; + document.getElementById('signiframeintern').className='rechtsinhaltinternetexplorer'; + document.getElementById('downloadsignbuttonsintern').className='rechtsinhaltinternetexplorer'; + document.getElementById('signaturesettingsintern').className='linksinhaltinternetexplorer'; + + var stringHeight = document.submitform.<%=FormFields.FIELD_HEIGHT_SIGNDIV%>.value; + var iediff = 25; + var height = parseInt(stringHeight)+iediff; + height = height + 'px'; + document.getElementById('sign').style.height = height; + document.getElementById('signaturesettings').style.height = height; + document.getElementById('signiframe').style.height = height; + document.getElementById('downloadsignbuttons').style.height = height; + } + } + + + -

- <% - if (testMode) { - %> - - <% } else { %> - - <% } // end if %> -

-

- <% if (freeText) { %> - - <% } else { %> - + + + <% if (!startedFromIFrame) { %> +

+ <% + if (testMode) { + %> + + <% } else { %> + + <% } // end if %> +

+ +

+ +

<% } %> -

-
- <% if (freeText) { %> - - <% } else { %> - + + + + + + + + + + <% if (source_mode!=null) { + if (source_mode.contains(FormFields.VALUE_SOURCE_FILE)) { %> +
+ +
+ + <% } else { %> + +
+ +
+ <% } + } else { %> +
+ +
+ <% } %> -
-
- - - - - - <% if (freeText) { %> - - <% } // end if %> -
-
- - - - - - - - - - - - - - - - - - -
- - - - onclick="return updateForm();"/>  -
- <% if (forceTextualForMocca && Constants.SIGNATURE_DEVICE_MOC.equals(device)) {%> - - + + + + + +
+ +
+ + + +
- -
- - - <% if (freeText) { %> - + <% } else { %> + <%if (german) { %> + <% } else { %> - - <% } // end if freetext %> -
- <% if ((!freeText && (FormFields.VALUE_MODE_TEXTUAL.equals(mode))) || pdfa) { %> -
- : - <% if ((FormFields.VALUE_MODE_TEXTUAL.equals(mode))) { %> - <% if (!freeText) { %><% } %> - <% } // end if %> - <% if (pdfa) { %> <% } %> + + <% } %> + <% } %> +
--> + + + + <% if (source_mode!=null) { %> + <% if (source_mode.contains(FormFields.VALUE_SOURCE_FILE)) { %> +
+ +
+
+ +
+
+
+ + +
+
+ + +
+ <% } else {%> +
+ +
+
+ +
+
+
+ + +
+
+ + +
+ <% } %> + <% } else { %> +
+ +
+
+ +
+
+
+ + +
+
+ + +
+ <% } %> + + + + - <% } // end if %> - - - - -
- - -
- <% if (Constants.SIGNATURE_DEVICE_BKU.equals(device)) { %> -
- - - +
+
+ +
+ Handy +
+ +
+ " alt="Signatur mit Handy" onclick="return submitForm(this)"> +
+ +
- <% } else if (Constants.SIGNATURE_DEVICE_MOC.equals(device)) { %> -
- <fmt:message key="/> +
+ + - - + +
+ <% if (german) { %> + + <% } else { %> + + <% } %> + <% if (source_mode!=null) { + if (source_mode.contains(FormFields.VALUE_SOURCE_FILE)) { %> + + + <% } else { %> + + + <% } + } else { %> + + + <% } %> +
+ + + + <% + //After loading the page set all attributes to null + session.setAttribute(SignServlet.SUBMITFORM_SIGNATURE_MODE_KEY, null); + session.setAttribute(SignServlet.SUBMITFORM_SOURCE_KEY, null); + session.setAttribute(SignServlet.SUBMITFORM_SIGNATURE_TYPE_KEY, null); + session.setAttribute(SignServlet.SUBMITFORM_PDFA_KEY, null); + session.setAttribute(SignServlet.SUBMITFORM_NOTE_KEY, null); + session.setAttribute(SignServlet.SUBMITFORM_FREETEXT_KEY, null); + session.setAttribute(SignServlet.SUBMITFORM_SIGNATURE_DEVICE_KEY, null); + session.setAttribute(SignServlet.SUBMITFORM_FILE_KEY, null); + session.setAttribute(SignServlet.SUBMITFORM_FILENAME_KEY, null); + session.setAttribute(SessionAttributes.ATTRIBUTE_SESSION_INFORMATION, null); + session.setAttribute(SignServlet.ERROR_WITHIN_IFRAME, null); + + %> -- cgit v1.2.3