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-29 15:02:46 +00:00
parent 235888ad88
commit 81dc9a9be3

View File

@ -58,8 +58,7 @@ app.classes.infolog = AppJS.extend(
break;
case 'infolog.edit.print':
// Trigger print command if the infolog oppend for printing porpuse
var that = this;
jQuery('#infolog-edit-print').bind('load',function(){that.infolog_print_preview();});
this.infolog_print_preview_onload();
}
},
@ -372,12 +371,36 @@ app.classes.infolog = AppJS.extend(
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
*/
infolog_print_preview: function ()
infolog_print_preview: function()
{
this.egw.message('Printing....');
this.egw.message('Printing...');
this.egw.window.print();
},