diff --git a/build/html2canvas.js b/build/html2canvas.js index 3316a01..6b109ea 100644 --- a/build/html2canvas.js +++ b/build/html2canvas.js @@ -83,6 +83,7 @@ function html2canvas(el, userOptions) { this.needReorder = false; this.blockElements = new RegExp("(BR|PARAM)"); this.pageOrigin = window.location.protocol + window.location.host; + this.queue = []; this.ignoreRe = new RegExp("("+this.ignoreElements+")"); @@ -687,7 +688,9 @@ html2canvas.prototype.newElement = function(el,parentStack){ var cssPosition = this.getCSS(el,"position"); parentStack = parentStack || {}; - var zindex = this.formatZ(this.getCSS(el,"zIndex"),cssPosition,parentStack.zIndex,el.parentNode); + //var zindex = this.formatZ(this.getCSS(el,"zIndex"),cssPosition,parentStack.zIndex,el.parentNode); + + var zindex = this.setZ(this.getCSS(el,"zIndex"),cssPosition,parentStack.zIndex,el.parentNode); //console.log(el.nodeName+":"+zindex+":"+this.getCSS(el,"position")+":"+this.numDraws+":"+this.getCSS(el,"z-index")) @@ -700,6 +703,8 @@ html2canvas.prototype.newElement = function(el,parentStack){ opacity: opacity*parentStack.opacity, cssPosition: cssPosition }; + + // TODO correct overflow for absolute content residing under a static position if (parentStack.clip){ @@ -719,11 +724,16 @@ html2canvas.prototype.newElement = function(el,parentStack){ } - + /* var stackLength = this.contextStacks.push(stack); var ctx = this.contextStacks[stackLength-1].ctx; +*/ + var stackLength = zindex.children.push(stack); + + var ctx = zindex.children[stackLength-1].ctx; + this.setContextVariable(ctx,"globalAlpha",stack.opacity); // draw element borders @@ -837,8 +847,8 @@ html2canvas.prototype.newElement = function(el,parentStack){ - return this.contextStacks[stackLength-1]; - + // return this.contextStacks[stackLength-1]; + return zindex.children[stackLength-1]; } @@ -1315,10 +1325,15 @@ html2canvas.prototype.canvasRenderStorage = function(queue,parentctx){ } } + + html2canvas.prototype.canvasRenderer = function(queue){ var _ = this; + this.sortZ(this.zStack); + queue = this.queue; + //console.log(queue); - queue = this.sortQueue(queue); + //queue = this.sortQueue(queue); @@ -1835,13 +1850,80 @@ html2canvas.prototype.extendObj = function(options,defaults){ return defaults; } - +/* + *todo remove this function html2canvas.prototype.leadingZero = function(num,size){ var s = "000000000" + num; return s.substr(s.length-size); } +*/ + +html2canvas.prototype.zContext = function(zindex){ + return { + zindex: zindex, + children: [] + } +} + +html2canvas.prototype.setZ = function(zindex,position,parentZ,parentNode){ + // TODO fix static elements overlapping relative/absolute elements under same stack, if they are defined after them + if (!parentZ){ + this.zStack = new this.zContext(0); + return this.zStack; + } + + if (zindex!="auto"){ + this.needReorder = true; + var newContext = new this.zContext(zindex); + parentZ.children.push(newContext); + + return newContext; + + }else { + return parentZ; + } + +} + +html2canvas.prototype.sortZ = function(zStack){ + var subStacks = []; + var stackValues = []; + var _ = this; + + this.each(zStack.children, function(i,stackChild){ + if (stackChild.children && stackChild.children.length > 0){ + subStacks.push(stackChild); + stackValues.push(stackChild.zindex); + }else{ + _.queue.push(stackChild); + } + + }); + + + + stackValues.sort(function(a,b){return a - b}); + + this.each(stackValues, function(i,zValue){ + for (var s = 0;s<=subStacks.length;s++){ + if (subStacks[s].zindex == zValue){ + var stackChild = subStacks.splice(s,1); + _.sortZ(stackChild[0]); + break; + + } + } + + }); + + +} + +/* + *todo remove this function + html2canvas.prototype.formatZ = function(zindex,position,parentZ,parentNode){ if (!parentZ){ @@ -1859,9 +1941,9 @@ html2canvas.prototype.formatZ = function(zindex,position,parentZ,parentNode){ if (parentPosition!="static" && typeof parentPosition != "undefined"){ zindex = 0; } - /*else{ + else{ return parentZ; - }*/ + } } var b = this.leadingZero(this.numDraws,9); @@ -1875,6 +1957,9 @@ html2canvas.prototype.formatZ = function(zindex,position,parentZ,parentNode){ } + */ + + /* * Get element childNodes diff --git a/build/html2canvas.min.js b/build/html2canvas.min.js index cd30029..d15f5be 100644 --- a/build/html2canvas.min.js +++ b/build/html2canvas.min.js @@ -7,26 +7,26 @@ */ function html2canvas(a,b){this.opts=this.extendObj(b||{},{logging:!1,ready:function(a){document.body.appendChild(a.canvas)},storageReady:function(a){a.Renderer(a.contextStacks)},iframeDefault:"default",flashCanvasPath:"http://html2canvas.hertzen.com/external/flashcanvas/flashcanvas.js",renderViewport:!1,reorderZ:!0,throttle:!0,letterRendering:!1,proxyUrl:null,logger:function(a){window.console&&window.console.log?window.console.log(a):alert(a)},canvasWidth:0,canvasHeight:0,useOverflow:!0,renderOrder:"canvas flash html"}); -this.element=a;this.imagesLoaded=0;this.images=[];this.fontData=[];this.numDraws=0;this.contextStacks=[];this.ignoreElements="IFRAME|OBJECT|PARAM";this.needReorder=!1;this.blockElements=/(BR|PARAM)/;this.pageOrigin=window.location.protocol+window.location.host;this.ignoreRe=RegExp("("+this.ignoreElements+")");this.support={rangeBounds:!1};if(document.createRange){var c=document.createRange();if(c.getBoundingClientRect){var d=document.createElement("boundtest");d.style.height="123px";d.style.display= -"block";document.getElementsByTagName("body")[0].appendChild(d);c.selectNode(d);if(c.getBoundingClientRect().height==123)this.support.rangeBounds=!0;document.getElementsByTagName("body")[0].removeChild(d)}}this.init();return this} +this.element=a;this.imagesLoaded=0;this.images=[];this.fontData=[];this.numDraws=0;this.contextStacks=[];this.ignoreElements="IFRAME|OBJECT|PARAM";this.needReorder=!1;this.blockElements=/(BR|PARAM)/;this.pageOrigin=window.location.protocol+window.location.host;this.queue=[];this.ignoreRe=RegExp("("+this.ignoreElements+")");this.support={rangeBounds:!1};if(document.createRange){var c=document.createRange();if(c.getBoundingClientRect){var d=document.createElement("boundtest");d.style.height="123px"; +d.style.display="block";document.getElementsByTagName("body")[0].appendChild(d);c.selectNode(d);if(c.getBoundingClientRect().height==123)this.support.rangeBounds=!0;document.getElementsByTagName("body")[0].removeChild(d)}}this.init();return this} html2canvas.prototype.init=function(){var a=this;this.log("Finding background-images");this.images.push("start");this.getImages(this.element);this.log("Finding images");this.each(this.element.ownerDocument.images,function(b,c){a.preloadImage(a.getAttr(c,"src"))});this.images.splice(0,1);this.images.length==0&&this.start()}; html2canvas.prototype.start=function(){if(this.images.length==0||this.imagesLoaded==this.images.length/2){this.log("Finished loading "+this.imagesLoaded+" images, Started parsing");this.bodyOverflow=document.getElementsByTagName("body")[0].style.overflow;document.getElementsByTagName("body")[0].style.overflow="hidden";var a=new this.storageContext($(document).width(),$(document).height());a.opacity=this.getCSS(this.element,"opacity");this.parseElement(this.element,this.newElement(this.element,a))}}; html2canvas.prototype.stackingContext=function(a){this.canvas=document.createElement("canvas");this.canvas.width=a;this.canvas.height=a;if(this.canvas.getContext)this.ctx=this.canvas.getContext("2d");this.ctx.textBaseline="bottom";return this.ctx}; -html2canvas.prototype.storageContext=function(a,b){this.storage=[];this.width=a;this.height=b;this.fillRect=function(a,b,e,f){this.storage.push({type:"function",name:"fillRect",arguments:[a,b,e,f]})};this.drawImage=function(a,b,e,f,h,i,g,j,k){this.storage.push({type:"function",name:"drawImage",arguments:[a,b,e,f,h,i,g,j,k]})};this.fillText=function(a,b,e){this.storage.push({type:"function",name:"fillText",arguments:[a,b,e]})};return this}; +html2canvas.prototype.storageContext=function(a,b){this.storage=[];this.width=a;this.height=b;this.fillRect=function(a,b,e,f){this.storage.push({type:"function",name:"fillRect",arguments:[a,b,e,f]})};this.drawImage=function(a,b,e,f,g,i,h,j,l){this.storage.push({type:"function",name:"drawImage",arguments:[a,b,e,f,g,i,h,j,l]})};this.fillText=function(a,b,e){this.storage.push({type:"function",name:"fillText",arguments:[a,b,e]})};return this}; html2canvas.prototype.finish=function(){this.log("Finished rendering");document.getElementsByTagName("body")[0].style.overflow=this.bodyOverflow;this.opts.ready(this)}; html2canvas.prototype.drawBackground=function(a,b,c){var d=this.getCSS(a,"background-image"),e=this.getCSS(a,"background-repeat");if(typeof d!="undefined"&&/^(1|none)$/.test(d)==!1&&/^(-webkit|-moz|linear-gradient|-o-)/.test(d)==!1){var d=this.backgroundImageUrl(d),f=this.loadImage(d),a=this.getBackgroundPosition(a,b,f);if(f)switch(e){case "repeat-x":this.drawbackgroundRepeatX(c,f,a,b.left,b.top,b.width,b.height);break;case "repeat-y":this.drawbackgroundRepeatY(c,f,a,b.left,b.top,b.width,b.height); -break;case "no-repeat":var d=b.width-a.left,e=b.height-a.top,h=a.left,i=a.top,g=a.left+b.left,j=a.top+b.top;h<0?(h=Math.abs(h),g+=h,d=Math.min(b.width,f.width-h)):(d=Math.min(d,f.width),h=0);i<0?(i=Math.abs(i),j+=i,e=Math.min(b.height,f.height-i)):(e=Math.min(e,f.height),i=0);if(e>0&&d>0){this.drawImage(c,f,h,i,d,e,g,j,d,e);break}default:a.top-=Math.ceil(a.top/f.height)*f.height;for(d=b.top+a.top;de+d?e+d-d:f.height,d< -b.top?(h=b.top-d,d=b.top):h=0,this.drawbackgroundRepeatX(c,f,a,b.left,d,b.width,e),h>0&&(a.top+=h),d=Math.floor(d+f.height)-h}else this.log("Error loading background:"+d)}};html2canvas.prototype.backgroundImageUrl=function(a){a.substr(0,5)=='url("'?(a=a.substr(5),a=a.substr(0,a.length-2)):(a=a.substr(4),a=a.substr(0,a.length-1));return a}; +break;case "no-repeat":var d=b.width-a.left,e=b.height-a.top,g=a.left,i=a.top,h=a.left+b.left,j=a.top+b.top;g<0?(g=Math.abs(g),h+=g,d=Math.min(b.width,f.width-g)):(d=Math.min(d,f.width),g=0);i<0?(i=Math.abs(i),j+=i,e=Math.min(b.height,f.height-i)):(e=Math.min(e,f.height),i=0);if(e>0&&d>0){this.drawImage(c,f,g,i,d,e,h,j,d,e);break}default:a.top-=Math.ceil(a.top/f.height)*f.height;for(d=b.top+a.top;de+d?e+d-d:f.height,d< +b.top?(g=b.top-d,d=b.top):g=0,this.drawbackgroundRepeatX(c,f,a,b.left,d,b.width,e),g>0&&(a.top+=g),d=Math.floor(d+f.height)-g}else this.log("Error loading background:"+d)}};html2canvas.prototype.backgroundImageUrl=function(a){a.substr(0,5)=='url("'?(a=a.substr(5),a=a.substr(0,a.length-2)):(a=a.substr(4),a=a.substr(0,a.length-1));return a}; html2canvas.prototype.getBackgroundPosition=function(a,b,c){var d=(this.getCSS(a,"backgroundPosition")||"0 0").split(" "),e;d.length==1&&(a=d,d=[],d[0]=a,d[1]=a);d[0].toString().indexOf("%")!=-1?(e=parseFloat(d[0])/100,a=b.width*e-c.width*e):a=parseInt(d[0],10);d[1].toString().indexOf("%")!=-1?(e=parseFloat(d[1])/100,b=b.height*e-c.height*e):b=parseInt(d[1],10);c={};c.top=b;c.left=a;return c}; -html2canvas.prototype.drawbackgroundRepeatY=function(a,b,c,d,e,f,h){var i=Math.min(b.width,f),g;c.top-=Math.ceil(c.top/b.height)*b.height;for(g=e+c.top;gh+e?h+e-g:b.height,this.drawBackgroundRepeat(a,b,d+c.left,g,i,f,d,e),g=Math.floor(g+b.height)}; -html2canvas.prototype.drawbackgroundRepeatX=function(a,b,c,d,e,f,h){var h=Math.min(b.height,h),i,g;c.left-=Math.ceil(c.left/b.width)*b.width;for(g=d+c.left;gf+d?f+d-g:b.width,this.drawBackgroundRepeat(a,b,g,e+c.top,i,h,d,e),g=Math.floor(g+b.width)};html2canvas.prototype.drawBackgroundRepeat=function(a,b,c,d,e,f,h,i){var g=0,j=0;h-c>0&&(g=h-c);i-d>0&&(j=i-d);this.drawImage(a,b,g,j,e-g,f-j,c+g,d+j,e-g,f-j)}; +html2canvas.prototype.drawbackgroundRepeatY=function(a,b,c,d,e,f,g){var i=Math.min(b.width,f),h;c.top-=Math.ceil(c.top/b.height)*b.height;for(h=e+c.top;hg+e?g+e-h:b.height,this.drawBackgroundRepeat(a,b,d+c.left,h,i,f,d,e),h=Math.floor(h+b.height)}; +html2canvas.prototype.drawbackgroundRepeatX=function(a,b,c,d,e,f,g){var g=Math.min(b.height,g),i,h;c.left-=Math.ceil(c.left/b.width)*b.width;for(h=d+c.left;hf+d?f+d-h:b.width,this.drawBackgroundRepeat(a,b,h,e+c.top,i,g,d,e),h=Math.floor(h+b.width)};html2canvas.prototype.drawBackgroundRepeat=function(a,b,c,d,e,f,g,i){var h=0,j=0;g-c>0&&(h=g-c);i-d>0&&(j=i-d);this.drawImage(a,b,h,j,e-h,f-j,c+h,d+j,e-h,f-j)}; html2canvas.prototype.getBorderData=function(a){var b=[],c=this;this.each(["top","right","bottom","left"],function(d,e){b.push({width:parseInt(c.getCSS(a,"border-"+e+"-width"),10),color:c.getCSS(a,"border-"+e+"-color")})});return b}; -html2canvas.prototype.drawBorders=function(a,b,c,d){var e=c.left,f=c.top,h=c.width,i=c.height,g=this.getBorderData(a),j=this;this.each(g,function(a,c){if(c.width>0){var n=e,o=f,m=h,p=i-g[2].width;switch(a){case 0:p=g[0].width;break;case 1:n=e+h-g[1].width;m=g[1].width;break;case 2:o=o+i-g[2].width;p=g[2].width;break;case 3:m=g[3].width}m={left:n,top:o,width:m,height:p};d&&(m=j.clipBounds(m,d));m.width>0&&m.height>0&&j.newRect(b,n,o,m.width,m.height,c.color)}});return g}; -html2canvas.prototype.newElement=function(a,b){var c=this.getBounds(a),d=c.left,e=c.top,f=c.width,h=c.height,i;i=this.getCSS(a,"background-color");var g=this.getCSS(a,"position"),b=b||{},j=this.formatZ(this.getCSS(a,"zIndex"),g,b.zIndex,a.parentNode),k=this.getCSS(a,"opacity"),l={ctx:new this.storageContext,zIndex:j,opacity:k*b.opacity,cssPosition:g};if(b.clip)l.clip=$.extend({},b.clip),l.clip.height-=b.borders[2].width;if(this.opts.useOverflow&&/(hidden|scroll|auto)/.test(this.getCSS(a,"overflow"))&& -!/(BODY)/i.test(a.nodeName))l.clip=l.clip?this.clipBounds(l.clip,c):c;g=this.contextStacks.push(l);j=this.contextStacks[g-1].ctx;this.setContextVariable(j,"globalAlpha",l.opacity);k=this.drawBorders(a,j,c);l.borders=k;this.ignoreRe.test(a.nodeName)&&this.opts.iframeDefault!="transparent"&&(i=this.opts.iframeDefault=="default"?"#efefef":this.opts.iframeDefault);f={left:d+k[3].width,top:e+k[0].width,width:f-(k[1].width+k[3].width),height:h-(k[0].width+k[2].width)};l.clip&&(f=this.clipBounds(f,l.clip)); -f.height>0&&f.width>0&&(this.newRect(j,f.left,f.top,f.width,f.height,i),this.drawBackground(a,f,j));switch(a.nodeName){case "IMG":(i=this.loadImage(this.getAttr(a,"src")))?this.drawImage(j,i,0,0,i.width,i.height,d+parseInt(this.getCSS(a,"padding-left"),10)+k[3].width,e+parseInt(this.getCSS(a,"padding-top"),10)+k[0].width,c.width-(k[1].width+k[3].width+parseInt(this.getCSS(a,"padding-left"),10)+parseInt(this.getCSS(a,"padding-right"),10)),c.height-(k[0].width+k[2].width+parseInt(this.getCSS(a,"padding-top"), -10)+parseInt(this.getCSS(a,"padding-bottom"),10))):this.log("Error loading :"+this.getAttr(a,"src"));break;case "INPUT":/^(text|url|email|submit|button|reset)$/.test(a.type)&&a.value.length>0&&this.renderFormValue(a,c,l);break;case "TEXTAREA":a.value.length>0&&this.renderFormValue(a,c,l);break;case "SELECT":a.options.length>0&&this.renderFormValue(a,c,l)}return this.contextStacks[g-1]};html2canvas.prototype.printText=function(a,b,c,d){this.trim(a).length>0&&(d.fillText(a,b,c),this.numDraws++)}; -html2canvas.prototype.newRect=function(a,b,c,d,e,f){f!="transparent"&&(this.setContextVariable(a,"fillStyle",f),a.fillRect(b,c,d,e),this.numDraws++)};html2canvas.prototype.drawImage=function(a,b,c,d,e,f,h,i,g,j){a.drawImage(b,c,d,e,f,h,i,g,j);this.numDraws++}; +html2canvas.prototype.drawBorders=function(a,b,c,d){var e=c.left,f=c.top,g=c.width,i=c.height,h=this.getBorderData(a),j=this;this.each(h,function(a,c){if(c.width>0){var k=e,o=f,n=g,p=i-h[2].width;switch(a){case 0:p=h[0].width;break;case 1:k=e+g-h[1].width;n=h[1].width;break;case 2:o=o+i-h[2].width;p=h[2].width;break;case 3:n=h[3].width}n={left:k,top:o,width:n,height:p};d&&(n=j.clipBounds(n,d));n.width>0&&n.height>0&&j.newRect(b,k,o,n.width,n.height,c.color)}});return h}; +html2canvas.prototype.newElement=function(a,b){var c=this.getBounds(a),d=c.left,e=c.top,f=c.width,g=c.height,i;i=this.getCSS(a,"background-color");var h=this.getCSS(a,"position"),b=b||{},j=this.setZ(this.getCSS(a,"zIndex"),h,b.zIndex,a.parentNode),l=this.getCSS(a,"opacity"),m={ctx:new this.storageContext,zIndex:j,opacity:l*b.opacity,cssPosition:h};if(b.clip)m.clip=$.extend({},b.clip),m.clip.height-=b.borders[2].width;if(this.opts.useOverflow&&/(hidden|scroll|auto)/.test(this.getCSS(a,"overflow"))&& +!/(BODY)/i.test(a.nodeName))m.clip=m.clip?this.clipBounds(m.clip,c):c;h=j.children.push(m);l=j.children[h-1].ctx;this.setContextVariable(l,"globalAlpha",m.opacity);var k=this.drawBorders(a,l,c);m.borders=k;this.ignoreRe.test(a.nodeName)&&this.opts.iframeDefault!="transparent"&&(i=this.opts.iframeDefault=="default"?"#efefef":this.opts.iframeDefault);f={left:d+k[3].width,top:e+k[0].width,width:f-(k[1].width+k[3].width),height:g-(k[0].width+k[2].width)};m.clip&&(f=this.clipBounds(f,m.clip));f.height> +0&&f.width>0&&(this.newRect(l,f.left,f.top,f.width,f.height,i),this.drawBackground(a,f,l));switch(a.nodeName){case "IMG":(i=this.loadImage(this.getAttr(a,"src")))?this.drawImage(l,i,0,0,i.width,i.height,d+parseInt(this.getCSS(a,"padding-left"),10)+k[3].width,e+parseInt(this.getCSS(a,"padding-top"),10)+k[0].width,c.width-(k[1].width+k[3].width+parseInt(this.getCSS(a,"padding-left"),10)+parseInt(this.getCSS(a,"padding-right"),10)),c.height-(k[0].width+k[2].width+parseInt(this.getCSS(a,"padding-top"), +10)+parseInt(this.getCSS(a,"padding-bottom"),10))):this.log("Error loading :"+this.getAttr(a,"src"));break;case "INPUT":/^(text|url|email|submit|button|reset)$/.test(a.type)&&a.value.length>0&&this.renderFormValue(a,c,m);break;case "TEXTAREA":a.value.length>0&&this.renderFormValue(a,c,m);break;case "SELECT":a.options.length>0&&this.renderFormValue(a,c,m)}return j.children[h-1]};html2canvas.prototype.printText=function(a,b,c,d){this.trim(a).length>0&&(d.fillText(a,b,c),this.numDraws++)}; +html2canvas.prototype.newRect=function(a,b,c,d,e,f){f!="transparent"&&(this.setContextVariable(a,"fillStyle",f),a.fillRect(b,c,d,e),this.numDraws++)};html2canvas.prototype.drawImage=function(a,b,c,d,e,f,g,i,h,j){a.drawImage(b,c,d,e,f,g,i,h,j);this.numDraws++}; html2canvas.prototype.renderFormValue=function(a,b,c){var d=document.createElement("valuewrap"),e=this;this.each(["lineHeight","textAlign","fontFamily","color","fontSize","paddingLeft","paddingTop","width","height","border","borderLeftWidth","borderTopWidth"],function(b,c){d.style[c]=e.getCSS(a,c)});d.style.borderColor="black";d.style.borderStyle="solid";d.style.display="block";d.style.position="absolute";if(/^(submit|reset|button|text|password)$/.test(a.type)||a.nodeName=="SELECT")d.style.lineHeight= e.getCSS(a,"height");d.style.top=b.top+"px";d.style.left=b.left+"px";b=document.createTextNode(a.nodeName=="SELECT"?a.options[a.selectedIndex].text:a.value);d.appendChild(b);$("body").append(d);this.newText(a,b,c);$(d).remove()}; html2canvas.prototype.getImages=function(a){var b=this;this.ignoreRe.test(a.nodeName)||this.each($(a).contents(),function(a,d){RegExp("("+this.ignoreElements+")").test(d.nodeName)||b.getImages(d)});if(a.nodeType==1||typeof a.nodeType=="undefined")(a=this.getCSS(a,"background-image"))&&a!="1"&&a!="none"&&a.substring(0,7)!="-webkit"&&a.substring(0,3)!="-o-"&&a.substring(0,4)!="-moz"&&this.preloadImage(this.backgroundImageUrl(a))}; @@ -35,19 +35,19 @@ html2canvas.prototype.proxyGetImage=function(a,b){var c=this,d=document.createEl html2canvas.prototype.Renderer=function(a){var b=this;this.log("Renderer initiated");this.each(this.opts.renderOrder.split(" "),function(c,d){switch(d){case "canvas":b.canvas=document.createElement("canvas");if(b.canvas.getContext)return b.canvasRenderer(a),b.log("Using canvas renderer"),!1;break;case "html":return b.log("Using HTML renderer"),!1}});return this};html2canvas.prototype.throttler=function(){}; html2canvas.prototype.canvasRenderContext=function(a,b){b.textBaseline="bottom";var c=this;a.clip&&(b.save(),b.beginPath(),b.rect(a.clip.left,a.clip.top,a.clip.width,a.clip.height),b.clip());a.ctx.storage&&c.each(a.ctx.storage,function(a,e){switch(e.type){case "variable":b[e.name]=e.arguments;break;case "function":e.name=="fillRect"?b.fillRect(e.arguments[0],e.arguments[1],e.arguments[2],e.arguments[3]):e.name=="fillText"?b.fillText(e.arguments[0],e.arguments[1],e.arguments[2]):e.name=="drawImage"? e.arguments[8]>0&&e.arguments[7]&&b.drawImage(e.arguments[0],e.arguments[1],e.arguments[2],e.arguments[3],e.arguments[4],e.arguments[5],e.arguments[6],e.arguments[7],e.arguments[8]):c.log(e)}});a.clip&&b.restore()};html2canvas.prototype.canvasRenderStorage=function(a,b){for(;0e.zIndex.length;)e.zIndex+="0";for(e.zIndex+=c;b+f+c.toString().length>e.zIndex.length;)e.zIndex+="0";c++});return a=a.sort(function(a,b){return a.zIndexb.zIndex?1:0})}; html2canvas.prototype.setContextVariable=function(a,b,c){a.storage?a.storage.push({type:"variable",name:b,arguments:c}):a[b]=c}; -html2canvas.prototype.newText=function(a,b,c){var c=c.ctx,d=this.getCSS(a,"font-family"),e=this.getCSS(a,"font-size"),f=this.getCSS(a,"color"),h=this.getCSS(a,"font-weight"),i=this.getCSS(a,"font-style"),g=this.getCSS(a,"font-variant"),j=this.getCSS(a,"text-decoration"),k=this.getCSS(a,"text-align"),l=this.getCSS(a,"letter-spacing");b.nodeValue=this.textTransform(b.nodeValue,this.getCSS(a,"text-transform"));if(this.trim(b.nodeValue).length>0){switch(h){case 401:h="bold";break;case 400:h="normal"}if(j!= -"none")var n=this.fontMetrics(d,e);d=g+" "+h+" "+i+" "+e+" "+d;k=k.replace(["-webkit-auto"],["auto"]);a=this.opts.letterRendering==!1&&/^(left|right|justify|auto)$/.test(k)&&/^(normal|none)$/.test(l)?b.nodeValue.split(/(\b| )/):b.nodeValue.split("");this.setContextVariable(c,"fillStyle",f);this.setContextVariable(c,"font",d);for(k=0;k0){switch(g){case 401:g="bold";break;case 400:g="normal"}if(j!= +"none")var k=this.fontMetrics(d,e);d=h+" "+g+" "+i+" "+e+" "+d;l=l.replace(["-webkit-auto"],["auto"]);a=this.opts.letterRendering==!1&&/^(left|right|justify|auto)$/.test(l)&&/^(normal|none)$/.test(m)?b.nodeValue.split(/(\b| )/):b.nodeValue.split("");this.setContextVariable(c,"fillStyle",f);this.setContextVariable(c,"font",d);for(l=0;l-1)return this.fontData[c+1];c=document.createElement("div");document.getElementsByTagName("body")[0].appendChild(c);$(c).css({visibility:"hidden",fontFamily:a,fontSize:b,margin:0,padding:0});var d=document.createElement("img");d.src="http://html2canvas.hertzen.com/images/8.jpg";d.width=1;d.height=1;$(d).css({margin:0,padding:0});var e=document.createElement("span");$(e).css({fontFamily:a,fontSize:b,margin:0, padding:0});e.appendChild(document.createTextNode("Hidden Text"));c.appendChild(e);c.appendChild(d);var f=d.offsetTop-e.offsetTop+1;c.removeChild(e);c.appendChild(document.createTextNode("Hidden Text"));$(c).css("line-height","normal");$(d).css("vertical-align","super");d={baseline:f,lineWidth:1,middle:d.offsetTop-c.offsetTop+1};this.fontData.push(a+"-"+b);this.fontData.push(d);$(c).remove();return d}; html2canvas.prototype.textTransform=function(a,b){switch(b){case "lowercase":return a.toLowerCase();case "capitalize":return a.replace(/(^|\s|:|-|\(|\))([a-z])/g,function(a,b,e){return b+e.toUpperCase()});case "uppercase":return a.toUpperCase();default:return a}};html2canvas.prototype.trim=function(a){return a.replace(/^\s*/,"").replace(/\s*$/,"")}; html2canvas.prototype.parseElement=function(a,b){var c=this;this.each(a.children,function(a,e){c.parsing(e,b)});this.log("Render queue stored");this.opts.storageReady(this);this.finish()};html2canvas.prototype.parsing=function(a,b){if(this.getCSS(a,"display")!="none"&&this.getCSS(a,"visibility")!="hidden"){var c=this,b=this.newElement(a,b)||b;this.ignoreRe.test(a.nodeName)||this.each(this.contentsInZ(a),function(d,e){e.nodeType==1?c.parsing(e,b):e.nodeType==3&&c.newText(a,e,b)})}}; html2canvas.prototype.log=function(a){this.opts.logging&&this.opts.logger(a)};html2canvas.prototype.withinBounds=function(a,b){return!a?!0:(a.left<=b.left||b.left+b.width0?(b.push(f),c.push(f.zindex)):d.queue.push(f)});c.sort(function(a,b){return a-b});this.each(c,function(a,c){for(var g=0;g<=b.length;g++)if(b[g].zindex==c){g=b.splice(g,1);d.sortZ(g[0]);break}})};html2canvas.prototype.getContents=function(a){return a.nodeName=="iframe"?a.contentDocument||a.contentWindow.document:a.childNodes}; html2canvas.prototype.getCSS=function(a,b,c){return c?parseInt($(a).css(b),10):$(a).css(b)};html2canvas.prototype.getIndex=function(a,b){if(a.indexOf)return a.indexOf(b);else{for(var c=0;c - + - +