Make sure all DOMSubtrees are loaded before trigger the print job on window onload. Fix error "getComputing is not function" when closing the window while the print preview is loaded

This commit is contained in:
Hadi Nategh 2014-07-30 15:18:41 +00:00
parent 8a01456df0
commit 612c7fe90b

View File

@ -58,8 +58,7 @@ app.classes.infolog = AppJS.extend(
break; break;
case 'infolog.edit.print': case 'infolog.edit.print':
// Trigger print command if the infolog oppend for printing porpuse // Trigger print command if the infolog oppend for printing porpuse
var that = this; this.infolog_print_preview_onload();
jQuery('#infolog-edit-print').bind('load',function(){that.infolog_print_preview();});
} }
}, },
@ -372,12 +371,36 @@ app.classes.infolog = AppJS.extend(
egw_open(id,'infolog','edit',{print:1}); egw_open(id,'infolog','edit',{print:1});
}, },
/**
* Trigger print() onload window
*/
infolog_print_preview_onload: function ()
{
var that = this;
jQuery('#infolog-edit-print').bind('load',function(){
var isLoadingCompleted = true;
jQuery('#infolog-edit-print').bind("DOMSubtreeModified",function(event){
isLoadingCompleted = false;
jQuery('#infolog-edit-print').unbind("DOMSubtreeModified");
});
setTimeout(function(){isLoadingCompleted = false},1000);
var interval = setInterval(function(){
if (!isLoadingCompleted)
{
clearInterval(interval);
that.infolog_print_preview();
}
}, 100);
});
},
/** /**
* Trigger print() function to print the current window * Trigger print() function to print the current window
*/ */
infolog_print_preview: function() infolog_print_preview: function()
{ {
this.egw.message('Printing....'); this.egw.message('Printing...');
this.egw.window.print(); this.egw.window.print();
}, },