Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung | |||
projekt:druckfunktioninsmartform [2013/01/22 18:34] stefan.barth |
— (aktuell) | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | In der Smartform folgendes DIV einfügen. | ||
- | <code> | ||
- | <div initMethod="preparePrint" style="cursor:pointer;display:block"><img src='/loom-portal/resrc/img/png/printer.png' /></div> | ||
- | </code> | ||
- | In der [[custom.js]] muss [[jQuery]] eingebunden sein. Falls dies nicht der Fall ist beim Laden der Smartform | ||
- | jq= (this.form.ownerDocument.defaultView!=null) ? this.form.ownerDocument.defaultView.jQuery : this.form.ownerDocument.parentWindow.jQuery; | ||
- | ausführen. | ||
- | |||
- | Es muss nur noch die preparePrint Funktion in die custom.js eingefügt werden. | ||
- | |||
- | <code javascript> | ||
- | gadget.functions.preparePrint = function () { | ||
- | function adjustMaskSize() { | ||
- | var fullSizeDiv = document.getElementById("printFullSize"); | ||
- | fullSizeDiv.style.width = '0'; | ||
- | fullSizeDiv.style.height = '0'; | ||
- | fullSizeDiv.style.height = document.body.scrollHeight + 'px'; | ||
- | fullSizeDiv.style.width = document.body.scrollWidth + 'px'; | ||
- | } | ||
- | var getParentWindow = function (obj) { | ||
- | var d = obj && obj.ownerDocument ? obj.ownerDocument : doc; | ||
- | return d.parentWindow || d.defaultView; | ||
- | }; | ||
- | this.innerHTML="<img src='/loom-portal/resrc/img/png/printer.png' />"; | ||
- | this.style.cursor="pointer"; | ||
- | |||
- | this.onclick=function() | ||
- | { | ||
- | this.style.display="none"; | ||
- | var html = '<html><head><title>Print view</title><script>\n' + adjustMaskSize.toString() + '\n</script>'; | ||
- | jq=getParentWindow(this).jQuery; | ||
- | // adding styles | ||
- | jq('link[href$=".css"]').each(function (idx, el) { | ||
- | // Util.log("found link: " + el.href); | ||
- | html += jq(el).clone().wrap('<div>').parent().html(); | ||
- | }); | ||
- | | ||
- | html += '</head><body class="printVersion" onload="adjustMaskSize()" onresize="adjustMaskSize()">' + | ||
- | '<div id="fullSize"> </div><div>'; | ||
- | | ||
- | jq('form').each(function() { | ||
- | html += jq(this).clone().wrap('<div>').parent().html().replace('id="local_zone"', 'class="local_zone"'); | ||
- | }); | ||
- | | ||
- | html += '</div></body></html>'; | ||
- | | ||
- | var popupWindow = window.open('', '_blank', | ||
- | 'menubar=no,addressbar=no,location=no,resizable=yes,scrollbars=yes,status=no'); | ||
- | popupWindow.document.open(); | ||
- | popupWindow.document.write(html); | ||
- | popupWindow.document.close(); | ||
- | popupWindow.print(); | ||
- | |||
- | this.style.display="block"; | ||
- | | ||
- | } | ||
- | };</code> |