html2canvas/build/html2canvas.min.js

7 lines
12 KiB
JavaScript
Raw Normal View History

2013-09-07 22:24:41 +04:00
/*
2014-01-19 20:04:27 +04:00
html2canvas 0.5.0-rc1 <http://html2canvas.hertzen.com>
Copyright (c) 2014 Niklas von Hertzen
2013-09-07 22:24:41 +04:00
Released under MIT License
*/
2014-01-19 20:04:27 +04:00
(function(t,e,n){function o(t,e,n){var o=t.documentElement.cloneNode(!0),r=t.createElement("iframe");r.style.display="hidden",r.style.position="absolute",r.style.width=e+"px",r.style.height=n+"px",t.body.appendChild(r);var i=r.contentWindow.document;return i.replaceChild(i.adoptNode(o),i.documentElement),r}function r(t,e,n){this.renderer=e,this.options=n,this.support=new S,this.range=null,this.stack=new StackingContext(!0,1,t.ownerDocument,null);var o=new NodeContainer(t,null);o.blockFormattingContext=o,this.nodes=[o].concat(this.getChildren(o)).filter(function(t){return t.visible=t.isElementVisible()}),this.createStackingContexts(),this.sortStackingContexts(this.stack),this.parse(this.stack)}function i(t){return 0>t.cssInt("zIndex")}function s(t){return t.cssInt("zIndex")>0}function c(t){return 0===t.cssInt("zIndex")}function a(t){return-1!==["inline","inline-block","inline-table"].indexOf(t.css("display"))}function h(t){return t instanceof StackingContext}function d(t){return t.node.data.trim().length>0}function p(t){return/^(normal|none|0px)$/.test(t.parent.css("letterSpacing"))}function u(t,e,n,o,r,i,s){e[0]>0||e[1]>0?(t.push(["line",o[0].start.x,o[0].start.y]),o[0].curveTo(t),o[1].curveTo(t)):t.push(["line",i,s]),(n[0]>0||n[1]>0)&&t.push(["line",r[0].start.x,r[0].start.y])}function l(t){return["TopLeft","TopRight","BottomRight","BottomLeft"].map(function(e){var n=t.css("border"+e+"Radius"),o=n.split(" ");return 1>=o.length&&(o[1]=o[0]),o.map(f)})}function f(t){return parseInt(t,10)}function g(t,e,n,o){var r=4*((Math.sqrt(2)-1)/3),i=n*r,s=o*r,c=t+n,a=e+o;return{topLeft:x({x:t,y:a},{x:t,y:a-s},{x:c-i,y:e},{x:c,y:e}),topRight:x({x:t,y:e},{x:t+i,y:e},{x:c,y:a-s},{x:c,y:a}),bottomRight:x({x:c,y:e},{x:c,y:e+s},{x:t+i,y:a},{x:t,y:a}),bottomLeft:x({x:c,y:a},{x:c-i,y:a},{x:t,y:e+s},{x:t,y:e})}}function y(t,e,n){var o=t.left,r=t.top,i=t.width,s=t.height,c=e[0][0],a=e[0][1],h=e[1][0],d=e[1][1],p=e[2][0],u=e[2][1],l=e[3][0],f=e[3][1],y=i-h,x=s-u,m=i-p,w=s-f;return{topLeftOuter:g(o,r,c,a).topLeft.subdivide(.5),topLeftInner:g(o+n[3].width,r+n[0].width,Math.max(0,c-n[3].width),Math.max(0,a-n[0].width)).topLeft.subdivide(.5),topRightOuter:g(o+y,r,h,d).topRight.subdivide(.5),topRightInner:g(o+Math.min(y,i+n[3].width),r+n[0].width,y>i+n[3].width?0:h-n[3].width,d-n[0].width).topRight.subdivide(.5),bottomRightOuter:g(o+m,r+x,p,u).bottomRight.subdivide(.5),bottomRightInner:g(o+Math.min(m,i+n[3].width),r+Math.min(x,s+n[0].width),Math.max(0,p-n[1].width),Math.max(0,u-n[2].width)).bottomRight.subdivide(.5),bottomLeftOuter:g(o,r+w,l,f).bottomLeft.subdivide(.5),bottomLeftInner:g(o+n[3].width,r+w,Math.max(0,l-n[3].width),Math.max(0,f-n[2].width)).bottomLeft.subdivide(.5)}}function x(t,e,n,o){var r=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:o,subdivide:function(i){var s=r(t,e,i),c=r(e,n,i),a=r(n,o,i),h=r(s,c,i),d=r(c,a,i),p=r(h,d,i);return[x(t,s,h,p),x(p,d,a,o)]},curveTo:function(t){t.push(["bezierCurve",e.x,e.y,n.x,n.y,o.x,o.y])},curveToReversed:function(o){o.push(["bezierCurve",n.x,n.y,e.x,e.y,t.x,t.y])}}}function m(t,e,n,o,r,i,s){var c=[];return e[0]>0||e[1]>0?(c.push(["line",o[1].start.x,o[1].start.y]),o[1].curveTo(c)):c.push(["line",t.c1[0],t.c1[1]]),n[0]>0||n[1]>0?(c.push(["line",i[0].start.x,i[0].start.y]),i[0].curveTo(c),c.push(["line",s[0].end.x,s[0].end.y]),s[0].curveToReversed(c)):(c.push(["line",t.c2[0],t.c2[1]]),c.push(["line",t.c3[0],t.c3[1]])),e[0]>0||e[1]>0?(c.push(["line",r[1].end.x,r[1].end.y]),r[1].curveToReversed(c)):c.push(["line",t.c4[0],t.c4[1]]),c}function w(t){return t.node.nodeType!==Node.ELEMENT_NODE||-1===["SCRIPT","HEAD","TITLE","OBJECT","BR"].indexOf(t.node.nodeName)}function b(t){return[].concat.apply([],t)}function v(t){return t.nodeType===Node.TEXT_NODE||t.nodeType===Node.ELEMENT_NODE}function R(t){var e=t.css("position"),n="absolute"===e||"relative"===e?t.css("zIndex"):"auto";return"auto"!==n}function T(t){return"static"!==t.css("position")}function C(t){return"none"!==t.css("float")}function E(t){var e=this;return function(){return!t.apply(e,ar