From bbd75286a8406cf9e5aea01fdb7950d547edefb9 Mon Sep 17 00:00:00 2001 From: Obexer Christoph Date: Sat, 4 Feb 2012 15:32:09 +0100 Subject: [PATCH] jquery.plugin.html2canvas: add profiling option, tests: enable profiling in case you run the tests in firefox and have firebug installed and active you now get a profiling run of html2canvas ;) --- src/plugins/jquery.plugin.html2canvas.js | 23 +++++++++++++---------- tests/test.js | 5 +++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/plugins/jquery.plugin.html2canvas.js b/src/plugins/jquery.plugin.html2canvas.js index 78460f5..f119438 100644 --- a/src/plugins/jquery.plugin.html2canvas.js +++ b/src/plugins/jquery.plugin.html2canvas.js @@ -3,6 +3,9 @@ */ (function( $ ){ $.fn.html2canvas = function(options) { + if (options && options.profile && window.console && window.console.profile) { + console.profile(); + } var date = new Date(), $message = null, timeoutTimer = false, @@ -14,20 +17,17 @@ $canvas = $(html2canvas.Renderer(queue, options)), finishTime = new Date(); + if (options && options.profile && window.console && window.console.profileEnd) { + console.profileEnd(); + } $canvas.css({ position: 'absolute', left: 0, top: 0 }).appendTo(document.body); $canvas.siblings().toggle(); $(window).click(function(){ - if (!$canvas.is(':visible')){ $canvas.toggle().siblings().toggle(); - throwMessage("Canvas Render visible"); - } else{ - $canvas.siblings().toggle(); - $canvas.toggle(); - throwMessage("Canvas Render hidden"); - } + throwMessage("Canvas Render " + ($canvas.is(':visible') ? "visible" : "hidden")); }); - throwMessage('Screenshot created in '+ ((finishTime.getTime()-timer)/1000) + " seconds
",4000); + throwMessage('Screenshot created in '+ ((finishTime.getTime()-timer)) + " ms
",4000); } }, options)); @@ -36,6 +36,7 @@ timeoutTimer = window.setTimeout(function(){ $message.fadeOut(function(){ $message.remove(); + $message = null; }); },duration || 2000); if ($message) @@ -55,8 +56,10 @@ width:'auto', height:'auto', textAlign:'center', - textDecoration:'none' - }).hide().fadeIn().appendTo('body'); + textDecoration:'none', + display:'none' + }).appendTo(document.body).fadeIn(); + html2canvas.log(msg); } }; })( jQuery ); diff --git a/tests/test.js b/tests/test.js index 3c21bcd..52a893a 100644 --- a/tests/test.js +++ b/tests/test.js @@ -18,8 +18,9 @@ } setTimeout(function() { $(document.body).html2canvas({ - logging: true + logging: true, + profile: true }); }, 100); }; -}(document, window)); \ No newline at end of file +}(document, window));