|
14 | 14 | options.elements = this;
|
15 | 15 | options.flashcanvas = "../external/flashcanvas.min.js";
|
16 | 16 |
|
17 |
| - html2canvas.logging = options && options.logging; |
| 17 | + html2canvas.logging = options && options.logging; |
18 | 18 | options.complete = function(images){
|
19 |
| - var queue = html2canvas.Parse(this[0], images, options), |
20 |
| - $canvas = $(html2canvas.Renderer(queue, options)), |
21 |
| - finishTime = new Date(); |
| 19 | + var queue = html2canvas.Parse(this[0], images, options), |
| 20 | + $canvas = $(html2canvas.Renderer(queue, options)), |
| 21 | + finishTime = new Date(); |
22 | 22 |
|
23 |
| - if (options && options.profile && window.console && window.console.profileEnd) { |
24 |
| - console.profileEnd(); |
25 |
| - } |
26 |
| - $canvas.css({ position: 'absolute', left: 0, top: 0 }).appendTo(document.body); |
27 |
| - $canvas.siblings().toggle(); |
| 23 | + if (options && options.profile && window.console && window.console.profileEnd) { |
| 24 | + console.profileEnd(); |
| 25 | + } |
| 26 | + $canvas.css({ |
| 27 | + position: 'absolute', |
| 28 | + left: 0, |
| 29 | + top: 0 |
| 30 | + }).appendTo(document.body); |
| 31 | + $canvas.siblings().toggle(); |
28 | 32 |
|
29 |
| - $(window).click(function(){ |
30 |
| - $canvas.toggle().siblings().toggle(); |
31 |
| - throwMessage("Canvas Render " + ($canvas.is(':visible') ? "visible" : "hidden")); |
32 |
| - }); |
33 |
| - throwMessage('Screenshot created in '+ ((finishTime.getTime()-timer)) + " ms<br />",4000); |
| 33 | + $(window).click(function(){ |
| 34 | + $canvas.toggle().siblings().toggle(); |
| 35 | + throwMessage("Canvas Render " + ($canvas.is(':visible') ? "visible" : "hidden")); |
| 36 | + }); |
| 37 | + throwMessage('Screenshot created in '+ ((finishTime.getTime()-timer)) + " ms<br />",4000); |
| 38 | + |
| 39 | + // test if canvas is read-able |
| 40 | + try { |
| 41 | + $canvas[0].toDataURL(); |
| 42 | + } catch(e) { |
| 43 | + if ($canvas[0].nodeName.toLowerCase() === "canvas") { |
| 44 | + // TODO, maybe add a bit less offensive way to present this, but still something that can easily be noticed |
| 45 | + alert("Canvas is tainted, unable to read data"); |
| 46 | + } |
| 47 | + } |
34 | 48 |
|
35 | 49 | };
|
36 | 50 | html2canvas.Preload(this[0], options);
|
|
0 commit comments