From 3fcb5e25bafb363c2e98324b75f7f9029d692060 Mon Sep 17 00:00:00 2001 From: nathangray Date: Mon, 25 Feb 2019 14:14:09 -0700 Subject: [PATCH] * Api - When printing lists ask for print orientation and size columns to fit --- api/js/etemplate/et2_extension_nextmatch.js | 32 +++++++++++++++++++-- api/src/Etemplate.php | 2 +- api/templates/default/etemplate2.css | 8 ++++-- api/templates/default/nm_print_dialog.xet | 1 + 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/api/js/etemplate/et2_extension_nextmatch.js b/api/js/etemplate/et2_extension_nextmatch.js index 7b6bb6dfa9..63fa076091 100644 --- a/api/js/etemplate/et2_extension_nextmatch.js +++ b/api/js/etemplate/et2_extension_nextmatch.js @@ -2140,6 +2140,31 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_ return; } + // Set CSS for orientation + this.div.addClass(value.orientation); + this.egw().set_preference(app,pref+'_orientation',value.orientation); + + + // Try to tell browser about orientation + var css = '@page { size: '+ value.orientation + '; }', + head = document.head || document.getElementsByTagName('head')[0], + style = document.createElement('style'); + + style.type = 'text/css'; + style.media = 'print'; + + if (style.styleSheet){ + style.styleSheet.cssText = css; + } else { + style.appendChild(document.createTextNode(css)); + } + + head.appendChild(style); + this.orientation_style = style; + + // Trigger resize, so we can fit on a page + this.dynheight.outerNode.css('max-width',this.div.css('max-width')); + // Handle columns this.set_columns(value.columns); this.egw().set_preference(app,pref,value.columns); @@ -2257,7 +2282,8 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_ value: { content: { row_count: Math.min(100,total), - columns: this.egw().preference(pref,app) || columns_selected + columns: this.egw().preference(pref,app) || columns_selected, + orientation: this.egw().preference(pref+'_orientation',app) }, sel_options: { columns: columns @@ -2274,7 +2300,9 @@ var et2_nextmatch = (function(){ "use strict"; return et2_DOMWidget.extend([et2_ */ afterPrint: function() { - this.div.removeClass('print'); + this.div.removeClass('print landscape portrait'); + jQuery(this.orientation_style).remove(); + delete this.orientation_style; // Put scrollbar back jQuery('.egwGridView_scrollarea',this.div).css('overflow-y',''); diff --git a/api/src/Etemplate.php b/api/src/Etemplate.php index 4b804248d3..37ebcaf37c 100644 --- a/api/src/Etemplate.php +++ b/api/src/Etemplate.php @@ -261,7 +261,7 @@ class Etemplate extends Etemplate\Widget\Template echo $GLOBALS['egw']->framework->header(); if ($output_mode != 2 && !$GLOBALS['egw_info']['flags']['nonavbar']) { - parse_navbar(); + $GLOBALS['egw']->framework->navbar(); } else // mark popups as such, by enclosing everything in div#popupMainDiv { diff --git a/api/templates/default/etemplate2.css b/api/templates/default/etemplate2.css index 74b49cc77a..ad881eec9f 100644 --- a/api/templates/default/etemplate2.css +++ b/api/templates/default/etemplate2.css @@ -555,9 +555,13 @@ for printing .et2_nextmatch.print > div { height: auto !important; } -.et2_nextmatch.print { +.et2_nextmatch.print.landscape { /* This is fairly arbitrary, but makes it fit in Chrome and Firefox*/ - max-width: 700pt !important; + max-width: 710pt !important; +} +.et2_nextmatch.print.portrait { + /* This is fairly arbitrary, but makes it fit in Chrome and Firefox*/ + max-width: 570pt !important; } /** * Diff widget diff --git a/api/templates/default/nm_print_dialog.xet b/api/templates/default/nm_print_dialog.xet index 03af10c742..9bd3c96637 100644 --- a/api/templates/default/nm_print_dialog.xet +++ b/api/templates/default/nm_print_dialog.xet @@ -7,6 +7,7 @@