2014-02-01 20:52:53 +04:00
|
|
|
(function(t,e){function n(){return Math.max(Math.max(e.body.scrollWidth,e.documentElement.scrollWidth),Math.max(e.body.offsetWidth,e.documentElement.offsetWidth),Math.max(e.body.clientWidth,e.documentElement.clientWidth))}function i(){return Math.max(Math.max(e.body.scrollHeight,e.documentElement.scrollHeight),Math.max(e.body.offsetHeight,e.documentElement.offsetHeight),Math.max(e.body.clientHeight,e.documentElement.clientHeight))}function o(e,n,i){var o=e.documentElement.cloneNode(!0),r=e.createElement("iframe");return r.style.display="hidden",r.style.position="absolute",r.width=n,r.height=i,r.scrolling="no",e.body.appendChild(r),new Promise(function(e){var n=function(){"none"!==r.contentWindow.getComputedStyle(s,null).backgroundImage?(i.body.removeChild(s),i.body.removeChild(a),e(r)):t.setTimeout(n,10)},i=r.contentWindow.document;i.open(),i.write(""),i.close(),i.replaceChild(i.adoptNode(o),i.documentElement),r.contentWindow.scrollTo(t.scrollX,t.scrollY);var s=i.createElement("div");s.className="html2canvas-ready-test",i.body.appendChild(s);var a=i.createElement("style");a.innerHTML="body div.html2canvas-ready-test { background-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7); }",i.body.appendChild(a),t.setTimeout(n,1e3)})}function r(t,e){this.src=t,this.image=new Image;var n=this.image;this.promise=new Promise(function(i,o){n.onload=i,n.onerror=o,e&&(n.crossOrigin="anonymous"),n.src=t,n.complete===!0&&i(n)})}function s(e,n){this.link=null,this.options=e,this.support=n,this.origin=t.location.protocol+t.location.host}function a(t){return"IMG"===t.node.nodeName}function c(t){return t.node.src}function u(){t.html2canvas.logging&&t.console&&t.console.log&&t.console.log.apply(t.console,[Date.now()-t.html2canvas.start+"ms","html2canvas:"].concat([].slice.call(arguments,0)))}function h(t,e){this.node=t,this.parent=e,this.stack=null,this.bounds=null,this.visible=null,this.computedStyles=null,this.styles={},this.backgroundImages=null}function p(t){return-1!==(""+t).indexOf("%")}function d(t,e,n,i,o){u("Starting NodeParser"),this.renderer=e,this.options=o,this.range=null,this.support=n,this.stack=new z(!0,1,t.ownerDocument,null);var r=new h(t,null);r.visibile=r.isElementVisible(),this.nodes=[r].concat(this.getChildren(r)).filter(function(t){return t.visible=t.isElementVisible()}),u("Fetched nodes"),this.images=i.fetch(this.nodes.filter(L)),u("Creating stacking contexts"),this.createStackingContexts(),u("Sorting stacking contexts"),this.sortStackingContexts(this.stack),this.images.ready.then(P(function(){u("Images loaded, starting parsing"),this.parse(this.stack),u("Finished rendering"),o.onrendered(e.canvas)},this))}function l(t,e,n,i){var o=4*((Math.sqrt(2)-1)/3),r=n*o,s=i*o,a=t+n,c=e+i;return{topLeft:g({x:t,y:c},{x:t,y:c-s},{x:a-r,y:e},{x:a,y:e}),topRight:g({x:t,y:e},{x:t+r,y:e},{x:a,y:c-s},{x:a,y:c}),bottomRight:g({x:a,y:e},{x:a,y:e+s},{x:t+r,y:c},{x:t,y:c}),bottomLeft:g({x:a,y:c},{x:a-r,y:c},{x:t,y:e+s},{x:t,y:e})}}function f(t,e,n){var i=t.left,o=t.top,r=t.width,s=t.height,a=e[0][0],c=e[0][1],u=e[1][0],h=e[1][1],p=e[2][0],d=e[2][1],f=e[3][0],g=e[3][1],m=r-u,y=s-d,w=r-p,v=s-g;return{topLeftOuter:l(i,o,a,c).topLeft.subdivide(.5),topLeftInner:l(i+n[3].width,o+n[0].width,Math.max(0,a-n[3].width),Math.max(0,c-n[0].width)).topLeft.subdivide(.5),topRightOuter:l(i+m,o,u,h).topRight.subdivide(.5),topRightInner:l(i+Math.min(m,r+n[3].width),o+n[0].width,m>r+n[3].width?0:u-n[3].width,h-n[0].width).topRight.subdivide(.5),bottomRightOuter:l(i+w,o+y,p,d).bottomRight.subdivide(.5),bottomRightInner:l(i+Math.min(w,r+n[3].width),o+Math.min(y,s+n[0].width),Math.max(0,p-n[1].width),Math.max(0,d-n[2].width)).bottomRight.subdivide(.5),bottomLeftOuter:l(i,o+v,f,g).bottomLeft.subdivide(.5),bottomLeftInner:l(i+n[3].width,o+v,Math.max(0,f-n[3].width),Math.max(0,g-n[2].width)).bottomLeft.subdivide(.5)}}function g(t,e,n,i){var o=function(t,e,n){return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n}};return{start:t,startControl:e,endControl:n,end:i,subdivide:function(r){var s=o(t,e,r),a=o(e,n,r),c=o(n,i,r),u=o(s,a,r),h=o(a,
|