2014-09-16 21:12:13 +04:00
|
|
|
!function(a,b,c){function d(a,b,c,d){return i(a,c,d,b).then(function(h){t("Document cloned");var i="["+wb+"='true']";a.querySelector(i).removeAttribute(wb);var j=h.contentWindow,k=j.document.querySelector(i),l=new nb(j.document),m=new r(b,l),n=B(k),o=null!=b.width?b.width:"view"===b.type?Math.min(n.width,c):f(),p=null!=b.height?b.height:"view"===b.type?Math.min(n.height,d):g(),q=new vb(o,p,m,b,a),s=new D(k,q,l,m,b);return s.ready.then(function(){t("Finished rendering");var a="view"===b.type||k!==j.document.body&&k!==j.document.documentElement?e(q.canvas,n):q.canvas;return b.removeContainer&&(h.parentNode.removeChild(h),t("Cleaned up container")),a})})}function e(a,c){var d=b.createElement("canvas"),e=Math.min(a.width-1,Math.max(0,c.left)),f=Math.min(a.width,Math.max(1,c.left+c.width)),g=Math.min(a.height-1,Math.max(0,c.top)),h=Math.min(a.height,Math.max(1,c.top+c.height)),i=d.width=f-e,j=d.height=h-g;return t("Cropping canvas at:","left:",c.left,"top:",c.top,"width:",c.width,"height:",c.height),t("Resulting crop with width",i,"and height",j," with x",e,"and y",g),d.getContext("2d").drawImage(a,e,g,i,j,0,0,i,j),d}function f(){return Math.max(Math.max(b.body.scrollWidth,b.documentElement.scrollWidth),Math.max(b.body.offsetWidth,b.documentElement.offsetWidth),Math.max(b.body.clientWidth,b.documentElement.clientWidth))}function g(){return Math.max(Math.max(b.body.scrollHeight,b.documentElement.scrollHeight),Math.max(b.body.offsetHeight,b.documentElement.offsetHeight),Math.max(b.body.clientHeight,b.documentElement.clientHeight))}function h(){return"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}function i(b,c,d,e){var f=b.documentElement.cloneNode(!0),g=b.createElement("iframe");return g.style.visibility="hidden",g.style.position="absolute",g.style.left=g.style.top="-10000px",g.width=c,g.height=d,g.scrolling="no",b.body.appendChild(g),new Promise(function(b){var c=g.contentWindow.document;g.contentWindow.onload=g.onload=function(){b(g)},c.open(),c.write("<!DOCTYPE html>"),c.close(),c.replaceChild(j(c.adoptNode(f)),c.documentElement),"view"===e.type&&g.contentWindow.scrollTo(a.pageXOffset,a.pageYOffset)})}function j(a){return[].slice.call(a.childNodes,0).filter(k).forEach(function(b){"SCRIPT"===b.tagName?a.removeChild(b):j(b)}),a}function k(a){return a.nodeType===Node.ELEMENT_NODE}function l(a){if(this.src=a,t("DummyImageContainer for",a),!this.promise||!this.image){t("Initiating DummyImageContainer"),l.prototype.image=new Image;var b=this.image;l.prototype.promise=new Promise(function(a,c){b.onload=a,b.onerror=c,b.src=h(),b.complete===!0&&a(b)})}}function m(a,c){var d,e,f=b.createElement("div"),g=b.createElement("img"),i=b.createElement("span"),j="Hidden Text";f.style.visibility="hidden",f.style.fontFamily=a,f.style.fontSize=c,f.style.margin=0,f.style.padding=0,b.body.appendChild(f),g.src=h(),g.width=1,g.height=1,g.style.margin=0,g.style.padding=0,g.style.verticalAlign="baseline",i.style.fontFamily=a,i.style.fontSize=c,i.style.margin=0,i.style.padding=0,i.appendChild(b.createTextNode(j)),f.appendChild(i),f.appendChild(g),d=g.offsetTop-i.offsetTop+1,f.removeChild(i),f.appendChild(b.createTextNode(j)),f.style.lineHeight="normal",g.style.verticalAlign="super",e=g.offsetTop-f.offsetTop+1,b.body.removeChild(f),this.baseline=d,this.lineWidth=1,this.middle=e}function n(){this.data={}}function o(a){this.image=null,this.src=a;var b=this,c=B(a);this.promise=new Promise(function(b){"about:blank"===a.contentWindow.document.URL||null==a.contentWindow.document.documentElement?a.contentWindow.onload=a.onload=function(){b(a)}:b(a)}).then(function(a){return html2canvas(a.contentWindow.document.documentElement,{width:c.width,height:c.height})}).then(function(a){return b.image=a})}function p(a){this.src=a.value,this.colorStops=[],this.type=null,this.x0=.5,this.y0=.5,this.x1=.5,this.y1=.5,this.promise=Promise.resolve(!0)}function q(a,b){this.src=a,this.image=new Image;var c=this;this.tainted=null,this.promise=new Promise(function(d,e){c.image.onload=d,c.image.onerror=e,b&&(c.image.crossOrigin="anonymous"),c.imag
|
|
|
|
g.style[j]=d[j]}if(g.className=this.pseudoHideClass,f)return g.src=y(e)[0].args[0],[h];var k=b.createTextNode(e);return g.appendChild(k),[h,new rb(k,h)]},D.prototype.getChildren=function(a){return fb([].filter.call(a.node.childNodes,T).map(function(b){var c=[b.nodeType===Node.TEXT_NODE?new rb(b,a):new u(b,a)].filter(eb);return b.nodeType===Node.ELEMENT_NODE&&c.length&&"TEXTAREA"!==b.tagName?c[0].isElementVisible()?c.concat(this.getChildren(c[0])):[]:c},this))},D.prototype.newStackingContext=function(a,b){var c=new mb(b,a.cssFloat("opacity"),a.node,a.parent);c.visible=a.visible;var d=b?c.getParentStack(this):c.parent.stack;d.contexts.push(c),a.stack=c},D.prototype.createStackingContexts=function(){this.nodes.forEach(function(a){Z(a)&&(this.isRootElement(a)||ab(a)||U(a)||this.isBodyWithTransparentRoot(a)||a.hasTransform())?this.newStackingContext(a,!0):Z(a)&&(V(a)&&N(a)||X(a)||W(a))?this.newStackingContext(a,!1):a.assignStack(a.parent.stack)},this)},D.prototype.isBodyWithTransparentRoot=function(a){return"BODY"===a.node.nodeName&&this.renderer.isTransparent(a.parent.css("backgroundColor"))},D.prototype.isRootElement=function(a){return null===a.parent},D.prototype.sortStackingContexts=function(a){a.contexts.sort(_),a.contexts.forEach(this.sortStackingContexts,this)},D.prototype.parseTextBounds=function(a){return function(b,c,d){if("none"!==a.parent.css("textDecoration").substr(0,4)||0!==b.trim().length){if(this.support.rangeBounds&&!a.parent.hasTransform()){var e=d.slice(0,c).join("").length;return this.getRangeBounds(a.node,e,b.length)}if(a.node&&"string"==typeof a.node.data){var f=a.node.splitText(b.length),g=this.getWrapperBounds(a.node,a.parent.hasTransform());return a.node=f,g}}else(!this.support.rangeBounds||a.parent.hasTransform())&&(a.node=a.node.splitText(b.length));return{}}},D.prototype.getWrapperBounds=function(a,b){var c=a.ownerDocument.createElement("html2canvaswrapper"),d=a.parentNode,e=a.cloneNode(!0);c.appendChild(a.cloneNode(!0)),d.replaceChild(c,a);var f=b?C(c):B(c);return d.replaceChild(e,c),f},D.prototype.getRangeBounds=function(a,b,c){var d=this.range||(this.range=a.ownerDocument.createRange());return d.setStart(a,b),d.setEnd(a,b+c),d.getBoundingClientRect()},D.prototype.parse=function(a){var b=a.contexts.filter(L),c=a.children.filter(Z),d=c.filter(Y(W)),e=d.filter(Y(V)).filter(Y(O)),f=c.filter(Y(V)).filter(W),g=d.filter(Y(V)).filter(O),h=a.contexts.concat(d.filter(V)).filter(N),i=a.children.filter($).filter(Q),j=a.contexts.filter(M);b.concat(e).concat(f).concat(g).concat(h).concat(i).concat(j).forEach(function(a){this.renderQueue.push(a),P(a)&&(this.parse(a),this.renderQueue.push(new F))},this)},D.prototype.paint=function(a){try{a instanceof F?this.renderer.ctx.restore():$(a)?this.paintText(a):this.paintNode(a)}catch(b){t(b)}},D.prototype.paintNode=function(a){P(a)&&(this.renderer.setOpacity(a.opacity),this.renderer.ctx.save(),a.hasTransform()&&this.renderer.setTransform(a.parseTransform()));var b=a.parseBounds(),c=this.parseBorders(a);switch(this.renderer.clip(c.clip,function(){this.renderer.renderBackground(a,b,c.borders.map(db))},this),this.renderer.renderBorders(c.borders),a.node.nodeName){case"svg":case"IFRAME":var d=this.images.get(a.node);d?this.renderer.renderImage(a,b,c,d):t("Error loading <"+a.node.nodeName+">",a.node);break;case"IMG":var e=this.images.get(a.node.src);e?this.renderer.renderImage(a,b,c,e):t("Error loading <img>",a.node.src);break;case"SELECT":case"INPUT":case"TEXTAREA":this.paintFormValue(a)}},D.prototype.paintFormValue=function(a){if(a.getValue().length>0){var b=a.node.ownerDocument,c=b.createElement("html2canvaswrapper"),d=["lineHeight","textAlign","fontFamily","fontWeight","fontSize","color","paddingLeft","paddingTop","paddingRight","paddingBottom","width","height","borderLeftStyle","borderTopStyle","borderLeftWidth","borderTopWidth","boxSizing","whiteSpace","wordWrap"];d.forEach(function(b){try{c.style[b]=a.css(b)}catch(d){t("html2canvas: Parse: Exception caught in renderFormValue: "+d.message)}});var e=a.parseBounds();c.style.position="absolute",c.style.left=e.left+"px"
|