Fix printing problem happening in IE and FF

This commit is contained in:
Hadi Nategh 2014-12-01 08:45:08 +00:00
parent b8756e7ecd
commit bd4448e967

View File

@ -3909,26 +3909,30 @@ app.classes.mail = AppJS.extend(
mail_display_print: function () mail_display_print: function ()
{ {
var mainIframe = jQuery('#mail-display_mailDisplayBodySrc'); var mainIframe = jQuery('#mail-display_mailDisplayBodySrc');
var tmpPrintDiv = jQuery('#tempPrintDiv');
if (jQuery('#tempPrintDiv').length == 0) if (tmpPrintDiv.length == 0 && tmpPrintDiv.children())
{ {
var tmpPrintDiv = jQuery(document.createElement('div')) tmpPrintDiv = jQuery(document.createElement('div'))
.attr('id', 'tempPrintDiv') .attr('id', 'tempPrintDiv')
.addClass('tmpPrintDiv'); .addClass('tmpPrintDiv');
var notAttached = true;
}
if (mainIframe) if (mainIframe)
{ {
tmpPrintDiv[0].innerHTML = mainIframe.contents().find('body').html(); tmpPrintDiv[0].innerHTML = mainIframe.contents().find('body').html();
} }
// Attach the element to the DOM after maniupulation
jQuery('#mail-display_mailDisplayBodySrc').after(tmpPrintDiv); if (notAttached) jQuery('#mail-display_mailDisplayBodySrc').after(tmpPrintDiv);
tmpPrintDiv.find('#divAppboxHeader').remove(); tmpPrintDiv.find('#divAppboxHeader').remove();
}
this.egw.message('Printing....'); this.egw.message('Printing....');
var display = this;
// Make sure the print happens after the content is loaded. Seems Firefox can't handle timing for print command correctly // Make sure the print happens after the content is loaded. Seems Firefox and IE can't handle timing for print command correctly
setTimeout(function(){display.egw.window.print();},1); setTimeout(function(){
egw(window).window.print();
},100);
}, },
/** /**