mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-16 13:03:16 +01:00
Printing improvements
This commit is contained in:
parent
b7d00df071
commit
29d0f737d5
@ -1875,7 +1875,7 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput, et2_IPrin
|
||||
this.resize();
|
||||
// Reset height to auto (after width resize) so there's no restrictions
|
||||
this.dynheight.innerNode.css('height', 'auto');
|
||||
|
||||
|
||||
// Check for rows that aren't loaded yet, or lots of rows
|
||||
var range = this.controller._grid.getIndexRange();
|
||||
this.old_height = this.controller._grid._scrollHeight;
|
||||
@ -1953,30 +1953,20 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput, et2_IPrin
|
||||
defer.reject();
|
||||
return;
|
||||
}
|
||||
if(value < total)
|
||||
{
|
||||
// Set height to the requested number of rows, using the average height.
|
||||
// We add one, in case there's some larger rows we
|
||||
// try to get most of it but that's pretty hacky
|
||||
nm.controller._grid.setScrollHeight(nm.controller._grid.getAverageHeight() * (value+1));
|
||||
}
|
||||
// Use CSS to hide all but the requested rows
|
||||
// Prevents us from showing more than requested, if actual height was less than average
|
||||
nm.print_row_selector = ".egwGridView_grid > tbody > tr:not(:nth-child(-n+"+value+"))";
|
||||
egw.css(nm.print_row_selector, 'display: none');
|
||||
|
||||
// No scrollbar in print view
|
||||
$j('.egwGridView_scrollarea',this.div).css('overflow-y','hidden');
|
||||
// Show it all
|
||||
$j('.egwGridView_scrollarea',this.div).css('height','auto');
|
||||
|
||||
// Grid needs to redraw before it can be printed, so wait
|
||||
window.setTimeout(jQuery.proxy(function() {
|
||||
dialog.destroy();
|
||||
|
||||
if(value < total)
|
||||
{
|
||||
// Show requested number, based on average height
|
||||
nm.controller._grid.setScrollHeight(nm.controller._grid.getAverageHeight() * (value));
|
||||
// No scrollbar in print view
|
||||
$j('.egwGridView_scrollarea',this.div).css('overflow-y','hidden');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show it all
|
||||
$j('.egwGridView_scrollarea',this.div).css('height','auto');
|
||||
}
|
||||
|
||||
// Should be OK to print now
|
||||
defer.resolve();
|
||||
},nm),ET2_GRID_INVALIDATE_TIMEOUT);
|
||||
@ -1991,7 +1981,15 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput, et2_IPrin
|
||||
else
|
||||
{
|
||||
// Don't need more rows, limit to requested and finish
|
||||
this.controller._grid.setScrollHeight(this.controller._grid.getAverageHeight() * (value));
|
||||
|
||||
// Show it all
|
||||
$j('.egwGridView_scrollarea',this.div).css('height','auto');
|
||||
|
||||
// Use CSS to hide all but the requested rows
|
||||
// Prevents us from showing more than requested, if actual height was less than average
|
||||
this.print_row_selector = ".egwGridView_grid > tbody > tr:not(:nth-child(-n+"+value+"))";
|
||||
egw.css(this.print_row_selector, 'display: none');
|
||||
|
||||
// No scrollbar in print view
|
||||
$j('.egwGridView_scrollarea',this.div).css('overflow-y','hidden');
|
||||
// Give dialog a chance to close, or it will be in the print
|
||||
@ -2017,10 +2015,29 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput, et2_IPrin
|
||||
}
|
||||
// Don't return anything, just work normally
|
||||
},
|
||||
|
||||
/**
|
||||
* Try to clean up the mess we made getting ready for printing
|
||||
* in beforePrint()
|
||||
*/
|
||||
afterPrint: function() {
|
||||
|
||||
this.div.removeClass('print');
|
||||
|
||||
// Put scrollbar back
|
||||
$j('.egwGridView_scrollarea',this.div).css('overflow-y','');
|
||||
|
||||
// Correct size of grid, and trigger resize to fix it
|
||||
this.controller._grid.setScrollHeight(this.old_height);
|
||||
delete this.old_height;
|
||||
|
||||
// Remove CSS rule hiding extra rows
|
||||
if(this.print_row_selector)
|
||||
{
|
||||
egw.css(this.print_row_selector, false);
|
||||
delete this.print_row_selector;
|
||||
}
|
||||
|
||||
this.dynheight.outerNode.css('max-width','inherit');
|
||||
this.resize();
|
||||
}
|
||||
|
@ -975,20 +975,29 @@ var fw_base = Class.extend({
|
||||
{
|
||||
// Try to clean up after - not guaranteed
|
||||
var afterPrint = function() {
|
||||
for(var i = 0; i < et2_list.length; i++)
|
||||
{
|
||||
et2_list[i].widgetContainer.iterateOver(function(_widget) {
|
||||
_widget.afterPrint();
|
||||
},et2_list[i],et2_IPrint);
|
||||
}
|
||||
// Reset after removing margin
|
||||
$j('#egw_fw_main').css('margin-left', (framework.activeApp.sideboxWidth -1)+ "px");
|
||||
var app = framework.activeApp;
|
||||
framework.activeApp = '';
|
||||
framework.setActiveApp(app);
|
||||
|
||||
// Give framework a chance to deal, then reset the etemplates
|
||||
window.setTimeout(function() {
|
||||
for(var i = 0; i < et2_list.length; i++)
|
||||
{
|
||||
et2_list[i].widgetContainer.iterateOver(function(_widget) {
|
||||
_widget.afterPrint();
|
||||
},et2_list[i],et2_IPrint);
|
||||
}
|
||||
},100);
|
||||
appWindow.onafterprint = null;
|
||||
};
|
||||
if(appWindow.matchMedia) {
|
||||
var mediaQueryList = appWindow.matchMedia('print');
|
||||
var listener = function(mql) {
|
||||
if (!mql.matches) {
|
||||
afterPrint();
|
||||
mediaQueryList.removeListener(listener);
|
||||
afterPrint();
|
||||
}
|
||||
};
|
||||
mediaQueryList.addListener(listener);
|
||||
@ -998,7 +1007,9 @@ var fw_base = Class.extend({
|
||||
|
||||
// Wait for everything to be loaded, then send it off
|
||||
jQuery.when.apply(jQuery, deferred).done(function() {
|
||||
appWindow.print();
|
||||
// Despite being set in the print CSS, this just doesn't work
|
||||
$j('#egw_fw_main').css('margin-left','0px');
|
||||
appWindow.setTimeout(appWindow.print, 0);
|
||||
}).fail(function() {
|
||||
afterPrint();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user