2014-09-28 00:03:57 +04:00
|
|
|
!function(a,b,c){function d(a,b,c,d){return k(a,a,c,d,b).then(function(f){A("Document cloned");var g="["+Kb+"='true']";a.querySelector(g).removeAttribute(Kb);var h=f.contentWindow,i=h.document.querySelector(g);return e(i,f,b,c,d)})}function e(a,c,d,e,j){var k=c.contentWindow,l=new Ab(k.document),m=new y(d,l),n=I(a),o=null!=d.width?d.width:"view"===d.type?Math.min(n.width,e):h(k.document),p=null!=d.height?d.height:"view"===d.type?Math.min(n.height,j):i(k.document),q=new Ib(o,p,m,d,b),r=new K(a,q,l,m,d);return r.ready.then(function(){A("Finished rendering");var b="view"===d.type||a!==k.document.body&&a!==k.document.documentElement?g(q.canvas,{width:o,height:p,top:n.top,left:n.left}):q.canvas;return f(c,d),b})}function f(a,b){b.removeContainer&&(a.parentNode.removeChild(a),A("Cleaned up container"))}function g(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 A("Cropping canvas at:","left:",c.left,"top:",c.top,"width:",c.width,"height:",c.height),A("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 h(a){return Math.max(Math.max(a.body.scrollWidth,a.documentElement.scrollWidth),Math.max(a.body.offsetWidth,a.documentElement.offsetWidth),Math.max(a.body.clientWidth,a.documentElement.clientWidth))}function i(a){return Math.max(Math.max(a.body.scrollHeight,a.documentElement.scrollHeight),Math.max(a.body.offsetHeight,a.documentElement.offsetHeight),Math.max(a.body.clientHeight,a.documentElement.clientHeight))}function j(){return"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}function k(b,c,d,e,f){n(b);var g=b.documentElement.cloneNode(!0),h=c.createElement("iframe");return h.style.visibility="hidden",h.style.position="absolute",h.style.left=h.style.top="-10000px",h.width=d,h.height=e,h.scrolling="no",c.body.appendChild(h),new Promise(function(c){var d=h.contentWindow.document;h.contentWindow.onload=h.onload=function(){var a=setInterval(function(){d.body.childNodes.length>0&&(o(b,d),clearInterval(a),c(h))},50)},d.open(),d.write("<!DOCTYPE html>"),d.close(),d.replaceChild(f.javascriptEnabled===!0?d.adoptNode(g):p(d.adoptNode(g)),d.documentElement),"view"===f.type&&h.contentWindow.scrollTo(a.pageXOffset,a.pageYOffset)})}function l(b,c,d,e,f,g){return new sb(b,c,a.document).then(m(b)).then(function(a){return k(a,d,e,f,g)})}function m(a){return function(b){var c=new DOMParser,d=c.parseFromString(b,"text/html"),e=d.querySelector("base");if(!e||!e.href.host){var f=d.createElement("base");f.href=a,d.head.insertBefore(f,d.head.firstChild)}return d}}function n(a){[].slice.call(a.querySelectorAll("canvas"),0).forEach(function(a){a.setAttribute(Lb,"canvas-"+Mb++)})}function o(a,b){[].slice.call(a.querySelectorAll("["+Lb+"]"),0).forEach(function(a){try{var c=b.querySelector("["+Lb+'="'+a.getAttribute(Lb)+'"]');c&&(c.width=a.width,c.height=a.height,c.getContext("2d").putImageData(a.getContext("2d").getImageData(0,0,a.width,a.height),0,0))}catch(d){A("Unable to copy canvas content from",a,d)}a.removeAttribute(Lb)})}function p(a){return[].slice.call(a.childNodes,0).filter(q).forEach(function(b){"SCRIPT"===b.tagName?a.removeChild(b):p(b)}),a}function q(a){return a.nodeType===Node.ELEMENT_NODE}function r(a){var c=b.createElement("a");return c.href=a,c.href=c.href,c}function s(a){if(this.src=a,A("DummyImageContainer for",a),!this.promise||!this.image){A("Initiating DummyImageContainer"),s.prototype.image=new Image;var b=this.image;s.prototype.promise=new Promise(function(a,c){b.onload=a,b.onerror=c,b.src=j(),b.complete===!0&&a(b)})}}function t(a,c){var d,e,f=b.createElement("div"),g=b.createElement("img"),h=b.createElement("span"),i="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=j(),g.width=1,g.height=1,g.style.margin=0,g.style.padding=0,g.style.ve
|
|
|
|
},B.prototype.parseBackgroundRepeat=function(a){return this.cssList("backgroundRepeat",a)[0]},B.prototype.parseTextShadows=function(){var a=this.css("textShadow"),b=[];if(a&&"none"!==a)for(var c=a.match(this.TEXT_SHADOW_PROPERTY),d=0;c&&d<c.length;d++){var e=c[d].match(this.TEXT_SHADOW_VALUES);b.push({color:e[0],offsetX:e[1]?e[1].replace("px",""):0,offsetY:e[2]?e[2].replace("px",""):0,blur:e[3]?e[3].replace("px",""):0})}return b},B.prototype.parseTransform=function(){if(!this.transformData)if(this.hasTransform()){var a=this.parseBounds(),b=this.prefixedCss("transformOrigin").split(" ").map(G).map(H);b[0]+=a.left,b[1]+=a.top,this.transformData={origin:b,matrix:this.parseTransformMatrix()}}else this.transformData={origin:[0,0],matrix:[1,0,0,1,0,0]};return this.transformData},B.prototype.parseTransformMatrix=function(){if(!this.transformMatrix){var a=this.prefixedCss("transform"),b=a?D(a.match(this.MATRIX_PROPERTY)):null;this.transformMatrix=b?b:[1,0,0,1,0,0]}return this.transformMatrix},B.prototype.parseBounds=function(){return this.bounds||(this.bounds=this.hasTransform()?J(this.node):I(this.node))},B.prototype.hasTransform=function(){return"1,0,0,1,0,0"!==this.parseTransformMatrix().join(",")||this.parent&&this.parent.hasTransform()},B.prototype.getValue=function(){var a=this.node.value||"";return a="SELECT"===this.node.tagName?C(this.node):a,0===a.length?this.node.placeholder||"":a},B.prototype.MATRIX_PROPERTY=/(matrix)\((.+)\)/,B.prototype.TEXT_SHADOW_PROPERTY=/((rgba|rgb)\([^\)]+\)(\s-?\d+px){0,})/g,B.prototype.TEXT_SHADOW_VALUES=/(-?\d+px)|(#.+)|(rgb\(.+\))|(rgba\(.+\))/g,K.prototype.calculateOverflowClips=function(){this.nodes.forEach(function(a){if(fb(a)){a.borders=this.parseBorders(a);var b="hidden"===a.css("overflow")?[a.borders.clip]:[];a.clip=L(a)?a.parent.clip.concat(b):b,a.backgroundClip="hidden"!==a.css("overflow")?a.clip.concat([a.borders.clip]):a.clip}else gb(a)&&(a.clip=L(a)?a.parent.clip:[]);a.bounds=null},this)},K.prototype.asyncRenderer=function(a,b,c){c=c||Date.now(),this.paint(a[this.renderIndex++]),a.length===this.renderIndex?b():c+20>Date.now()?this.asyncRenderer(a,b,c):setTimeout(jb(function(){this.asyncRenderer(a,b)},this),0)},K.prototype.createPseudoHideStyles=function(a){var b=a.createElement("style");b.innerHTML="."+this.pseudoHideClass+':before { content: "" !important; display: none !important; }.'+this.pseudoHideClass+':after { content: "" !important; display: none !important; }',a.body.appendChild(b)},K.prototype.getPseudoElements=function(a){var b=[[a]];if(a.node.nodeType===Node.ELEMENT_NODE){var c=this.getPseudoElement(a,":before"),d=this.getPseudoElement(a,":after");c&&(a.node.insertBefore(c[0].node,a.node.firstChild),b.push(c)),d&&(a.node.appendChild(d[0].node),b.push(d)),(c||d)&&(a.node.className+=" "+this.pseudoHideClass)}return nb(b)},K.prototype.getPseudoElement=function(a,c){var d=a.computedStyle(c);if(!d||!d.content||"none"===d.content||"-moz-alt-content"===d.content||"none"===d.display)return null;for(var e=ob(d.content),f="url"===e.substr(0,3),g=b.createElement(f?"img":"html2canvaspseudoelement"),h=new B(g,a),i=d.length-1;i>=0;i--){var j=M(d.item(i));g.style[j]=d[j]}if(g.className=this.pseudoHideClass,f)return g.src=F(e)[0].args[0],[h];var k=b.createTextNode(e);return g.appendChild(k),[h,new Eb(k,h)]},K.prototype.getChildren=function(a){return nb([].filter.call(a.node.childNodes,_).map(function(b){var c=[b.nodeType===Node.TEXT_NODE?new Eb(b,a):new B(b,a)].filter(mb);return b.nodeType===Node.ELEMENT_NODE&&c.length&&"TEXTAREA"!==b.tagName?c[0].isElementVisible()?c.concat(this.getChildren(c[0])):[]:c},this))},K.prototype.newStackingContext=function(a,b){var c=new zb(b,a.cssFloat("opacity"),a.node,a.parent);c.visible=a.visible,c.borders=a.borders,c.bounds=a.bounds,c.clip=a.clip,c.backgroundClip=a.backgroundClip;var d=b?c.getParentStack(this):c.parent.stack;d.contexts.push(c),a.stack=c},K.prototype.createStackingContexts=function(){this.nodes.forEach(function(a){fb(a)&&(this.isRootElement(a)||ib(a)||ab(a)||this.isBodyWithTransparentRoot(a)||a.hasTransform())?this.newStackingContext
|