From 612c7fe90b8b1f749a4213b46b1fd2b26fd256cd Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Wed, 30 Jul 2014 15:18:41 +0000 Subject: [PATCH] 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 --- infolog/js/app.js | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/infolog/js/app.js b/infolog/js/app.js index af8ce4e6a8..8a82642c70 100644 --- a/infolog/js/app.js +++ b/infolog/js/app.js @@ -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(); },