diff --git a/build/html2canvas.js b/build/html2canvas.js index 10fe0a0..895b811 100644 --- a/build/html2canvas.js +++ b/build/html2canvas.js @@ -57,7 +57,6 @@ _html2canvas.Util.asFloat = function(v) { }; })(); - _html2canvas.Util.parseBackgroundImage = function (value) { var whitespace = ' \r\n\t', method, definition, prefix, prefix_i, block, results = [], @@ -231,6 +230,10 @@ function asInt(val) { return parseInt(val, 10); } +function isPercentage(value) { + return value.toString().indexOf("%") !== -1; +} + function parseBackgroundSizePosition(value, element, attribute, index) { value = (value || '').split(','); value = value[index || 0] || value[0] || 'auto'; @@ -303,7 +306,7 @@ _html2canvas.Util.BackgroundPosition = function(element, bounds, image, imageInd backgroundPosition = [backgroundPosition[0], backgroundPosition[0]]; } - if (backgroundPosition[0].toString().indexOf("%") !== -1){ + if (isPercentage(backgroundPosition[0])){ leftPosition = (bounds.width - (backgroundSize || image).width) * (parseFloat(backgroundPosition[0]) / 100); } else { leftPosition = parseInt(backgroundPosition[0], 10); @@ -311,7 +314,7 @@ _html2canvas.Util.BackgroundPosition = function(element, bounds, image, imageInd if (backgroundPosition[1] === 'auto') { topPosition = leftPosition / image.width * image.height; - } else if (backgroundPosition[1].toString().indexOf("%") !== -1){ + } else if (isPercentage(backgroundPosition[1])){ topPosition = (bounds.height - (backgroundSize || image).height) * parseFloat(backgroundPosition[1]) / 100; } else { topPosition = parseInt(backgroundPosition[1], 10); @@ -325,41 +328,40 @@ _html2canvas.Util.BackgroundPosition = function(element, bounds, image, imageInd }; _html2canvas.Util.BackgroundSize = function(element, bounds, image, imageIndex) { - var backgroundSize = _html2canvas.Util.getCSS(element, 'backgroundSize', imageIndex), - width, - height; + var backgroundSize = _html2canvas.Util.getCSS(element, 'backgroundSize', imageIndex), width, height; - if (backgroundSize.length === 1){ - backgroundSize = [backgroundSize[0], backgroundSize[0]]; - } + if (backgroundSize.length === 1) { + backgroundSize = [backgroundSize[0], backgroundSize[0]]; + } - if (backgroundSize[0].toString().indexOf("%") !== -1){ - width = bounds.width * parseFloat(backgroundSize[0]) / 100; - } else if(backgroundSize[0] === 'auto') { - width = image.width; - } else { - if (/contain|cover/.test(backgroundSize[0])) { - var resized = _html2canvas.Util.resizeBounds(image.width, image.height, bounds.width, bounds.height, backgroundSize[0]); - return {width: resized.width, height: resized.height}; - } else { - width = parseInt(backgroundSize[0], 10); - } - } + if (isPercentage(backgroundSize[0])) { + width = bounds.width * parseFloat(backgroundSize[0]) / 100; + } else if (/contain|cover/.test(backgroundSize[0])) { + return _html2canvas.Util.resizeBounds(image.width, image.height, bounds.width, bounds.height, backgroundSize[0]); + } else { + width = parseInt(backgroundSize[0], 10); + } - if(backgroundSize[1] === 'auto') { - height = width / image.width * image.height; - } else if (backgroundSize[1].toString().indexOf("%") !== -1){ - height = bounds.height * parseFloat(backgroundSize[1]) / 100; - } else { - height = parseInt(backgroundSize[1],10); - } + if (backgroundSize[0] === 'auto' && backgroundSize[1] === 'auto') { + height = image.height; + } else if (backgroundSize[1] === 'auto') { + height = width / image.width * image.height; + } else if (isPercentage(backgroundSize[1])) { + height = bounds.height * parseFloat(backgroundSize[1]) / 100; + } else { + height = parseInt(backgroundSize[1], 10); + } + if (backgroundSize[0] === 'auto') { + width = height / image.height * image.width; + } - if (backgroundSize[0] === 'auto') { - width = height / image.height * image.width; - } + return {width: width, height: height}; +}; - return {width: width, height: height}; +_html2canvas.Util.BackgroundRepeat = function(element, imageIndex) { + var backgroundRepeat = _html2canvas.Util.getCSS(element, "backgroundRepeat").split(",").map(_html2canvas.Util.trimText); + return backgroundRepeat[imageIndex] || backgroundRepeat[0]; }; _html2canvas.Util.Extend = function (options, defaults) { @@ -416,6 +418,7 @@ _html2canvas.Util.Children = function( elem ) { _html2canvas.Util.isTransparent = function(backgroundColor) { return (!backgroundColor || backgroundColor === "transparent" || backgroundColor === "rgba(0, 0, 0, 0)"); }; + _html2canvas.Util.Font = (function () { var fontData = {}; @@ -1042,7 +1045,7 @@ _html2canvas.Parse = function (images, options, cb) { pseudoHide = "___html2canvas___pseudoelement", hidePseudoElementsStyles = doc.createElement('style'); - hidePseudoElementsStyles.innerHTML = '.' + pseudoHide + + hidePseudoElementsStyles.innerHTML = '.' + pseudoHide + '-parent:before { content: "" !important; display: none !important; }' + '.' + pseudoHide + '-parent:after { content: "" !important; display: none !important; }'; @@ -1059,7 +1062,7 @@ _html2canvas.Parse = function (images, options, cb) { // create pseudo elements in a single pass to prevent synchronous layouts addPseudoElements(element); - + parseChildren(element, stack, function() { if (transparentBackground) { background = stack.backgroundColor; @@ -1076,8 +1079,8 @@ _html2canvas.Parse = function (images, options, cb) { }); } - // Given a root element, find all pseudo elements below, create elements mocking pseudo element styles - // so we can process them as normal elements, and hide the original pseudo elements so they don't interfere + // Given a root element, find all pseudo elements below, create elements mocking pseudo element styles + // so we can process them as normal elements, and hide the original pseudo elements so they don't interfere // with layout. function addPseudoElements(el) { // These are done in discrete steps to prevent a relayout loop caused by addClass() invalidating @@ -1194,7 +1197,7 @@ _html2canvas.Parse = function (images, options, cb) { // Note that this doesn't work in < IE8, but we don't support that anyhow function nodeListToArray (nodeList) { - return Array.prototype.slice.call(nodeList); + return Array.prototype.slice.call(nodeList); } function documentWidth () { @@ -1961,8 +1964,8 @@ _html2canvas.Parse = function (images, options, cb) { var parentStyle = window.getComputedStyle(el); // If no content attribute is present, the pseudo element is hidden, // or the parent has a content property equal to the content on the pseudo element, - // move along. - if(!elStyle || !elStyle.content || elStyle.content === "none" || elStyle.content === "-moz-alt-content" || + // move along. + if(!elStyle || !elStyle.content || elStyle.content === "none" || elStyle.content === "-moz-alt-content" || elStyle.display === "none" || parentStyle.content === elStyle.content) { return; } @@ -2036,28 +2039,25 @@ _html2canvas.Parse = function (images, options, cb) { function renderBackgroundRepeating(el, bounds, ctx, image, imageIndex) { var backgroundSize = Util.BackgroundSize(el, bounds, image, imageIndex), backgroundPosition = Util.BackgroundPosition(el, bounds, image, imageIndex, backgroundSize), - backgroundRepeat = getCSS(el, "backgroundRepeat").split(",").map(Util.trimText); + backgroundRepeat = Util.BackgroundRepeat(el, imageIndex); image = resizeImage(image, backgroundSize); - backgroundRepeat = backgroundRepeat[imageIndex] || backgroundRepeat[0]; - switch (backgroundRepeat) { case "repeat-x": + case "repeat no-repeat": backgroundRepeatShape(ctx, image, backgroundPosition, bounds, bounds.left, bounds.top + backgroundPosition.top, 99999, image.height); break; - case "repeat-y": + case "no-repeat repeat": backgroundRepeatShape(ctx, image, backgroundPosition, bounds, bounds.left + backgroundPosition.left, bounds.top, image.width, 99999); break; - case "no-repeat": backgroundRepeatShape(ctx, image, backgroundPosition, bounds, bounds.left + backgroundPosition.left, bounds.top + backgroundPosition.top, image.width, image.height); break; - default: renderBackgroundRepeat(ctx, image, backgroundPosition, { top: bounds.top, @@ -2275,7 +2275,7 @@ _html2canvas.Parse = function (images, options, cb) { // We add one and kick it off so this will still work when children.length === 0. // Note that unless async is true, this will happen synchronously, just will callbacks. var jobs = children.length + 1; - finished(); + finished(); if (options.async) { children.forEach(function(node) { @@ -2623,6 +2623,15 @@ _html2canvas.Preload = function( options ) { }; _html2canvas.Renderer = function(parseQueue, options){ + function sortZindex(a, b) { + if (a === 'children') { + return -1; + } else if (b === 'children') { + return 1; + } else { + return a - b; + } + } // http://www.w3.org/TR/CSS21/zindex.html function createRenderQueue(parseQueue) { @@ -2640,8 +2649,9 @@ _html2canvas.Renderer = function(parseQueue, options){ childrenDest = specialParent; // where children without z-index should be pushed into if (node.zIndex.ownStacking) { - // '!' comes before numbers in sorted array - contextForChildren = stub.context = { '!': [{node:node, children: []}]}; + contextForChildren = stub.context = { + children: [{node:node, children: []}] + }; childrenDest = undefined; } else if (isPositioned || isFloated) { childrenDest = stub.children = []; @@ -2663,7 +2673,7 @@ _html2canvas.Renderer = function(parseQueue, options){ })(parseQueue); function sortZ(context) { - Object.keys(context).sort().forEach(function(zi) { + Object.keys(context).sort(sortZindex).forEach(function(zi) { var nonPositioned = [], floated = [], positioned = [], @@ -2885,7 +2895,7 @@ _html2canvas.Renderer.Canvas = function(options) { } function safeImage(item) { - if (safeImages.indexOf(item['arguments'][0].src ) === -1) { + if (safeImages.indexOf(item['arguments'][0].src) === -1) { testctx.drawImage(item['arguments'][0], 0, 0); try { testctx.getImageData(0, 0, 1, 1); @@ -2910,8 +2920,7 @@ _html2canvas.Renderer.Canvas = function(options) { if (item['arguments'][0].width > 0 && item['arguments'][0].height > 0) { try { ctx.fillStyle = ctx.createPattern(item['arguments'][0], "repeat"); - } - catch(e) { + } catch(e) { Util.log("html2canvas: Renderer: Error creating pattern", e.message); } } @@ -2947,7 +2956,6 @@ _html2canvas.Renderer.Canvas = function(options) { ctx.fillStyle = (Util.isTransparent(parsedData.backgroundColor) && options.background !== undefined) ? options.background : parsedData.backgroundColor; ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = fstyle; - queue.forEach(function(storageContext) { // set common settings for canvas ctx.textBaseline = "bottom"; diff --git a/build/html2canvas.min.js b/build/html2canvas.min.js index cd16c25..4dd4709 100644 --- a/build/html2canvas.min.js +++ b/build/html2canvas.min.js @@ -4,5 +4,5 @@ Released under MIT License */ -(function(t,e,n){"use strict";function r(t,e,n){var r,a=t.runtimeStyle&&t.runtimeStyle[e],o=t.style;return!/^-?[0-9]+\.?[0-9]*(?:px)?$/i.test(n)&&/^-?\d/.test(n)&&(r=o.left,a&&(t.runtimeStyle.left=t.currentStyle.left),o.left="fontSize"===e?"1em":n||0,n=o.pixelLeft+"px",o.left=r,a&&(t.runtimeStyle.left=a)),/^(thin|medium|thick)$/i.test(n)?n:Math.round(parseFloat(n))+"px"}function a(t){return parseInt(t,10)}function o(t,e,a,o){if(t=(t||"").split(","),t=t[o||0]||t[0]||"auto",t=c.Util.trimText(t).split(" "),"backgroundSize"===a&&t[0]&&t[0].match(/^(cover|contain|auto)$/))return t;if(t[0]=-1===t[0].indexOf("%")?r(e,a+"X",t[0]):t[0],t[1]===n){if("backgroundSize"===a)return t[1]="auto",t;t[1]=t[0]}return t[1]=-1===t[1].indexOf("%")?r(e,a+"Y",t[1]):t[1],t}function i(t,e){var n=[];return{storage:n,width:t,height:e,clip:function(){n.push({type:"function",name:"clip",arguments:arguments})},translate:function(){n.push({type:"function",name:"translate",arguments:arguments})},fill:function(){n.push({type:"function",name:"fill",arguments:arguments})},save:function(){n.push({type:"function",name:"save",arguments:arguments})},restore:function(){n.push({type:"function",name:"restore",arguments:arguments})},fillRect:function(){n.push({type:"function",name:"fillRect",arguments:arguments})},createPattern:function(){n.push({type:"function",name:"createPattern",arguments:arguments})},drawShape:function(){var t=[];return n.push({type:"function",name:"drawShape",arguments:t}),{moveTo:function(){t.push({name:"moveTo",arguments:arguments})},lineTo:function(){t.push({name:"lineTo",arguments:arguments})},arcTo:function(){t.push({name:"arcTo",arguments:arguments})},bezierCurveTo:function(){t.push({name:"bezierCurveTo",arguments:arguments})},quadraticCurveTo:function(){t.push({name:"quadraticCurveTo",arguments:arguments})}}},drawImage:function(){n.push({type:"function",name:"drawImage",arguments:arguments})},fillText:function(){n.push({type:"function",name:"fillText",arguments:arguments})},setVariable:function(t,e){return n.push({type:"variable",name:t,arguments:e}),e}}}var l,s,c={};c.Util={},c.Util.log=function(e){c.logging&&t.console&&t.console.log&&t.console.log(e)},c.Util.trimText=function(t){return function(e){return t?t.apply(e):((e||"")+"").replace(/^\s+|\s+$/g,"")}}(String.prototype.trim),c.Util.asFloat=function(t){return parseFloat(t)},function(){var t=/((rgba|rgb)\([^\)]+\)(\s-?\d+px){0,})/g,e=/(-?\d+px)|(#.+)|(rgb\(.+\))|(rgba\(.+\))/g;c.Util.parseTextShadows=function(n){if(!n||"none"===n)return[];for(var r=n.match(t),a=[],o=0;r&&r.length>o;o++){var i=r[o].match(e);a.push({color:i[0],offsetX:i[1]?i[1].replace("px",""):0,offsetY:i[2]?i[2].replace("px",""):0,blur:i[3]?i[3].replace("px",""):0})}return a}}(),c.Util.parseBackgroundImage=function(t){var e,n,r,a,o,i,l,s,c=" \r\n ",d=[],h=0,u=0,f=function(){e&&('"'===n.substr(0,1)&&(n=n.substr(1,n.length-2)),n&&s.push(n),"-"===e.substr(0,1)&&(a=e.indexOf("-",1)+1)>0&&(r=e.substr(0,a),e=e.substr(a)),d.push({prefix:r,method:e.toLowerCase(),value:o,args:s})),s=[],e=r=n=o=""};f();for(var p=0,g=t.length;g>p;p++)if(i=t[p],!(0===h&&c.indexOf(i)>-1)){switch(i){case'"':l?l===i&&(l=null):l=i;break;case"(":if(l)break;if(0===h){h=1,o+=i;continue}u++;break;case")":if(l)break;if(1===h){if(0===u){h=0,o+=i,f();continue}u--}break;case",":if(l)break;if(0===h){f();continue}if(1===h&&0===u&&!e.match(/^url$/i)){s.push(n),n="",o+=i;continue}}o+=i,0===h?e+=i:n+=i}return f(),d},c.Util.Bounds=function(t){var e,n={};return t.getBoundingClientRect&&(e=t.getBoundingClientRect(),n.top=e.top,n.bottom=e.bottom||e.top+e.height,n.left=e.left,n.width=t.offsetWidth,n.height=t.offsetHeight),n},c.Util.OffsetBounds=function(t){var e=t.offsetParent?c.Util.OffsetBounds(t.offsetParent):{top:0,left:0};return{top:t.offsetTop+e.top,bottom:t.offsetTop+t.offsetHeight+e.top,left:t.offsetLeft+e.left,width:t.offsetWidth,height:t.offsetHeight}},c.Util.getCSS=function(t,n,r){l!==t&&(s=e.defaultView.getComputedStyle(t,null));var i=s[n];if(/^background(Size|Position)$/.test(n))return o(i,t,n,r);if(/border(Top|Bottom)(Left|Right)Radius/.test(n)){var c=i.split(" ");return 1>=c.length&&(c[1]=c[0]),c.map(a)}return i},c.Util.resizeBounds=function(t,e,n,r,a){var o,i,l=n/r,s=t/e;return a&&"auto"!==a?s>l^"contain"===a?(i=r,o=r*s):(o=n,i=n/s):(o=n,i=r),{width:o,height:i}},c.Util.BackgroundPosition=function(t,e,n,r,a){var o,i,l=c.Util.getCSS(t,"backgroundPosition",r);return 1===l.length&&(l=[l[0],l[0]]),o=-1!==(""+l[0]).indexOf("%")?(e.width-(a||n).width)*(parseFloat(l[0])/100):parseInt(l[0],10),i="auto"===l[1]?o/n.width*n.height:-1!==(""+l[1]).indexOf("%")?(e.height-(a||n).height)*parseFloat(l[1])/100:parseInt(l[1],10),"auto"===l[0]&&(o=i/n.height*n.width),{left:o,top:i}},c.Util.BackgroundSize=function(t,e,n,r){var a,o,i=c.Util.getCSS(t,"backgroundSize",r);if(1===i.length&&(i=[i[0],i[0]]),-1!==(""+i[0]).indexOf("%"))a=e.width*parseFloat(i[0])/100;else if("auto"===i[0])a=n.width;else{if(/contain|cover/.test(i[0])){var l=c.Util.resizeBounds(n.width,n.height,e.width,e.height,i[0]);return{width:l.width,height:l.height}}a=parseInt(i[0],10)}return o="auto"===i[1]?a/n.width*n.height:-1!==(""+i[1]).indexOf("%")?e.height*parseFloat(i[1])/100:parseInt(i[1],10),"auto"===i[0]&&(a=o/n.height*n.width),{width:a,height:o}},c.Util.Extend=function(t,e){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},c.Util.Children=function(t){var e;try{e=t.nodeName&&"IFRAME"===t.nodeName.toUpperCase()?t.contentDocument||t.contentWindow.document:function(t){var e=[];return null!==t&&function(t,e){var r=t.length,a=0;if("number"==typeof e.length)for(var o=e.length;o>a;a++)t[r++]=e[a];else for(;e[a]!==n;)t[r++]=e[a++];return t.length=r,t}(e,t),e}(t.childNodes)}catch(r){c.Util.log("html2canvas.Util.Children failed with exception: "+r.message),e=[]}return e},c.Util.isTransparent=function(t){return!t||"transparent"===t||"rgba(0, 0, 0, 0)"===t},c.Util.Font=function(){var t={};return function(e,r,a){if(t[e+"-"+r]!==n)return t[e+"-"+r];var o,i,l,s=a.createElement("div"),c=a.createElement("img"),d=a.createElement("span"),h="Hidden Text";return s.style.visibility="hidden",s.style.fontFamily=e,s.style.fontSize=r,s.style.margin=0,s.style.padding=0,a.body.appendChild(s),c.src="data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=",c.width=1,c.height=1,c.style.margin=0,c.style.padding=0,c.style.verticalAlign="baseline",d.style.fontFamily=e,d.style.fontSize=r,d.style.margin=0,d.style.padding=0,d.appendChild(a.createTextNode(h)),s.appendChild(d),s.appendChild(c),o=c.offsetTop-d.offsetTop+1,s.removeChild(d),s.appendChild(a.createTextNode(h)),s.style.lineHeight="normal",c.style.verticalAlign="super",i=c.offsetTop-s.offsetTop+1,l={baseline:o,lineWidth:1,middle:i},t[e+"-"+r]=l,a.body.removeChild(s),l}}(),function(){function t(t){return function(e){try{t.addColorStop(e.stop,e.color)}catch(r){n.log(["failed to add color stop: ",r,"; tried to add: ",e])}}}var n=c.Util,r={};c.Generate=r;var a=[/^(-webkit-linear-gradient)\(([a-z\s]+)([\w\d\.\s,%\(\)]+)\)$/,/^(-o-linear-gradient)\(([a-z\s]+)([\w\d\.\s,%\(\)]+)\)$/,/^(-webkit-gradient)\((linear|radial),\s((?:\d{1,3}%?)\s(?:\d{1,3}%?),\s(?:\d{1,3}%?)\s(?:\d{1,3}%?))([\w\d\.\s,%\(\)\-]+)\)$/,/^(-moz-linear-gradient)\(((?:\d{1,3}%?)\s(?:\d{1,3}%?))([\w\d\.\s,%\(\)]+)\)$/,/^(-webkit-radial-gradient)\(((?:\d{1,3}%?)\s(?:\d{1,3}%?)),\s(\w+)\s([a-z\-]+)([\w\d\.\s,%\(\)]+)\)$/,/^(-moz-radial-gradient)\(((?:\d{1,3}%?)\s(?:\d{1,3}%?)),\s(\w+)\s?([a-z\-]*)([\w\d\.\s,%\(\)]+)\)$/,/^(-o-radial-gradient)\(((?:\d{1,3}%?)\s(?:\d{1,3}%?)),\s(\w+)\s([a-z\-]+)([\w\d\.\s,%\(\)]+)\)$/];r.parseGradient=function(t,e){var n,r,o,i,l,s,c,d,h,u,f,p,g=a.length;for(r=0;g>r&&!(o=t.match(a[r]));r+=1);if(o)switch(o[1]){case"-webkit-linear-gradient":case"-o-linear-gradient":if(n={type:"linear",x0:null,y0:null,x1:null,y1:null,colorStops:[]},l=o[2].match(/\w+/g))for(s=l.length,r=0;s>r;r+=1)switch(l[r]){case"top":n.y0=0,n.y1=e.height;break;case"right":n.x0=e.width,n.x1=0;break;case"bottom":n.y0=e.height,n.y1=0;break;case"left":n.x0=0,n.x1=e.width}if(null===n.x0&&null===n.x1&&(n.x0=n.x1=e.width/2),null===n.y0&&null===n.y1&&(n.y0=n.y1=e.height/2),l=o[3].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\)(?:\s\d{1,3}(?:%|px))?)+/g))for(s=l.length,c=1/Math.max(s-1,1),r=0;s>r;r+=1)d=l[r].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\))\s*(\d{1,3})?(%|px)?/),d[2]?(i=parseFloat(d[2]),i/="%"===d[3]?100:e.width):i=r*c,n.colorStops.push({color:d[1],stop:i});break;case"-webkit-gradient":if(n={type:"radial"===o[2]?"circle":o[2],x0:0,y0:0,x1:0,y1:0,colorStops:[]},l=o[3].match(/(\d{1,3})%?\s(\d{1,3})%?,\s(\d{1,3})%?\s(\d{1,3})%?/),l&&(n.x0=l[1]*e.width/100,n.y0=l[2]*e.height/100,n.x1=l[3]*e.width/100,n.y1=l[4]*e.height/100),l=o[4].match(/((?:from|to|color-stop)\((?:[0-9\.]+,\s)?(?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\)\))+/g))for(s=l.length,r=0;s>r;r+=1)d=l[r].match(/(from|to|color-stop)\(([0-9\.]+)?(?:,\s)?((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\))\)/),i=parseFloat(d[2]),"from"===d[1]&&(i=0),"to"===d[1]&&(i=1),n.colorStops.push({color:d[3],stop:i});break;case"-moz-linear-gradient":if(n={type:"linear",x0:0,y0:0,x1:0,y1:0,colorStops:[]},l=o[2].match(/(\d{1,3})%?\s(\d{1,3})%?/),l&&(n.x0=l[1]*e.width/100,n.y0=l[2]*e.height/100,n.x1=e.width-n.x0,n.y1=e.height-n.y0),l=o[3].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\)(?:\s\d{1,3}%)?)+/g))for(s=l.length,c=1/Math.max(s-1,1),r=0;s>r;r+=1)d=l[r].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\))\s*(\d{1,3})?(%)?/),d[2]?(i=parseFloat(d[2]),d[3]&&(i/=100)):i=r*c,n.colorStops.push({color:d[1],stop:i});break;case"-webkit-radial-gradient":case"-moz-radial-gradient":case"-o-radial-gradient":if(n={type:"circle",x0:0,y0:0,x1:e.width,y1:e.height,cx:0,cy:0,rx:0,ry:0,colorStops:[]},l=o[2].match(/(\d{1,3})%?\s(\d{1,3})%?/),l&&(n.cx=l[1]*e.width/100,n.cy=l[2]*e.height/100),l=o[3].match(/\w+/),d=o[4].match(/[a-z\-]*/),l&&d)switch(d[0]){case"farthest-corner":case"cover":case"":h=Math.sqrt(Math.pow(n.cx,2)+Math.pow(n.cy,2)),u=Math.sqrt(Math.pow(n.cx,2)+Math.pow(n.y1-n.cy,2)),f=Math.sqrt(Math.pow(n.x1-n.cx,2)+Math.pow(n.y1-n.cy,2)),p=Math.sqrt(Math.pow(n.x1-n.cx,2)+Math.pow(n.cy,2)),n.rx=n.ry=Math.max(h,u,f,p);break;case"closest-corner":h=Math.sqrt(Math.pow(n.cx,2)+Math.pow(n.cy,2)),u=Math.sqrt(Math.pow(n.cx,2)+Math.pow(n.y1-n.cy,2)),f=Math.sqrt(Math.pow(n.x1-n.cx,2)+Math.pow(n.y1-n.cy,2)),p=Math.sqrt(Math.pow(n.x1-n.cx,2)+Math.pow(n.cy,2)),n.rx=n.ry=Math.min(h,u,f,p);break;case"farthest-side":"circle"===l[0]?n.rx=n.ry=Math.max(n.cx,n.cy,n.x1-n.cx,n.y1-n.cy):(n.type=l[0],n.rx=Math.max(n.cx,n.x1-n.cx),n.ry=Math.max(n.cy,n.y1-n.cy));break;case"closest-side":case"contain":"circle"===l[0]?n.rx=n.ry=Math.min(n.cx,n.cy,n.x1-n.cx,n.y1-n.cy):(n.type=l[0],n.rx=Math.min(n.cx,n.x1-n.cx),n.ry=Math.min(n.cy,n.y1-n.cy))}if(l=o[5].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\)(?:\s\d{1,3}(?:%|px))?)+/g))for(s=l.length,c=1/Math.max(s-1,1),r=0;s>r;r+=1)d=l[r].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\))\s*(\d{1,3})?(%|px)?/),d[2]?(i=parseFloat(d[2]),i/="%"===d[3]?100:e.width):i=r*c,n.colorStops.push({color:d[1],stop:i})}return n},r.Gradient=function(n,r){if(0!==r.width&&0!==r.height){var a,o,i=e.createElement("canvas"),l=i.getContext("2d");if(i.width=r.width,i.height=r.height,a=c.Generate.parseGradient(n,r))switch(a.type){case"linear":o=l.createLinearGradient(a.x0,a.y0,a.x1,a.y1),a.colorStops.forEach(t(o)),l.fillStyle=o,l.fillRect(0,0,r.width,r.height);break;case"circle":o=l.createRadialGradient(a.cx,a.cy,0,a.cx,a.cy,a.rx),a.colorStops.forEach(t(o)),l.fillStyle=o,l.fillRect(0,0,r.width,r.height);break;case"ellipse":var s=e.createElement("canvas"),d=s.getContext("2d"),h=Math.max(a.rx,a.ry),u=2*h;s.width=s.height=u,o=d.createRadialGradient(a.rx,a.ry,0,a.rx,a.ry,h),a.colorStops.forEach(t(o)),d.fillStyle=o,d.fillRect(0,0,u,u),l.fillStyle=a.colorStops[a.colorStops.length-1].color,l.fillRect(0,0,i.width,i.height),l.drawImage(s,a.cx-a.rx,a.cy-a.ry,2*a.rx,2*a.ry)}return i}},r.ListAlpha=function(t){var e,n="";do e=t%26,n=String.fromCharCode(e+64)+n,t/=26;while(26*t>26);return n},r.ListRoman=function(t){var e,n=["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"],r=[1e3,900,500,400,100,90,50,40,10,9,5,4,1],a="",o=n.length;if(0>=t||t>=4e3)return t;for(e=0;o>e;e+=1)for(;t>=r[e];)t-=r[e],a+=n[e];return a}}(),c.Parse=function(r,a,o){function l(){var t=be(e.documentElement,"backgroundColor"),n=me.isTransparent(t)&&fe===e.body,r=ce(fe,null,!1,n);s(fe),ue(fe,r,function(){n&&(t=r.backgroundColor),d(),me.log("Done parsing, moving to Render."),o({backgroundColor:t,stack:r})})}function s(t){function n(){for(var t=/:before|:after/,n=e.styleSheets,r=0,a=n.length;a>r;r++)try{for(var o=n[r].cssRules,i=0,s=o.length;s>i;i++)t.test(o[i].selectorText)&&l.push(o[i].selectorText)}catch(c){}for(r=0,a=l.length;a>r;r++)l[r]=l[r].match(/(^[^:]*)/)[1]}function r(){for(var t=e.querySelectorAll(l.join(",")),n=0,r=t.length;r>n;n++)a(t[n])}function a(t){var e=Y(t,":before"),n=Y(t,":after");e&&i.push({type:"before",pseudo:e,el:t}),n&&i.push({type:"after",pseudo:n,el:t})}function o(){i.forEach(function(t){h(t.el,ve+"-parent")}),i.forEach(function(t){"before"===t.type?t.el.insertBefore(t.pseudo,t.el.firstChild):t.el.appendChild(t.pseudo)})}var i=[],l=[];n(),r(t),o()}function d(){xe.removeChild(Ce);for(var t=e.getElementsByClassName(ve+"-element");t.length;)t[0].parentNode.removeChild(t[0]);for(var n=e.getElementsByClassName(ve+"-parent");n.length;)u(n[0],ve+"-parent")}function h(t,e){t.classList?t.classList.add(e):t.className=t.className+" "+e}function u(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(e,"").trim()}function f(){return Math.max(Math.max(ge.body.scrollWidth,ge.documentElement.scrollWidth),Math.max(ge.body.offsetWidth,ge.documentElement.offsetWidth),Math.max(ge.body.clientWidth,ge.documentElement.clientWidth))}function p(){return Math.max(Math.max(ge.body.scrollHeight,ge.documentElement.scrollHeight),Math.max(ge.body.offsetHeight,ge.documentElement.offsetHeight),Math.max(ge.body.clientHeight,ge.documentElement.clientHeight))}function g(t,e){var n=parseInt(be(t,e),10);return isNaN(n)?0:n}function m(t,e,n,r,a,o){"transparent"!==o&&(t.setVariable("fillStyle",o),t.fillRect(e,n,r,a),pe+=1)}function y(t,e,r){return t.length>0?e+r.toUpperCase():n}function w(t,e){switch(e){case"lowercase":return t.toLowerCase();case"capitalize":return t.replace(/(^|\s|:|-|\(|\))([a-z])/g,y);case"uppercase":return t.toUpperCase();default:return t}}function x(t){return/^(normal|none|0px)$/.test(t)}function b(t,e,n,r){null!==t&&me.trimText(t).length>0&&(r.fillText(t,e,n),pe+=1)}function v(t,e,r,a){var o=!1,i=be(e,"fontWeight"),l=be(e,"fontFamily"),s=be(e,"fontSize"),c=me.parseTextShadows(be(e,"textShadow"));switch(parseInt(i,10)){case 401:i="bold";break;case 400:i="normal"}return t.setVariable("fillStyle",a),t.setVariable("font",[be(e,"fontStyle"),be(e,"fontVariant"),i,s,l].join(" ")),t.setVariable("textAlign",o?"right":"left"),c.length&&(t.setVariable("shadowColor",c[0].color),t.setVariable("shadowOffsetX",c[0].offsetX),t.setVariable("shadowOffsetY",c[0].offsetY),t.setVariable("shadowBlur",c[0].blur)),"none"!==r?me.Font(l,s,ge):n}function C(t,e,n,r,a){switch(e){case"underline":m(t,n.left,Math.round(n.top+r.baseline+r.lineWidth),n.width,1,a);break;case"overline":m(t,n.left,Math.round(n.top),n.width,1,a);break;case"line-through":m(t,n.left,Math.ceil(n.top+r.middle+r.lineWidth),n.width,1,a)}}function k(t,e,n,r,a){var o;if(ye.rangeBounds&&!a)("none"!==n||0!==me.trimText(e).length)&&(o=T(e,t.node,t.textOffset)),t.textOffset+=e.length;else if(t.node&&"string"==typeof t.node.nodeValue){var i=r?t.node.splitText(e.length):null;o=E(t.node,a),t.node=i}return o}function T(t,e,n){var r=ge.createRange();return r.setStart(e,n),r.setEnd(e,n+t.length),r.getBoundingClientRect()}function E(t,e){var n=t.parentNode,r=ge.createElement("wrapper"),a=t.cloneNode(!0);r.appendChild(t.cloneNode(!0)),n.replaceChild(r,t);var o=e?me.OffsetBounds(r):me.Bounds(r);return n.replaceChild(a,r),o}function S(t,e,n){var r,o,i=n.ctx,l=be(t,"color"),s=be(t,"textDecoration"),c=be(t,"textAlign"),d={node:e,textOffset:0};me.trimText(e.nodeValue).length>0&&(e.nodeValue=w(e.nodeValue,be(t,"textTransform")),c=c.replace(["-webkit-auto"],["auto"]),o=!a.letterRendering&&/^(left|right|justify|auto)$/.test(c)&&x(be(t,"letterSpacing"))?e.nodeValue.split(/(\b| )/):e.nodeValue.split(""),r=v(i,t,s,l),a.chinese&&o.forEach(function(t,e){/.*[\u4E00-\u9FA5].*$/.test(t)&&(t=t.split(""),t.unshift(e,1),o.splice.apply(o,t))}),o.forEach(function(t,e){var a=k(d,t,s,o.length-1>e,n.transform.matrix);a&&(b(t,a.left,a.bottom,i),C(i,s,a,r,l))}))}function R(t,e){var n,r,a=ge.createElement("boundelement");return a.style.display="inline",n=t.style.listStyleType,t.style.listStyleType="none",a.appendChild(ge.createTextNode(e)),t.insertBefore(a,t.firstChild),r=me.Bounds(a),t.removeChild(a),t.style.listStyleType=n,r}function M(t){var e=-1,n=1,r=t.parentNode.childNodes;if(t.parentNode){for(;r[++e]!==t;)1===r[e].nodeType&&n++;return n}return-1}function I(t,e){var n,r=M(t);switch(e){case"decimal":n=r;break;case"decimal-leading-zero":n=1===(""+r).length?r="0"+(""+r):""+r;break;case"upper-roman":n=c.Generate.ListRoman(r);break;case"lower-roman":n=c.Generate.ListRoman(r).toLowerCase();break;case"lower-alpha":n=c.Generate.ListAlpha(r).toLowerCase();break;case"upper-alpha":n=c.Generate.ListAlpha(r)}return n+". "}function L(t,e,n){var r,a,o,i=e.ctx,l=be(t,"listStyleType");if(/^(decimal|decimal-leading-zero|upper-alpha|upper-latin|upper-roman|lower-alpha|lower-greek|lower-latin|lower-roman)$/i.test(l)){if(a=I(t,l),o=R(t,a),v(i,t,"none",be(t,"color")),"inside"!==be(t,"listStylePosition"))return;i.setVariable("textAlign","left"),r=n.left,b(a,r,o.bottom,i)}}function O(t){var e=r[t];return e&&e.succeeded===!0?e.img:!1}function z(t,e){var n=Math.max(t.left,e.left),r=Math.max(t.top,e.top),a=Math.min(t.left+t.width,e.left+e.width),o=Math.min(t.top+t.height,e.top+e.height);return{left:n,top:r,width:a-n,height:o-r}}function A(t,e,n){var r,a="static"!==e.cssPosition,o=a?be(t,"zIndex"):"auto",i=be(t,"opacity"),l="none"!==be(t,"cssFloat");e.zIndex=r=B(o),r.isPositioned=a,r.isFloated=l,r.opacity=i,r.ownStacking="auto"!==o||1>i,r.depth=n?n.zIndex.depth+1:0,n&&n.zIndex.children.push(e)}function B(t){return{depth:0,zindex:t,children:[]}}function U(t,e,n,r,a){var o=g(e,"paddingLeft"),i=g(e,"paddingTop"),l=g(e,"paddingRight"),s=g(e,"paddingBottom");_(t,n,0,0,n.width,n.height,r.left+o+a[3].width,r.top+i+a[0].width,r.width-(a[1].width+a[3].width+o+l),r.height-(a[0].width+a[2].width+i+s))}function N(t){return["Top","Right","Bottom","Left"].map(function(e){return{width:g(t,"border"+e+"Width"),color:be(t,"border"+e+"Color")}})}function P(t){return["TopLeft","TopRight","BottomRight","BottomLeft"].map(function(e){return be(t,"border"+e+"Radius")})}function F(t,e,n,r){var a=4*((Math.sqrt(2)-1)/3),o=n*a,i=r*a,l=t+n,s=e+r;return{topLeft:V({x:t,y:s},{x:t,y:s-i},{x:l-o,y:e},{x:l,y:e}),topRight:V({x:t,y:e},{x:t+o,y:e},{x:l,y:s-i},{x:l,y:s}),bottomRight:V({x:l,y:e},{x:l,y:e+i},{x:t+o,y:s},{x:t,y:s}),bottomLeft:V({x:l,y:s},{x:l-o,y:s},{x:t,y:e+i},{x:t,y:e})}}function V(t,e,n,r){var a=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:r,subdivide:function(o){var i=a(t,e,o),l=a(e,n,o),s=a(n,r,o),c=a(i,l,o),d=a(l,s,o),h=a(c,d,o);return[V(t,i,c,h),V(h,d,s,r)]},curveTo:function(t){t.push(["bezierCurve",e.x,e.y,n.x,n.y,r.x,r.y])},curveToReversed:function(r){r.push(["bezierCurve",n.x,n.y,e.x,e.y,t.x,t.y])}}}function D(t,e,n,r,a,o,i){e[0]>0||e[1]>0?(t.push(["line",r[0].start.x,r[0].start.y]),r[0].curveTo(t),r[1].curveTo(t)):t.push(["line",o,i]),(n[0]>0||n[1]>0)&&t.push(["line",a[0].start.x,a[0].start.y])}function $(t,e,n,r,a,o,i){var l=[];return e[0]>0||e[1]>0?(l.push(["line",r[1].start.x,r[1].start.y]),r[1].curveTo(l)):l.push(["line",t.c1[0],t.c1[1]]),n[0]>0||n[1]>0?(l.push(["line",o[0].start.x,o[0].start.y]),o[0].curveTo(l),l.push(["line",i[0].end.x,i[0].end.y]),i[0].curveToReversed(l)):(l.push(["line",t.c2[0],t.c2[1]]),l.push(["line",t.c3[0],t.c3[1]])),e[0]>0||e[1]>0?(l.push(["line",a[1].end.x,a[1].end.y]),a[1].curveToReversed(l)):l.push(["line",t.c4[0],t.c4[1]]),l}function G(t,e,n){var r=t.left,a=t.top,o=t.width,i=t.height,l=e[0][0],s=e[0][1],c=e[1][0],d=e[1][1],h=e[2][0],u=e[2][1],f=e[3][0],p=e[3][1],g=o-c,m=i-u,y=o-h,w=i-p;return{topLeftOuter:F(r,a,l,s).topLeft.subdivide(.5),topLeftInner:F(r+n[3].width,a+n[0].width,Math.max(0,l-n[3].width),Math.max(0,s-n[0].width)).topLeft.subdivide(.5),topRightOuter:F(r+g,a,c,d).topRight.subdivide(.5),topRightInner:F(r+Math.min(g,o+n[3].width),a+n[0].width,g>o+n[3].width?0:c-n[3].width,d-n[0].width).topRight.subdivide(.5),bottomRightOuter:F(r+y,a+m,h,u).bottomRight.subdivide(.5),bottomRightInner:F(r+Math.min(y,o+n[3].width),a+Math.min(m,i+n[0].width),Math.max(0,h-n[1].width),Math.max(0,u-n[2].width)).bottomRight.subdivide(.5),bottomLeftOuter:F(r,a+w,f,p).bottomLeft.subdivide(.5),bottomLeftInner:F(r+n[3].width,a+w,Math.max(0,f-n[3].width),Math.max(0,p-n[2].width)).bottomLeft.subdivide(.5)}}function W(t,e,n,r,a){var o=be(t,"backgroundClip"),i=[];switch(o){case"content-box":case"padding-box":D(i,r[0],r[1],e.topLeftInner,e.topRightInner,a.left+n[3].width,a.top+n[0].width),D(i,r[1],r[2],e.topRightInner,e.bottomRightInner,a.left+a.width-n[1].width,a.top+n[0].width),D(i,r[2],r[3],e.bottomRightInner,e.bottomLeftInner,a.left+a.width-n[1].width,a.top+a.height-n[2].width),D(i,r[3],r[0],e.bottomLeftInner,e.topLeftInner,a.left+n[3].width,a.top+a.height-n[2].width);break;default:D(i,r[0],r[1],e.topLeftOuter,e.topRightOuter,a.left,a.top),D(i,r[1],r[2],e.topRightOuter,e.bottomRightOuter,a.left+a.width,a.top),D(i,r[2],r[3],e.bottomRightOuter,e.bottomLeftOuter,a.left+a.width,a.top+a.height),D(i,r[3],r[0],e.bottomLeftOuter,e.topLeftOuter,a.left,a.top+a.height)}return i}function H(t,e,n){var r,a,o,i,l,s,c=e.left,d=e.top,h=e.width,u=e.height,f=P(t),p=G(e,f,n),g={clip:W(t,p,n,f,e),borders:[]};for(r=0;4>r;r++)if(n[r].width>0){switch(a=c,o=d,i=h,l=u-n[2].width,r){case 0:l=n[0].width,s=$({c1:[a,o],c2:[a+i,o],c3:[a+i-n[1].width,o+l],c4:[a+n[3].width,o+l]},f[0],f[1],p.topLeftOuter,p.topLeftInner,p.topRightOuter,p.topRightInner);break;case 1:a=c+h-n[1].width,i=n[1].width,s=$({c1:[a+i,o],c2:[a+i,o+l+n[2].width],c3:[a,o+l],c4:[a,o+n[0].width]},f[1],f[2],p.topRightOuter,p.topRightInner,p.bottomRightOuter,p.bottomRightInner);break;case 2:o=o+u-n[2].width,l=n[2].width,s=$({c1:[a+i,o+l],c2:[a,o+l],c3:[a+n[3].width,o],c4:[a+i-n[3].width,o]},f[2],f[3],p.bottomRightOuter,p.bottomRightInner,p.bottomLeftOuter,p.bottomLeftInner);break;case 3:i=n[3].width,s=$({c1:[a,o+l+n[2].width],c2:[a,o],c3:[a+i,o+n[0].width],c4:[a+i,o+l]},f[3],f[0],p.bottomLeftOuter,p.bottomLeftInner,p.topLeftOuter,p.topLeftInner)}g.borders.push({args:s,color:n[r].color})}return g}function j(t,e){var n=t.drawShape();return e.forEach(function(t,e){n[0===e?"moveTo":t[0]+"To"].apply(null,t.slice(1))}),n}function q(t,e,n){"transparent"!==n&&(t.setVariable("fillStyle",n),j(t,e),t.fill(),pe+=1)}function X(t,e,n){var r,a,o=ge.createElement("valuewrap"),i=["lineHeight","textAlign","fontFamily","color","fontSize","paddingLeft","paddingTop","width","height","border","borderLeftWidth","borderTopWidth"];i.forEach(function(e){try{o.style[e]=be(t,e)}catch(n){me.log("html2canvas: Parse: Exception caught in renderFormValue: "+n.message)}}),o.style.borderColor="black",o.style.borderStyle="solid",o.style.display="block",o.style.position="absolute",(/^(submit|reset|button|text|password)$/.test(t.type)||"SELECT"===t.nodeName)&&(o.style.lineHeight=be(t,"height")),o.style.top=e.top+"px",o.style.left=e.left+"px",r="SELECT"===t.nodeName?(t.options[t.selectedIndex]||0).text:t.value,r||(r=t.placeholder),a=ge.createTextNode(r),o.appendChild(a),xe.appendChild(o),S(t,a,n),xe.removeChild(o)}function _(t){t.drawImage.apply(t,Array.prototype.slice.call(arguments,1)),pe+=1}function Y(n,r){var a=t.getComputedStyle(n,r),o=t.getComputedStyle(n);if(a&&a.content&&"none"!==a.content&&"-moz-alt-content"!==a.content&&"none"!==a.display&&o.content!==a.content){var i=a.content+"";("'"===i[0]||'"'===i[0])&&(i=i.replace(/(^['"])|(['"]$)/g,""));var l="url"===i.substr(0,3),s=e.createElement(l?"img":"span");return s.className=ve+"-element ",Object.keys(a).filter(Q).forEach(function(t){try{s.style[t]=a[t]}catch(e){me.log(["Tried to assign readonly property ",t,"Error:",e])}}),l?s.src=me.parseBackgroundImage(i)[0].args[0]:s.innerHTML=i,s}}function Q(e){return isNaN(t.parseInt(e,10))}function J(t,e,n,r){var a=Math.round(r.left+n.left),o=Math.round(r.top+n.top);t.createPattern(e),t.translate(a,o),t.fill(),t.translate(-a,-o)}function K(t,e,n,r,a,o,i,l){var s=[];s.push(["line",Math.round(a),Math.round(o)]),s.push(["line",Math.round(a+i),Math.round(o)]),s.push(["line",Math.round(a+i),Math.round(l+o)]),s.push(["line",Math.round(a),Math.round(l+o)]),j(t,s),t.save(),t.clip(),J(t,e,n,r),t.restore()}function Z(t,e,n){m(t,e.left,e.top,e.width,e.height,n)}function te(t,e,n,r,a){var o=me.BackgroundSize(t,e,r,a),i=me.BackgroundPosition(t,e,r,a,o),l=be(t,"backgroundRepeat").split(",").map(me.trimText);switch(r=ne(r,o),l=l[a]||l[0]){case"repeat-x":K(n,r,i,e,e.left,e.top+i.top,99999,r.height);break;case"repeat-y":K(n,r,i,e,e.left+i.left,e.top,r.width,99999);break;case"no-repeat":K(n,r,i,e,e.left+i.left,e.top+i.top,r.width,r.height);break;default:J(n,r,i,{top:e.top,left:e.left,width:r.width,height:r.height})}}function ee(t,e,n){for(var r,a=be(t,"backgroundImage"),o=me.parseBackgroundImage(a),i=o.length;i--;)if(a=o[i],a.args&&0!==a.args.length){var l="url"===a.method?a.args[0]:a.value;r=O(l),r?te(t,e,n,r,i):me.log("html2canvas: Error loading background:",a)}}function ne(t,e){if(t.width===e.width&&t.height===e.height)return t;var n,r=ge.createElement("canvas");return r.width=e.width,r.height=e.height,n=r.getContext("2d"),_(n,t,0,0,t.width,t.height,0,0,e.width,e.height),r}function re(t,e,n){return t.setVariable("globalAlpha",be(e,"opacity")*(n?n.opacity:1))}function ae(t){return t.replace("px","")}function oe(t){var e=/(matrix)\((.+)\)/,n=be(t,"transform")||be(t,"-webkit-transform")||be(t,"-moz-transform")||be(t,"-ms-transform")||be(t,"-o-transform"),r=be(t,"transform-origin")||be(t,"-webkit-transform-origin")||be(t,"-moz-transform-origin")||be(t,"-ms-transform-origin")||be(t,"-o-transform-origin")||"0px 0px";r=r.split(" ").map(ae).map(me.asFloat);var a;if(n&&"none"!==n){var o=n.match(e);if(o)switch(o[1]){case"matrix":a=o[2].split(",").map(me.trimText).map(me.asFloat)}}return{origin:r,matrix:a}}function ie(t,e,n,r){var o=i(e?n.width:f(),e?n.height:p()),l={ctx:o,opacity:re(o,t,e),cssPosition:be(t,"position"),borders:N(t),transform:r,clip:e&&e.clip?me.Extend({},e.clip):null};return A(t,l,e),a.useOverflow===!0&&/(hidden|scroll|auto)/.test(be(t,"overflow"))===!0&&/(BODY)/i.test(t.nodeName)===!1&&(l.clip=l.clip?z(l.clip,n):n),l}function le(t,e,n){var r={left:e.left+t[3].width,top:e.top+t[0].width,width:e.width-(t[1].width+t[3].width),height:e.height-(t[0].width+t[2].width)};return n&&(r=z(r,n)),r}function se(t,e){var n=e.matrix?me.OffsetBounds(t):me.Bounds(t);return e.origin[0]+=n.left,e.origin[1]+=n.top,n}function ce(t,e,n){var r,a=oe(t,e),o=se(t,a),i=ie(t,e,o,a),l=i.borders,s=i.ctx,c=le(l,o,i.clip),d=H(t,o,l),h=we.test(t.nodeName)?"#efefef":be(t,"backgroundColor");switch(j(s,d.clip),s.save(),s.clip(),c.height>0&&c.width>0&&!n?(Z(s,o,h),ee(t,c,s)):n&&(i.backgroundColor=h),s.restore(),d.borders.forEach(function(t){q(s,t.args,t.color)}),t.nodeName){case"IMG":(r=O(t.getAttribute("src")))?U(s,t,r,o,l):me.log("html2canvas: Error loading :"+t.getAttribute("src"));break;case"INPUT":/^(text|url|email|submit|button|reset)$/.test(t.type)&&(t.value||t.placeholder||"").length>0&&X(t,o,i);break;case"TEXTAREA":(t.value||t.placeholder||"").length>0&&X(t,o,i);break;case"SELECT":(t.options||t.placeholder||"").length>0&&X(t,o,i);break;case"LI":L(t,i,c);break;case"CANVAS":U(s,t,t,o,l)}return i}function de(t){return"none"!==be(t,"display")&&"hidden"!==be(t,"visibility")&&!t.hasAttribute("data-html2canvas-ignore")}function he(t,e,r){return r||(r=function(){}),de(t)&&(e=ce(t,e,!1)||e,!we.test(t.nodeName))?ue(t,e,r):(r(),n)}function ue(t,e,n){function r(n){n.nodeType===n.ELEMENT_NODE?he(n,e,o):n.nodeType===n.TEXT_NODE?(S(t,n,e),o()):o()}function o(){0>=--l&&(me.log("finished rendering "+i.length+" children."),n())}var i=me.Children(t),l=i.length+1;o(),a.async?i.forEach(function(t){setTimeout(function(){r(t)},0)}):i.forEach(r)}t.scroll(0,0);var fe=a.elements===n?e.body:a.elements[0],pe=0,ge=fe.ownerDocument,me=c.Util,ye=me.Support(a,ge),we=RegExp("("+a.ignoreElements+")"),xe=ge.body,be=me.getCSS,ve="___html2canvas___pseudoelement",Ce=ge.createElement("style");Ce.innerHTML="."+ve+'-parent:before { content: "" !important; display: none !important; }'+"."+ve+'-parent:after { content: "" !important; display: none !important; }',xe.appendChild(Ce),r=r||{},l()},c.Preload=function(r){function a(t){S.href=t,S.href=S.href;var e=S.protocol+S.host;return e===g}function o(){b.log("html2canvas: start: images: "+x.numLoaded+" / "+x.numTotal+" (failed: "+x.numFailed+")"),!x.firstRun&&x.numLoaded>=x.numTotal&&(b.log("Finished loading images: # "+x.numTotal+" (failed: "+x.numFailed+")"),"function"==typeof r.complete&&r.complete(x))}function i(e,a,i){var l,s,c=r.proxy;S.href=e,e=S.href,l="html2canvas_"+v++,i.callbackname=l,c+=c.indexOf("?")>-1?"&":"?",c+="url="+encodeURIComponent(e)+"&callback="+l,s=k.createElement("script"),t[l]=function(e){"error:"===e.substring(0,6)?(i.succeeded=!1,x.numLoaded++,x.numFailed++,o()):(p(a,i),a.src=e),t[l]=n;try{delete t[l]}catch(r){}s.parentNode.removeChild(s),s=null,delete i.script,delete i.callbackname},s.setAttribute("type","text/javascript"),s.setAttribute("src",c),i.script=s,t.document.body.appendChild(s)}function l(e,n){var r=t.getComputedStyle(e,n),a=r.content;"url"===a.substr(0,3)&&m.loadImage(c.Util.parseBackgroundImage(a)[0].args[0]),u(r.backgroundImage,e)}function s(t){l(t,":before"),l(t,":after")}function d(t,e){var r=c.Generate.Gradient(t,e);r!==n&&(x[t]={img:r,succeeded:!0},x.numTotal++,x.numLoaded++,o())}function h(t){return t&&t.method&&t.args&&t.args.length>0}function u(t,e){var r;c.Util.parseBackgroundImage(t).filter(h).forEach(function(t){"url"===t.method?m.loadImage(t.args[0]):t.method.match(/\-?gradient$/)&&(r===n&&(r=c.Util.Bounds(e)),d(t.value,r))})}function f(t){var e=!1;try{b.Children(t).forEach(f)}catch(r){}try{e=t.nodeType}catch(a){e=!1,b.log("html2canvas: failed to access some element's nodeType - Exception: "+a.message)}if(1===e||e===n){s(t);try{u(b.getCSS(t,"backgroundImage"),t)}catch(r){b.log("html2canvas: failed to get background-image - Exception: "+r.message)}u(t)}}function p(e,a){e.onload=function(){a.timer!==n&&t.clearTimeout(a.timer),x.numLoaded++,a.succeeded=!0,e.onerror=e.onload=null,o()},e.onerror=function(){if("anonymous"===e.crossOrigin&&(t.clearTimeout(a.timer),r.proxy)){var l=e.src;return e=new Image,a.img=e,e.src=l,i(e.src,e,a),n}x.numLoaded++,x.numFailed++,a.succeeded=!1,e.onerror=e.onload=null,o()}}var g,m,y,w,x={numLoaded:0,numFailed:0,numTotal:0,cleanupDone:!1},b=c.Util,v=0,C=r.elements[0]||e.body,k=C.ownerDocument,T=C.getElementsByTagName("img"),E=T.length,S=k.createElement("a"),R=function(t){return t.crossOrigin!==n}(new Image);for(S.href=t.location.href,g=S.protocol+S.host,m={loadImage:function(t){var e,o;t&&x[t]===n&&(e=new Image,t.match(/data:image\/.*;base64,/i)?(e.src=t.replace(/url\(['"]{0,}|['"]{0,}\)$/gi,""),o=x[t]={img:e},x.numTotal++,p(e,o)):a(t)||r.allowTaint===!0?(o=x[t]={img:e},x.numTotal++,p(e,o),e.src=t):R&&!r.allowTaint&&r.useCORS?(e.crossOrigin="anonymous",o=x[t]={img:e},x.numTotal++,p(e,o),e.src=t):r.proxy&&(o=x[t]={img:e},x.numTotal++,i(t,e,o)))},cleanupDOM:function(a){var i,l;if(!x.cleanupDone){a&&"string"==typeof a?b.log("html2canvas: Cleanup because: "+a):b.log("html2canvas: Cleanup after timeout: "+r.timeout+" ms."); -for(l in x)if(x.hasOwnProperty(l)&&(i=x[l],"object"==typeof i&&i.callbackname&&i.succeeded===n)){t[i.callbackname]=n;try{delete t[i.callbackname]}catch(s){}i.script&&i.script.parentNode&&(i.script.setAttribute("src","about:blank"),i.script.parentNode.removeChild(i.script)),x.numLoaded++,x.numFailed++,b.log("html2canvas: Cleaned up failed img: '"+l+"' Steps: "+x.numLoaded+" / "+x.numTotal)}t.stop!==n?t.stop():e.execCommand!==n&&e.execCommand("Stop",!1),e.close!==n&&e.close(),x.cleanupDone=!0,a&&"string"==typeof a||o()}},renderingDone:function(){w&&t.clearTimeout(w)}},r.timeout>0&&(w=t.setTimeout(m.cleanupDOM,r.timeout)),b.log("html2canvas: Preload starts: finding background-images"),x.firstRun=!0,f(C),b.log("html2canvas: Preload: Finding images"),y=0;E>y;y+=1)m.loadImage(T[y].getAttribute("src"));return x.firstRun=!1,b.log("html2canvas: Preload: Done."),x.numTotal===x.numLoaded&&o(),m},c.Renderer=function(t,r){function a(t){function e(t){Object.keys(t).sort().forEach(function(n){var r=[],o=[],i=[],l=[];t[n].forEach(function(t){t.node.zIndex.isPositioned||1>t.node.zIndex.opacity?i.push(t):t.node.zIndex.isFloated?o.push(t):r.push(t)}),function s(t){t.forEach(function(t){l.push(t),t.children&&s(t.children)})}(r.concat(o,i)),l.forEach(function(t){t.context?e(t.context):a.push(t.node)})})}var r,a=[];return r=function(t){function e(t,r,a){var o="auto"===r.zIndex.zindex?0:Number(r.zIndex.zindex),i=t,l=r.zIndex.isPositioned,s=r.zIndex.isFloated,c={node:r},d=a;r.zIndex.ownStacking?(i=c.context={"!":[{node:r,children:[]}]},d=n):(l||s)&&(d=c.children=[]),0===o&&a?a.push(c):(t[o]||(t[o]=[]),t[o].push(c)),r.zIndex.children.forEach(function(t){e(i,t,d)})}var r={};return e(r,t),r}(t),e(r),a}function o(t){var e;if("string"==typeof r.renderer&&c.Renderer[t]!==n)e=c.Renderer[t](r);else{if("function"!=typeof t)throw Error("Unknown renderer");e=t(r)}if("function"!=typeof e)throw Error("Invalid renderer defined");return e}return o(r.renderer)(t,r,e,a(t.stack),c)},c.Util.Support=function(t,e){function r(){var t=new Image,r=e.createElement("canvas"),a=r.getContext===n?!1:r.getContext("2d");if(a===!1)return!1;r.width=r.height=10,t.src=["data:image/svg+xml,","","","
","sup","
","
","
"].join("");try{a.drawImage(t,0,0),r.toDataURL()}catch(o){return!1}return c.Util.log("html2canvas: Parse: SVG powered rendering available"),!0}function a(){var t,n,r,a,o=!1;return e.createRange&&(t=e.createRange(),t.getBoundingClientRect&&(n=e.createElement("boundtest"),n.style.height="123px",n.style.display="block",e.body.appendChild(n),t.selectNode(n),r=t.getBoundingClientRect(),a=r.height,123===a&&(o=!0),e.body.removeChild(n))),o}return{rangeBounds:a(),svgRendering:t.svgRendering&&r()}},t.html2canvas=function(e,n){e=e.length?e:[e];var r,a={logging:!1,elements:e,background:"#fff",proxy:null,timeout:0,useCORS:!1,allowTaint:!1,svgRendering:!1,ignoreElements:"IFRAME|OBJECT|PARAM",useOverflow:!0,letterRendering:!1,chinese:!1,async:!1,width:null,height:null,taintTest:!0,renderer:"Canvas"};return a=c.Util.Extend(n,a),c.logging=a.logging,a.complete=function(t){("function"!=typeof a.onpreloaded||a.onpreloaded(t)!==!1)&&c.Parse(t,a,function(t){("function"!=typeof a.onparsed||a.onparsed(t)!==!1)&&(r=c.Renderer(t,a),"function"==typeof a.onrendered&&a.onrendered(r))})},t.setTimeout(function(){c.Preload(a)},0),{render:function(t,e){return c.Renderer(t,c.Util.Extend(e,a))},parse:function(t,e){return c.Parse(t,c.Util.Extend(e,a))},preload:function(t){return c.Preload(c.Util.Extend(t,a))},log:c.Util.log}},t.html2canvas.log=c.Util.log,t.html2canvas.Renderer={Canvas:n},c.Renderer.Canvas=function(t){function r(t,e){t.beginPath(),e.forEach(function(e){t[e.name].apply(t,e.arguments)}),t.closePath()}function a(t){if(-1===l.indexOf(t.arguments[0].src)){d.drawImage(t.arguments[0],0,0);try{d.getImageData(0,0,1,1)}catch(e){return s=i.createElement("canvas"),d=s.getContext("2d"),!1}l.push(t.arguments[0].src)}return!0}function o(e,n){switch(n.type){case"variable":e[n.name]=n.arguments;break;case"function":switch(n.name){case"createPattern":if(n.arguments[0].width>0&&n.arguments[0].height>0)try{e.fillStyle=e.createPattern(n.arguments[0],"repeat")}catch(o){h.log("html2canvas: Renderer: Error creating pattern",o.message)}break;case"drawShape":r(e,n.arguments);break;case"drawImage":n.arguments[8]>0&&n.arguments[7]>0&&(!t.taintTest||t.taintTest&&a(n))&&e.drawImage.apply(e,n.arguments);break;default:e[n.name].apply(e,n.arguments)}}}t=t||{};var i=e,l=[],s=e.createElement("canvas"),d=s.getContext("2d"),h=c.Util,u=t.canvas||i.createElement("canvas");return function(t,e,r,a,i){var l,s,c,d=u.getContext("2d"),f=t.stack;return u.width=u.style.width=e.width||f.ctx.width,u.height=u.style.height=e.height||f.ctx.height,c=d.fillStyle,d.fillStyle=h.isTransparent(t.backgroundColor)&&e.background!==n?e.background:t.backgroundColor,d.fillRect(0,0,u.width,u.height),d.fillStyle=c,a.forEach(function(t){d.textBaseline="bottom",d.save(),t.transform.matrix&&(d.translate(t.transform.origin[0],t.transform.origin[1]),d.transform.apply(d,t.transform.matrix),d.translate(-t.transform.origin[0],-t.transform.origin[1])),t.clip&&(d.beginPath(),d.rect(t.clip.left,t.clip.top,t.clip.width,t.clip.height),d.clip()),t.ctx.storage&&t.ctx.storage.forEach(function(t){o(d,t)}),d.restore()}),h.log("html2canvas: Renderer: Canvas renderer done - returning canvas obj"),1===e.elements.length&&"object"==typeof e.elements[0]&&"BODY"!==e.elements[0].nodeName?(s=i.Util.Bounds(e.elements[0]),l=r.createElement("canvas"),l.width=Math.ceil(s.width),l.height=Math.ceil(s.height),d=l.getContext("2d"),d.drawImage(u,s.left,s.top,s.width,s.height,0,0,s.width,s.height),u=null,l):u}}})(window,document); \ No newline at end of file +(function(t,e,n){"use strict";function r(t,e,n){var r,a=t.runtimeStyle&&t.runtimeStyle[e],o=t.style;return!/^-?[0-9]+\.?[0-9]*(?:px)?$/i.test(n)&&/^-?\d/.test(n)&&(r=o.left,a&&(t.runtimeStyle.left=t.currentStyle.left),o.left="fontSize"===e?"1em":n||0,n=o.pixelLeft+"px",o.left=r,a&&(t.runtimeStyle.left=a)),/^(thin|medium|thick)$/i.test(n)?n:Math.round(parseFloat(n))+"px"}function a(t){return parseInt(t,10)}function o(t){return-1!==(""+t).indexOf("%")}function i(t,e,a,o){if(t=(t||"").split(","),t=t[o||0]||t[0]||"auto",t=d.Util.trimText(t).split(" "),"backgroundSize"===a&&t[0]&&t[0].match(/^(cover|contain|auto)$/))return t;if(t[0]=-1===t[0].indexOf("%")?r(e,a+"X",t[0]):t[0],t[1]===n){if("backgroundSize"===a)return t[1]="auto",t;t[1]=t[0]}return t[1]=-1===t[1].indexOf("%")?r(e,a+"Y",t[1]):t[1],t}function l(t,e){var n=[];return{storage:n,width:t,height:e,clip:function(){n.push({type:"function",name:"clip",arguments:arguments})},translate:function(){n.push({type:"function",name:"translate",arguments:arguments})},fill:function(){n.push({type:"function",name:"fill",arguments:arguments})},save:function(){n.push({type:"function",name:"save",arguments:arguments})},restore:function(){n.push({type:"function",name:"restore",arguments:arguments})},fillRect:function(){n.push({type:"function",name:"fillRect",arguments:arguments})},createPattern:function(){n.push({type:"function",name:"createPattern",arguments:arguments})},drawShape:function(){var t=[];return n.push({type:"function",name:"drawShape",arguments:t}),{moveTo:function(){t.push({name:"moveTo",arguments:arguments})},lineTo:function(){t.push({name:"lineTo",arguments:arguments})},arcTo:function(){t.push({name:"arcTo",arguments:arguments})},bezierCurveTo:function(){t.push({name:"bezierCurveTo",arguments:arguments})},quadraticCurveTo:function(){t.push({name:"quadraticCurveTo",arguments:arguments})}}},drawImage:function(){n.push({type:"function",name:"drawImage",arguments:arguments})},fillText:function(){n.push({type:"function",name:"fillText",arguments:arguments})},setVariable:function(t,e){return n.push({type:"variable",name:t,arguments:e}),e}}}var s,c,d={};d.Util={},d.Util.log=function(e){d.logging&&t.console&&t.console.log&&t.console.log(e)},d.Util.trimText=function(t){return function(e){return t?t.apply(e):((e||"")+"").replace(/^\s+|\s+$/g,"")}}(String.prototype.trim),d.Util.asFloat=function(t){return parseFloat(t)},function(){var t=/((rgba|rgb)\([^\)]+\)(\s-?\d+px){0,})/g,e=/(-?\d+px)|(#.+)|(rgb\(.+\))|(rgba\(.+\))/g;d.Util.parseTextShadows=function(n){if(!n||"none"===n)return[];for(var r=n.match(t),a=[],o=0;r&&r.length>o;o++){var i=r[o].match(e);a.push({color:i[0],offsetX:i[1]?i[1].replace("px",""):0,offsetY:i[2]?i[2].replace("px",""):0,blur:i[3]?i[3].replace("px",""):0})}return a}}(),d.Util.parseBackgroundImage=function(t){var e,n,r,a,o,i,l,s,c=" \r\n ",d=[],h=0,u=0,f=function(){e&&('"'===n.substr(0,1)&&(n=n.substr(1,n.length-2)),n&&s.push(n),"-"===e.substr(0,1)&&(a=e.indexOf("-",1)+1)>0&&(r=e.substr(0,a),e=e.substr(a)),d.push({prefix:r,method:e.toLowerCase(),value:o,args:s})),s=[],e=r=n=o=""};f();for(var p=0,g=t.length;g>p;p++)if(i=t[p],!(0===h&&c.indexOf(i)>-1)){switch(i){case'"':l?l===i&&(l=null):l=i;break;case"(":if(l)break;if(0===h){h=1,o+=i;continue}u++;break;case")":if(l)break;if(1===h){if(0===u){h=0,o+=i,f();continue}u--}break;case",":if(l)break;if(0===h){f();continue}if(1===h&&0===u&&!e.match(/^url$/i)){s.push(n),n="",o+=i;continue}}o+=i,0===h?e+=i:n+=i}return f(),d},d.Util.Bounds=function(t){var e,n={};return t.getBoundingClientRect&&(e=t.getBoundingClientRect(),n.top=e.top,n.bottom=e.bottom||e.top+e.height,n.left=e.left,n.width=t.offsetWidth,n.height=t.offsetHeight),n},d.Util.OffsetBounds=function(t){var e=t.offsetParent?d.Util.OffsetBounds(t.offsetParent):{top:0,left:0};return{top:t.offsetTop+e.top,bottom:t.offsetTop+t.offsetHeight+e.top,left:t.offsetLeft+e.left,width:t.offsetWidth,height:t.offsetHeight}},d.Util.getCSS=function(t,n,r){s!==t&&(c=e.defaultView.getComputedStyle(t,null));var o=c[n];if(/^background(Size|Position)$/.test(n))return i(o,t,n,r);if(/border(Top|Bottom)(Left|Right)Radius/.test(n)){var l=o.split(" ");return 1>=l.length&&(l[1]=l[0]),l.map(a)}return o},d.Util.resizeBounds=function(t,e,n,r,a){var o,i,l=n/r,s=t/e;return a&&"auto"!==a?s>l^"contain"===a?(i=r,o=r*s):(o=n,i=n/s):(o=n,i=r),{width:o,height:i}},d.Util.BackgroundPosition=function(t,e,n,r,a){var i,l,s=d.Util.getCSS(t,"backgroundPosition",r);return 1===s.length&&(s=[s[0],s[0]]),i=o(s[0])?(e.width-(a||n).width)*(parseFloat(s[0])/100):parseInt(s[0],10),l="auto"===s[1]?i/n.width*n.height:o(s[1])?(e.height-(a||n).height)*parseFloat(s[1])/100:parseInt(s[1],10),"auto"===s[0]&&(i=l/n.height*n.width),{left:i,top:l}},d.Util.BackgroundSize=function(t,e,n,r){var a,i,l=d.Util.getCSS(t,"backgroundSize",r);if(1===l.length&&(l=[l[0],l[0]]),o(l[0]))a=e.width*parseFloat(l[0])/100;else{if(/contain|cover/.test(l[0]))return d.Util.resizeBounds(n.width,n.height,e.width,e.height,l[0]);a=parseInt(l[0],10)}return i="auto"===l[0]&&"auto"===l[1]?n.height:"auto"===l[1]?a/n.width*n.height:o(l[1])?e.height*parseFloat(l[1])/100:parseInt(l[1],10),"auto"===l[0]&&(a=i/n.height*n.width),{width:a,height:i}},d.Util.BackgroundRepeat=function(t,e){var n=d.Util.getCSS(t,"backgroundRepeat").split(",").map(d.Util.trimText);return n[e]||n[0]},d.Util.Extend=function(t,e){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},d.Util.Children=function(t){var e;try{e=t.nodeName&&"IFRAME"===t.nodeName.toUpperCase()?t.contentDocument||t.contentWindow.document:function(t){var e=[];return null!==t&&function(t,e){var r=t.length,a=0;if("number"==typeof e.length)for(var o=e.length;o>a;a++)t[r++]=e[a];else for(;e[a]!==n;)t[r++]=e[a++];return t.length=r,t}(e,t),e}(t.childNodes)}catch(r){d.Util.log("html2canvas.Util.Children failed with exception: "+r.message),e=[]}return e},d.Util.isTransparent=function(t){return!t||"transparent"===t||"rgba(0, 0, 0, 0)"===t},d.Util.Font=function(){var t={};return function(e,r,a){if(t[e+"-"+r]!==n)return t[e+"-"+r];var o,i,l,s=a.createElement("div"),c=a.createElement("img"),d=a.createElement("span"),h="Hidden Text";return s.style.visibility="hidden",s.style.fontFamily=e,s.style.fontSize=r,s.style.margin=0,s.style.padding=0,a.body.appendChild(s),c.src="data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACwAAAAAAQABAAACAkQBADs=",c.width=1,c.height=1,c.style.margin=0,c.style.padding=0,c.style.verticalAlign="baseline",d.style.fontFamily=e,d.style.fontSize=r,d.style.margin=0,d.style.padding=0,d.appendChild(a.createTextNode(h)),s.appendChild(d),s.appendChild(c),o=c.offsetTop-d.offsetTop+1,s.removeChild(d),s.appendChild(a.createTextNode(h)),s.style.lineHeight="normal",c.style.verticalAlign="super",i=c.offsetTop-s.offsetTop+1,l={baseline:o,lineWidth:1,middle:i},t[e+"-"+r]=l,a.body.removeChild(s),l}}(),function(){function t(t){return function(e){try{t.addColorStop(e.stop,e.color)}catch(r){n.log(["failed to add color stop: ",r,"; tried to add: ",e])}}}var n=d.Util,r={};d.Generate=r;var a=[/^(-webkit-linear-gradient)\(([a-z\s]+)([\w\d\.\s,%\(\)]+)\)$/,/^(-o-linear-gradient)\(([a-z\s]+)([\w\d\.\s,%\(\)]+)\)$/,/^(-webkit-gradient)\((linear|radial),\s((?:\d{1,3}%?)\s(?:\d{1,3}%?),\s(?:\d{1,3}%?)\s(?:\d{1,3}%?))([\w\d\.\s,%\(\)\-]+)\)$/,/^(-moz-linear-gradient)\(((?:\d{1,3}%?)\s(?:\d{1,3}%?))([\w\d\.\s,%\(\)]+)\)$/,/^(-webkit-radial-gradient)\(((?:\d{1,3}%?)\s(?:\d{1,3}%?)),\s(\w+)\s([a-z\-]+)([\w\d\.\s,%\(\)]+)\)$/,/^(-moz-radial-gradient)\(((?:\d{1,3}%?)\s(?:\d{1,3}%?)),\s(\w+)\s?([a-z\-]*)([\w\d\.\s,%\(\)]+)\)$/,/^(-o-radial-gradient)\(((?:\d{1,3}%?)\s(?:\d{1,3}%?)),\s(\w+)\s([a-z\-]+)([\w\d\.\s,%\(\)]+)\)$/];r.parseGradient=function(t,e){var n,r,o,i,l,s,c,d,h,u,f,p,g=a.length;for(r=0;g>r&&!(o=t.match(a[r]));r+=1);if(o)switch(o[1]){case"-webkit-linear-gradient":case"-o-linear-gradient":if(n={type:"linear",x0:null,y0:null,x1:null,y1:null,colorStops:[]},l=o[2].match(/\w+/g))for(s=l.length,r=0;s>r;r+=1)switch(l[r]){case"top":n.y0=0,n.y1=e.height;break;case"right":n.x0=e.width,n.x1=0;break;case"bottom":n.y0=e.height,n.y1=0;break;case"left":n.x0=0,n.x1=e.width}if(null===n.x0&&null===n.x1&&(n.x0=n.x1=e.width/2),null===n.y0&&null===n.y1&&(n.y0=n.y1=e.height/2),l=o[3].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\)(?:\s\d{1,3}(?:%|px))?)+/g))for(s=l.length,c=1/Math.max(s-1,1),r=0;s>r;r+=1)d=l[r].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\))\s*(\d{1,3})?(%|px)?/),d[2]?(i=parseFloat(d[2]),i/="%"===d[3]?100:e.width):i=r*c,n.colorStops.push({color:d[1],stop:i});break;case"-webkit-gradient":if(n={type:"radial"===o[2]?"circle":o[2],x0:0,y0:0,x1:0,y1:0,colorStops:[]},l=o[3].match(/(\d{1,3})%?\s(\d{1,3})%?,\s(\d{1,3})%?\s(\d{1,3})%?/),l&&(n.x0=l[1]*e.width/100,n.y0=l[2]*e.height/100,n.x1=l[3]*e.width/100,n.y1=l[4]*e.height/100),l=o[4].match(/((?:from|to|color-stop)\((?:[0-9\.]+,\s)?(?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\)\))+/g))for(s=l.length,r=0;s>r;r+=1)d=l[r].match(/(from|to|color-stop)\(([0-9\.]+)?(?:,\s)?((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\))\)/),i=parseFloat(d[2]),"from"===d[1]&&(i=0),"to"===d[1]&&(i=1),n.colorStops.push({color:d[3],stop:i});break;case"-moz-linear-gradient":if(n={type:"linear",x0:0,y0:0,x1:0,y1:0,colorStops:[]},l=o[2].match(/(\d{1,3})%?\s(\d{1,3})%?/),l&&(n.x0=l[1]*e.width/100,n.y0=l[2]*e.height/100,n.x1=e.width-n.x0,n.y1=e.height-n.y0),l=o[3].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\)(?:\s\d{1,3}%)?)+/g))for(s=l.length,c=1/Math.max(s-1,1),r=0;s>r;r+=1)d=l[r].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\))\s*(\d{1,3})?(%)?/),d[2]?(i=parseFloat(d[2]),d[3]&&(i/=100)):i=r*c,n.colorStops.push({color:d[1],stop:i});break;case"-webkit-radial-gradient":case"-moz-radial-gradient":case"-o-radial-gradient":if(n={type:"circle",x0:0,y0:0,x1:e.width,y1:e.height,cx:0,cy:0,rx:0,ry:0,colorStops:[]},l=o[2].match(/(\d{1,3})%?\s(\d{1,3})%?/),l&&(n.cx=l[1]*e.width/100,n.cy=l[2]*e.height/100),l=o[3].match(/\w+/),d=o[4].match(/[a-z\-]*/),l&&d)switch(d[0]){case"farthest-corner":case"cover":case"":h=Math.sqrt(Math.pow(n.cx,2)+Math.pow(n.cy,2)),u=Math.sqrt(Math.pow(n.cx,2)+Math.pow(n.y1-n.cy,2)),f=Math.sqrt(Math.pow(n.x1-n.cx,2)+Math.pow(n.y1-n.cy,2)),p=Math.sqrt(Math.pow(n.x1-n.cx,2)+Math.pow(n.cy,2)),n.rx=n.ry=Math.max(h,u,f,p);break;case"closest-corner":h=Math.sqrt(Math.pow(n.cx,2)+Math.pow(n.cy,2)),u=Math.sqrt(Math.pow(n.cx,2)+Math.pow(n.y1-n.cy,2)),f=Math.sqrt(Math.pow(n.x1-n.cx,2)+Math.pow(n.y1-n.cy,2)),p=Math.sqrt(Math.pow(n.x1-n.cx,2)+Math.pow(n.cy,2)),n.rx=n.ry=Math.min(h,u,f,p);break;case"farthest-side":"circle"===l[0]?n.rx=n.ry=Math.max(n.cx,n.cy,n.x1-n.cx,n.y1-n.cy):(n.type=l[0],n.rx=Math.max(n.cx,n.x1-n.cx),n.ry=Math.max(n.cy,n.y1-n.cy));break;case"closest-side":case"contain":"circle"===l[0]?n.rx=n.ry=Math.min(n.cx,n.cy,n.x1-n.cx,n.y1-n.cy):(n.type=l[0],n.rx=Math.min(n.cx,n.x1-n.cx),n.ry=Math.min(n.cy,n.y1-n.cy))}if(l=o[5].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\)(?:\s\d{1,3}(?:%|px))?)+/g))for(s=l.length,c=1/Math.max(s-1,1),r=0;s>r;r+=1)d=l[r].match(/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\))\s*(\d{1,3})?(%|px)?/),d[2]?(i=parseFloat(d[2]),i/="%"===d[3]?100:e.width):i=r*c,n.colorStops.push({color:d[1],stop:i})}return n},r.Gradient=function(n,r){if(0!==r.width&&0!==r.height){var a,o,i=e.createElement("canvas"),l=i.getContext("2d");if(i.width=r.width,i.height=r.height,a=d.Generate.parseGradient(n,r))switch(a.type){case"linear":o=l.createLinearGradient(a.x0,a.y0,a.x1,a.y1),a.colorStops.forEach(t(o)),l.fillStyle=o,l.fillRect(0,0,r.width,r.height);break;case"circle":o=l.createRadialGradient(a.cx,a.cy,0,a.cx,a.cy,a.rx),a.colorStops.forEach(t(o)),l.fillStyle=o,l.fillRect(0,0,r.width,r.height);break;case"ellipse":var s=e.createElement("canvas"),c=s.getContext("2d"),h=Math.max(a.rx,a.ry),u=2*h;s.width=s.height=u,o=c.createRadialGradient(a.rx,a.ry,0,a.rx,a.ry,h),a.colorStops.forEach(t(o)),c.fillStyle=o,c.fillRect(0,0,u,u),l.fillStyle=a.colorStops[a.colorStops.length-1].color,l.fillRect(0,0,i.width,i.height),l.drawImage(s,a.cx-a.rx,a.cy-a.ry,2*a.rx,2*a.ry)}return i}},r.ListAlpha=function(t){var e,n="";do e=t%26,n=String.fromCharCode(e+64)+n,t/=26;while(26*t>26);return n},r.ListRoman=function(t){var e,n=["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"],r=[1e3,900,500,400,100,90,50,40,10,9,5,4,1],a="",o=n.length;if(0>=t||t>=4e3)return t;for(e=0;o>e;e+=1)for(;t>=r[e];)t-=r[e],a+=n[e];return a}}(),d.Parse=function(r,a,o){function i(){var t=be(e.documentElement,"backgroundColor"),n=me.isTransparent(t)&&fe===e.body,r=ce(fe,null,!1,n);s(fe),ue(fe,r,function(){n&&(t=r.backgroundColor),c(),me.log("Done parsing, moving to Render."),o({backgroundColor:t,stack:r})})}function s(t){function n(){for(var t=/:before|:after/,n=e.styleSheets,r=0,a=n.length;a>r;r++)try{for(var o=n[r].cssRules,i=0,s=o.length;s>i;i++)t.test(o[i].selectorText)&&l.push(o[i].selectorText)}catch(c){}for(r=0,a=l.length;a>r;r++)l[r]=l[r].match(/(^[^:]*)/)[1]}function r(){for(var t=e.querySelectorAll(l.join(",")),n=0,r=t.length;r>n;n++)a(t[n])}function a(t){var e=Y(t,":before"),n=Y(t,":after");e&&i.push({type:"before",pseudo:e,el:t}),n&&i.push({type:"after",pseudo:n,el:t})}function o(){i.forEach(function(t){h(t.el,ve+"-parent")}),i.forEach(function(t){"before"===t.type?t.el.insertBefore(t.pseudo,t.el.firstChild):t.el.appendChild(t.pseudo)})}var i=[],l=[];n(),r(t),o()}function c(){xe.removeChild(Ce);for(var t=e.getElementsByClassName(ve+"-element");t.length;)t[0].parentNode.removeChild(t[0]);for(var n=e.getElementsByClassName(ve+"-parent");n.length;)u(n[0],ve+"-parent")}function h(t,e){t.classList?t.classList.add(e):t.className=t.className+" "+e}function u(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(e,"").trim()}function f(){return Math.max(Math.max(ge.body.scrollWidth,ge.documentElement.scrollWidth),Math.max(ge.body.offsetWidth,ge.documentElement.offsetWidth),Math.max(ge.body.clientWidth,ge.documentElement.clientWidth))}function p(){return Math.max(Math.max(ge.body.scrollHeight,ge.documentElement.scrollHeight),Math.max(ge.body.offsetHeight,ge.documentElement.offsetHeight),Math.max(ge.body.clientHeight,ge.documentElement.clientHeight))}function g(t,e){var n=parseInt(be(t,e),10);return isNaN(n)?0:n}function m(t,e,n,r,a,o){"transparent"!==o&&(t.setVariable("fillStyle",o),t.fillRect(e,n,r,a),pe+=1)}function y(t,e,r){return t.length>0?e+r.toUpperCase():n}function w(t,e){switch(e){case"lowercase":return t.toLowerCase();case"capitalize":return t.replace(/(^|\s|:|-|\(|\))([a-z])/g,y);case"uppercase":return t.toUpperCase();default:return t}}function x(t){return/^(normal|none|0px)$/.test(t)}function b(t,e,n,r){null!==t&&me.trimText(t).length>0&&(r.fillText(t,e,n),pe+=1)}function v(t,e,r,a){var o=!1,i=be(e,"fontWeight"),l=be(e,"fontFamily"),s=be(e,"fontSize"),c=me.parseTextShadows(be(e,"textShadow"));switch(parseInt(i,10)){case 401:i="bold";break;case 400:i="normal"}return t.setVariable("fillStyle",a),t.setVariable("font",[be(e,"fontStyle"),be(e,"fontVariant"),i,s,l].join(" ")),t.setVariable("textAlign",o?"right":"left"),c.length&&(t.setVariable("shadowColor",c[0].color),t.setVariable("shadowOffsetX",c[0].offsetX),t.setVariable("shadowOffsetY",c[0].offsetY),t.setVariable("shadowBlur",c[0].blur)),"none"!==r?me.Font(l,s,ge):n}function C(t,e,n,r,a){switch(e){case"underline":m(t,n.left,Math.round(n.top+r.baseline+r.lineWidth),n.width,1,a);break;case"overline":m(t,n.left,Math.round(n.top),n.width,1,a);break;case"line-through":m(t,n.left,Math.ceil(n.top+r.middle+r.lineWidth),n.width,1,a)}}function k(t,e,n,r,a){var o;if(ye.rangeBounds&&!a)("none"!==n||0!==me.trimText(e).length)&&(o=T(e,t.node,t.textOffset)),t.textOffset+=e.length;else if(t.node&&"string"==typeof t.node.nodeValue){var i=r?t.node.splitText(e.length):null;o=S(t.node,a),t.node=i}return o}function T(t,e,n){var r=ge.createRange();return r.setStart(e,n),r.setEnd(e,n+t.length),r.getBoundingClientRect()}function S(t,e){var n=t.parentNode,r=ge.createElement("wrapper"),a=t.cloneNode(!0);r.appendChild(t.cloneNode(!0)),n.replaceChild(r,t);var o=e?me.OffsetBounds(r):me.Bounds(r);return n.replaceChild(a,r),o}function E(t,e,n){var r,o,i=n.ctx,l=be(t,"color"),s=be(t,"textDecoration"),c=be(t,"textAlign"),d={node:e,textOffset:0};me.trimText(e.nodeValue).length>0&&(e.nodeValue=w(e.nodeValue,be(t,"textTransform")),c=c.replace(["-webkit-auto"],["auto"]),o=!a.letterRendering&&/^(left|right|justify|auto)$/.test(c)&&x(be(t,"letterSpacing"))?e.nodeValue.split(/(\b| )/):e.nodeValue.split(""),r=v(i,t,s,l),a.chinese&&o.forEach(function(t,e){/.*[\u4E00-\u9FA5].*$/.test(t)&&(t=t.split(""),t.unshift(e,1),o.splice.apply(o,t))}),o.forEach(function(t,e){var a=k(d,t,s,o.length-1>e,n.transform.matrix);a&&(b(t,a.left,a.bottom,i),C(i,s,a,r,l))}))}function R(t,e){var n,r,a=ge.createElement("boundelement");return a.style.display="inline",n=t.style.listStyleType,t.style.listStyleType="none",a.appendChild(ge.createTextNode(e)),t.insertBefore(a,t.firstChild),r=me.Bounds(a),t.removeChild(a),t.style.listStyleType=n,r}function M(t){var e=-1,n=1,r=t.parentNode.childNodes;if(t.parentNode){for(;r[++e]!==t;)1===r[e].nodeType&&n++;return n}return-1}function I(t,e){var n,r=M(t);switch(e){case"decimal":n=r;break;case"decimal-leading-zero":n=1===(""+r).length?r="0"+(""+r):""+r;break;case"upper-roman":n=d.Generate.ListRoman(r);break;case"lower-roman":n=d.Generate.ListRoman(r).toLowerCase();break;case"lower-alpha":n=d.Generate.ListAlpha(r).toLowerCase();break;case"upper-alpha":n=d.Generate.ListAlpha(r)}return n+". "}function L(t,e,n){var r,a,o,i=e.ctx,l=be(t,"listStyleType");if(/^(decimal|decimal-leading-zero|upper-alpha|upper-latin|upper-roman|lower-alpha|lower-greek|lower-latin|lower-roman)$/i.test(l)){if(a=I(t,l),o=R(t,a),v(i,t,"none",be(t,"color")),"inside"!==be(t,"listStylePosition"))return;i.setVariable("textAlign","left"),r=n.left,b(a,r,o.bottom,i)}}function O(t){var e=r[t];return e&&e.succeeded===!0?e.img:!1}function z(t,e){var n=Math.max(t.left,e.left),r=Math.max(t.top,e.top),a=Math.min(t.left+t.width,e.left+e.width),o=Math.min(t.top+t.height,e.top+e.height);return{left:n,top:r,width:a-n,height:o-r}}function B(t,e,n){var r,a="static"!==e.cssPosition,o=a?be(t,"zIndex"):"auto",i=be(t,"opacity"),l="none"!==be(t,"cssFloat");e.zIndex=r=U(o),r.isPositioned=a,r.isFloated=l,r.opacity=i,r.ownStacking="auto"!==o||1>i,r.depth=n?n.zIndex.depth+1:0,n&&n.zIndex.children.push(e)}function U(t){return{depth:0,zindex:t,children:[]}}function A(t,e,n,r,a){var o=g(e,"paddingLeft"),i=g(e,"paddingTop"),l=g(e,"paddingRight"),s=g(e,"paddingBottom");_(t,n,0,0,n.width,n.height,r.left+o+a[3].width,r.top+i+a[0].width,r.width-(a[1].width+a[3].width+o+l),r.height-(a[0].width+a[2].width+i+s))}function N(t){return["Top","Right","Bottom","Left"].map(function(e){return{width:g(t,"border"+e+"Width"),color:be(t,"border"+e+"Color")}})}function P(t){return["TopLeft","TopRight","BottomRight","BottomLeft"].map(function(e){return be(t,"border"+e+"Radius")})}function F(t,e,n,r){var a=4*((Math.sqrt(2)-1)/3),o=n*a,i=r*a,l=t+n,s=e+r;return{topLeft:V({x:t,y:s},{x:t,y:s-i},{x:l-o,y:e},{x:l,y:e}),topRight:V({x:t,y:e},{x:t+o,y:e},{x:l,y:s-i},{x:l,y:s}),bottomRight:V({x:l,y:e},{x:l,y:e+i},{x:t+o,y:s},{x:t,y:s}),bottomLeft:V({x:l,y:s},{x:l-o,y:s},{x:t,y:e+i},{x:t,y:e})}}function V(t,e,n,r){var a=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:r,subdivide:function(o){var i=a(t,e,o),l=a(e,n,o),s=a(n,r,o),c=a(i,l,o),d=a(l,s,o),h=a(c,d,o);return[V(t,i,c,h),V(h,d,s,r)]},curveTo:function(t){t.push(["bezierCurve",e.x,e.y,n.x,n.y,r.x,r.y])},curveToReversed:function(r){r.push(["bezierCurve",n.x,n.y,e.x,e.y,t.x,t.y])}}}function D(t,e,n,r,a,o,i){e[0]>0||e[1]>0?(t.push(["line",r[0].start.x,r[0].start.y]),r[0].curveTo(t),r[1].curveTo(t)):t.push(["line",o,i]),(n[0]>0||n[1]>0)&&t.push(["line",a[0].start.x,a[0].start.y])}function $(t,e,n,r,a,o,i){var l=[];return e[0]>0||e[1]>0?(l.push(["line",r[1].start.x,r[1].start.y]),r[1].curveTo(l)):l.push(["line",t.c1[0],t.c1[1]]),n[0]>0||n[1]>0?(l.push(["line",o[0].start.x,o[0].start.y]),o[0].curveTo(l),l.push(["line",i[0].end.x,i[0].end.y]),i[0].curveToReversed(l)):(l.push(["line",t.c2[0],t.c2[1]]),l.push(["line",t.c3[0],t.c3[1]])),e[0]>0||e[1]>0?(l.push(["line",a[1].end.x,a[1].end.y]),a[1].curveToReversed(l)):l.push(["line",t.c4[0],t.c4[1]]),l}function G(t,e,n){var r=t.left,a=t.top,o=t.width,i=t.height,l=e[0][0],s=e[0][1],c=e[1][0],d=e[1][1],h=e[2][0],u=e[2][1],f=e[3][0],p=e[3][1],g=o-c,m=i-u,y=o-h,w=i-p;return{topLeftOuter:F(r,a,l,s).topLeft.subdivide(.5),topLeftInner:F(r+n[3].width,a+n[0].width,Math.max(0,l-n[3].width),Math.max(0,s-n[0].width)).topLeft.subdivide(.5),topRightOuter:F(r+g,a,c,d).topRight.subdivide(.5),topRightInner:F(r+Math.min(g,o+n[3].width),a+n[0].width,g>o+n[3].width?0:c-n[3].width,d-n[0].width).topRight.subdivide(.5),bottomRightOuter:F(r+y,a+m,h,u).bottomRight.subdivide(.5),bottomRightInner:F(r+Math.min(y,o+n[3].width),a+Math.min(m,i+n[0].width),Math.max(0,h-n[1].width),Math.max(0,u-n[2].width)).bottomRight.subdivide(.5),bottomLeftOuter:F(r,a+w,f,p).bottomLeft.subdivide(.5),bottomLeftInner:F(r+n[3].width,a+w,Math.max(0,f-n[3].width),Math.max(0,p-n[2].width)).bottomLeft.subdivide(.5)}}function W(t,e,n,r,a){var o=be(t,"backgroundClip"),i=[];switch(o){case"content-box":case"padding-box":D(i,r[0],r[1],e.topLeftInner,e.topRightInner,a.left+n[3].width,a.top+n[0].width),D(i,r[1],r[2],e.topRightInner,e.bottomRightInner,a.left+a.width-n[1].width,a.top+n[0].width),D(i,r[2],r[3],e.bottomRightInner,e.bottomLeftInner,a.left+a.width-n[1].width,a.top+a.height-n[2].width),D(i,r[3],r[0],e.bottomLeftInner,e.topLeftInner,a.left+n[3].width,a.top+a.height-n[2].width);break;default:D(i,r[0],r[1],e.topLeftOuter,e.topRightOuter,a.left,a.top),D(i,r[1],r[2],e.topRightOuter,e.bottomRightOuter,a.left+a.width,a.top),D(i,r[2],r[3],e.bottomRightOuter,e.bottomLeftOuter,a.left+a.width,a.top+a.height),D(i,r[3],r[0],e.bottomLeftOuter,e.topLeftOuter,a.left,a.top+a.height)}return i}function H(t,e,n){var r,a,o,i,l,s,c=e.left,d=e.top,h=e.width,u=e.height,f=P(t),p=G(e,f,n),g={clip:W(t,p,n,f,e),borders:[]};for(r=0;4>r;r++)if(n[r].width>0){switch(a=c,o=d,i=h,l=u-n[2].width,r){case 0:l=n[0].width,s=$({c1:[a,o],c2:[a+i,o],c3:[a+i-n[1].width,o+l],c4:[a+n[3].width,o+l]},f[0],f[1],p.topLeftOuter,p.topLeftInner,p.topRightOuter,p.topRightInner);break;case 1:a=c+h-n[1].width,i=n[1].width,s=$({c1:[a+i,o],c2:[a+i,o+l+n[2].width],c3:[a,o+l],c4:[a,o+n[0].width]},f[1],f[2],p.topRightOuter,p.topRightInner,p.bottomRightOuter,p.bottomRightInner);break;case 2:o=o+u-n[2].width,l=n[2].width,s=$({c1:[a+i,o+l],c2:[a,o+l],c3:[a+n[3].width,o],c4:[a+i-n[3].width,o]},f[2],f[3],p.bottomRightOuter,p.bottomRightInner,p.bottomLeftOuter,p.bottomLeftInner);break;case 3:i=n[3].width,s=$({c1:[a,o+l+n[2].width],c2:[a,o],c3:[a+i,o+n[0].width],c4:[a+i,o+l]},f[3],f[0],p.bottomLeftOuter,p.bottomLeftInner,p.topLeftOuter,p.topLeftInner)}g.borders.push({args:s,color:n[r].color})}return g}function j(t,e){var n=t.drawShape();return e.forEach(function(t,e){n[0===e?"moveTo":t[0]+"To"].apply(null,t.slice(1))}),n}function q(t,e,n){"transparent"!==n&&(t.setVariable("fillStyle",n),j(t,e),t.fill(),pe+=1)}function X(t,e,n){var r,a,o=ge.createElement("valuewrap"),i=["lineHeight","textAlign","fontFamily","color","fontSize","paddingLeft","paddingTop","width","height","border","borderLeftWidth","borderTopWidth"];i.forEach(function(e){try{o.style[e]=be(t,e)}catch(n){me.log("html2canvas: Parse: Exception caught in renderFormValue: "+n.message)}}),o.style.borderColor="black",o.style.borderStyle="solid",o.style.display="block",o.style.position="absolute",(/^(submit|reset|button|text|password)$/.test(t.type)||"SELECT"===t.nodeName)&&(o.style.lineHeight=be(t,"height")),o.style.top=e.top+"px",o.style.left=e.left+"px",r="SELECT"===t.nodeName?(t.options[t.selectedIndex]||0).text:t.value,r||(r=t.placeholder),a=ge.createTextNode(r),o.appendChild(a),xe.appendChild(o),E(t,a,n),xe.removeChild(o)}function _(t){t.drawImage.apply(t,Array.prototype.slice.call(arguments,1)),pe+=1}function Y(n,r){var a=t.getComputedStyle(n,r),o=t.getComputedStyle(n);if(a&&a.content&&"none"!==a.content&&"-moz-alt-content"!==a.content&&"none"!==a.display&&o.content!==a.content){var i=a.content+"";("'"===i[0]||'"'===i[0])&&(i=i.replace(/(^['"])|(['"]$)/g,""));var l="url"===i.substr(0,3),s=e.createElement(l?"img":"span");return s.className=ve+"-element ",Object.keys(a).filter(Q).forEach(function(t){try{s.style[t]=a[t]}catch(e){me.log(["Tried to assign readonly property ",t,"Error:",e])}}),l?s.src=me.parseBackgroundImage(i)[0].args[0]:s.innerHTML=i,s}}function Q(e){return isNaN(t.parseInt(e,10))}function J(t,e,n,r){var a=Math.round(r.left+n.left),o=Math.round(r.top+n.top);t.createPattern(e),t.translate(a,o),t.fill(),t.translate(-a,-o)}function K(t,e,n,r,a,o,i,l){var s=[];s.push(["line",Math.round(a),Math.round(o)]),s.push(["line",Math.round(a+i),Math.round(o)]),s.push(["line",Math.round(a+i),Math.round(l+o)]),s.push(["line",Math.round(a),Math.round(l+o)]),j(t,s),t.save(),t.clip(),J(t,e,n,r),t.restore()}function Z(t,e,n){m(t,e.left,e.top,e.width,e.height,n)}function te(t,e,n,r,a){var o=me.BackgroundSize(t,e,r,a),i=me.BackgroundPosition(t,e,r,a,o),l=me.BackgroundRepeat(t,a);switch(r=ne(r,o),l){case"repeat-x":case"repeat no-repeat":K(n,r,i,e,e.left,e.top+i.top,99999,r.height);break;case"repeat-y":case"no-repeat repeat":K(n,r,i,e,e.left+i.left,e.top,r.width,99999);break;case"no-repeat":K(n,r,i,e,e.left+i.left,e.top+i.top,r.width,r.height);break;default:J(n,r,i,{top:e.top,left:e.left,width:r.width,height:r.height})}}function ee(t,e,n){for(var r,a=be(t,"backgroundImage"),o=me.parseBackgroundImage(a),i=o.length;i--;)if(a=o[i],a.args&&0!==a.args.length){var l="url"===a.method?a.args[0]:a.value;r=O(l),r?te(t,e,n,r,i):me.log("html2canvas: Error loading background:",a)}}function ne(t,e){if(t.width===e.width&&t.height===e.height)return t;var n,r=ge.createElement("canvas");return r.width=e.width,r.height=e.height,n=r.getContext("2d"),_(n,t,0,0,t.width,t.height,0,0,e.width,e.height),r}function re(t,e,n){return t.setVariable("globalAlpha",be(e,"opacity")*(n?n.opacity:1))}function ae(t){return t.replace("px","")}function oe(t){var e=/(matrix)\((.+)\)/,n=be(t,"transform")||be(t,"-webkit-transform")||be(t,"-moz-transform")||be(t,"-ms-transform")||be(t,"-o-transform"),r=be(t,"transform-origin")||be(t,"-webkit-transform-origin")||be(t,"-moz-transform-origin")||be(t,"-ms-transform-origin")||be(t,"-o-transform-origin")||"0px 0px";r=r.split(" ").map(ae).map(me.asFloat);var a;if(n&&"none"!==n){var o=n.match(e);if(o)switch(o[1]){case"matrix":a=o[2].split(",").map(me.trimText).map(me.asFloat)}}return{origin:r,matrix:a}}function ie(t,e,n,r){var o=l(e?n.width:f(),e?n.height:p()),i={ctx:o,opacity:re(o,t,e),cssPosition:be(t,"position"),borders:N(t),transform:r,clip:e&&e.clip?me.Extend({},e.clip):null};return B(t,i,e),a.useOverflow===!0&&/(hidden|scroll|auto)/.test(be(t,"overflow"))===!0&&/(BODY)/i.test(t.nodeName)===!1&&(i.clip=i.clip?z(i.clip,n):n),i}function le(t,e,n){var r={left:e.left+t[3].width,top:e.top+t[0].width,width:e.width-(t[1].width+t[3].width),height:e.height-(t[0].width+t[2].width)};return n&&(r=z(r,n)),r}function se(t,e){var n=e.matrix?me.OffsetBounds(t):me.Bounds(t);return e.origin[0]+=n.left,e.origin[1]+=n.top,n}function ce(t,e,n){var r,a=oe(t,e),o=se(t,a),i=ie(t,e,o,a),l=i.borders,s=i.ctx,c=le(l,o,i.clip),d=H(t,o,l),h=we.test(t.nodeName)?"#efefef":be(t,"backgroundColor");switch(j(s,d.clip),s.save(),s.clip(),c.height>0&&c.width>0&&!n?(Z(s,o,h),ee(t,c,s)):n&&(i.backgroundColor=h),s.restore(),d.borders.forEach(function(t){q(s,t.args,t.color)}),t.nodeName){case"IMG":(r=O(t.getAttribute("src")))?A(s,t,r,o,l):me.log("html2canvas: Error loading :"+t.getAttribute("src"));break;case"INPUT":/^(text|url|email|submit|button|reset)$/.test(t.type)&&(t.value||t.placeholder||"").length>0&&X(t,o,i);break;case"TEXTAREA":(t.value||t.placeholder||"").length>0&&X(t,o,i);break;case"SELECT":(t.options||t.placeholder||"").length>0&&X(t,o,i);break;case"LI":L(t,i,c);break;case"CANVAS":A(s,t,t,o,l)}return i}function de(t){return"none"!==be(t,"display")&&"hidden"!==be(t,"visibility")&&!t.hasAttribute("data-html2canvas-ignore")}function he(t,e,r){return r||(r=function(){}),de(t)&&(e=ce(t,e,!1)||e,!we.test(t.nodeName))?ue(t,e,r):(r(),n)}function ue(t,e,n){function r(n){n.nodeType===n.ELEMENT_NODE?he(n,e,o):n.nodeType===n.TEXT_NODE?(E(t,n,e),o()):o()}function o(){0>=--l&&(me.log("finished rendering "+i.length+" children."),n())}var i=me.Children(t),l=i.length+1;o(),a.async?i.forEach(function(t){setTimeout(function(){r(t)},0)}):i.forEach(r)}t.scroll(0,0);var fe=a.elements===n?e.body:a.elements[0],pe=0,ge=fe.ownerDocument,me=d.Util,ye=me.Support(a,ge),we=RegExp("("+a.ignoreElements+")"),xe=ge.body,be=me.getCSS,ve="___html2canvas___pseudoelement",Ce=ge.createElement("style");Ce.innerHTML="."+ve+'-parent:before { content: "" !important; display: none !important; }'+"."+ve+'-parent:after { content: "" !important; display: none !important; }',xe.appendChild(Ce),r=r||{},i()},d.Preload=function(r){function a(t){E.href=t,E.href=E.href;var e=E.protocol+E.host;return e===g}function o(){b.log("html2canvas: start: images: "+x.numLoaded+" / "+x.numTotal+" (failed: "+x.numFailed+")"),!x.firstRun&&x.numLoaded>=x.numTotal&&(b.log("Finished loading images: # "+x.numTotal+" (failed: "+x.numFailed+")"),"function"==typeof r.complete&&r.complete(x))}function i(e,a,i){var l,s,c=r.proxy;E.href=e,e=E.href,l="html2canvas_"+v++,i.callbackname=l,c+=c.indexOf("?")>-1?"&":"?",c+="url="+encodeURIComponent(e)+"&callback="+l,s=k.createElement("script"),t[l]=function(e){"error:"===e.substring(0,6)?(i.succeeded=!1,x.numLoaded++,x.numFailed++,o()):(p(a,i),a.src=e),t[l]=n;try{delete t[l]}catch(r){}s.parentNode.removeChild(s),s=null,delete i.script,delete i.callbackname},s.setAttribute("type","text/javascript"),s.setAttribute("src",c),i.script=s,t.document.body.appendChild(s)}function l(e,n){var r=t.getComputedStyle(e,n),a=r.content;"url"===a.substr(0,3)&&m.loadImage(d.Util.parseBackgroundImage(a)[0].args[0]),u(r.backgroundImage,e)}function s(t){l(t,":before"),l(t,":after")}function c(t,e){var r=d.Generate.Gradient(t,e);r!==n&&(x[t]={img:r,succeeded:!0},x.numTotal++,x.numLoaded++,o())}function h(t){return t&&t.method&&t.args&&t.args.length>0}function u(t,e){var r;d.Util.parseBackgroundImage(t).filter(h).forEach(function(t){"url"===t.method?m.loadImage(t.args[0]):t.method.match(/\-?gradient$/)&&(r===n&&(r=d.Util.Bounds(e)),c(t.value,r))})}function f(t){var e=!1;try{b.Children(t).forEach(f)}catch(r){}try{e=t.nodeType}catch(a){e=!1,b.log("html2canvas: failed to access some element's nodeType - Exception: "+a.message)}if(1===e||e===n){s(t);try{u(b.getCSS(t,"backgroundImage"),t)}catch(r){b.log("html2canvas: failed to get background-image - Exception: "+r.message)}u(t)}}function p(e,a){e.onload=function(){a.timer!==n&&t.clearTimeout(a.timer),x.numLoaded++,a.succeeded=!0,e.onerror=e.onload=null,o()},e.onerror=function(){if("anonymous"===e.crossOrigin&&(t.clearTimeout(a.timer),r.proxy)){var l=e.src;return e=new Image,a.img=e,e.src=l,i(e.src,e,a),n}x.numLoaded++,x.numFailed++,a.succeeded=!1,e.onerror=e.onload=null,o()}}var g,m,y,w,x={numLoaded:0,numFailed:0,numTotal:0,cleanupDone:!1},b=d.Util,v=0,C=r.elements[0]||e.body,k=C.ownerDocument,T=C.getElementsByTagName("img"),S=T.length,E=k.createElement("a"),R=function(t){return t.crossOrigin!==n}(new Image);for(E.href=t.location.href,g=E.protocol+E.host,m={loadImage:function(t){var e,o;t&&x[t]===n&&(e=new Image,t.match(/data:image\/.*;base64,/i)?(e.src=t.replace(/url\(['"]{0,}|['"]{0,}\)$/gi,""),o=x[t]={img:e},x.numTotal++,p(e,o)):a(t)||r.allowTaint===!0?(o=x[t]={img:e},x.numTotal++,p(e,o),e.src=t):R&&!r.allowTaint&&r.useCORS?(e.crossOrigin="anonymous",o=x[t]={img:e},x.numTotal++,p(e,o),e.src=t):r.proxy&&(o=x[t]={img:e},x.numTotal++,i(t,e,o)))},cleanupDOM:function(a){var i,l; +if(!x.cleanupDone){a&&"string"==typeof a?b.log("html2canvas: Cleanup because: "+a):b.log("html2canvas: Cleanup after timeout: "+r.timeout+" ms.");for(l in x)if(x.hasOwnProperty(l)&&(i=x[l],"object"==typeof i&&i.callbackname&&i.succeeded===n)){t[i.callbackname]=n;try{delete t[i.callbackname]}catch(s){}i.script&&i.script.parentNode&&(i.script.setAttribute("src","about:blank"),i.script.parentNode.removeChild(i.script)),x.numLoaded++,x.numFailed++,b.log("html2canvas: Cleaned up failed img: '"+l+"' Steps: "+x.numLoaded+" / "+x.numTotal)}t.stop!==n?t.stop():e.execCommand!==n&&e.execCommand("Stop",!1),e.close!==n&&e.close(),x.cleanupDone=!0,a&&"string"==typeof a||o()}},renderingDone:function(){w&&t.clearTimeout(w)}},r.timeout>0&&(w=t.setTimeout(m.cleanupDOM,r.timeout)),b.log("html2canvas: Preload starts: finding background-images"),x.firstRun=!0,f(C),b.log("html2canvas: Preload: Finding images"),y=0;S>y;y+=1)m.loadImage(T[y].getAttribute("src"));return x.firstRun=!1,b.log("html2canvas: Preload: Done."),x.numTotal===x.numLoaded&&o(),m},d.Renderer=function(t,r){function a(t,e){return"children"===t?-1:"children"===e?1:t-e}function o(t){function e(t){Object.keys(t).sort(a).forEach(function(n){var r=[],a=[],i=[],l=[];t[n].forEach(function(t){t.node.zIndex.isPositioned||1>t.node.zIndex.opacity?i.push(t):t.node.zIndex.isFloated?a.push(t):r.push(t)}),function s(t){t.forEach(function(t){l.push(t),t.children&&s(t.children)})}(r.concat(a,i)),l.forEach(function(t){t.context?e(t.context):o.push(t.node)})})}var r,o=[];return r=function(t){function e(t,r,a){var o="auto"===r.zIndex.zindex?0:Number(r.zIndex.zindex),i=t,l=r.zIndex.isPositioned,s=r.zIndex.isFloated,c={node:r},d=a;r.zIndex.ownStacking?(i=c.context={children:[{node:r,children:[]}]},d=n):(l||s)&&(d=c.children=[]),0===o&&a?a.push(c):(t[o]||(t[o]=[]),t[o].push(c)),r.zIndex.children.forEach(function(t){e(i,t,d)})}var r={};return e(r,t),r}(t),e(r),o}function i(t){var e;if("string"==typeof r.renderer&&d.Renderer[t]!==n)e=d.Renderer[t](r);else{if("function"!=typeof t)throw Error("Unknown renderer");e=t(r)}if("function"!=typeof e)throw Error("Invalid renderer defined");return e}return i(r.renderer)(t,r,e,o(t.stack),d)},d.Util.Support=function(t,e){function r(){var t=new Image,r=e.createElement("canvas"),a=r.getContext===n?!1:r.getContext("2d");if(a===!1)return!1;r.width=r.height=10,t.src=["data:image/svg+xml,","","","
","sup","
","
","
"].join("");try{a.drawImage(t,0,0),r.toDataURL()}catch(o){return!1}return d.Util.log("html2canvas: Parse: SVG powered rendering available"),!0}function a(){var t,n,r,a,o=!1;return e.createRange&&(t=e.createRange(),t.getBoundingClientRect&&(n=e.createElement("boundtest"),n.style.height="123px",n.style.display="block",e.body.appendChild(n),t.selectNode(n),r=t.getBoundingClientRect(),a=r.height,123===a&&(o=!0),e.body.removeChild(n))),o}return{rangeBounds:a(),svgRendering:t.svgRendering&&r()}},t.html2canvas=function(e,n){e=e.length?e:[e];var r,a={logging:!1,elements:e,background:"#fff",proxy:null,timeout:0,useCORS:!1,allowTaint:!1,svgRendering:!1,ignoreElements:"IFRAME|OBJECT|PARAM",useOverflow:!0,letterRendering:!1,chinese:!1,async:!1,width:null,height:null,taintTest:!0,renderer:"Canvas"};return a=d.Util.Extend(n,a),d.logging=a.logging,a.complete=function(t){("function"!=typeof a.onpreloaded||a.onpreloaded(t)!==!1)&&d.Parse(t,a,function(t){("function"!=typeof a.onparsed||a.onparsed(t)!==!1)&&(r=d.Renderer(t,a),"function"==typeof a.onrendered&&a.onrendered(r))})},t.setTimeout(function(){d.Preload(a)},0),{render:function(t,e){return d.Renderer(t,d.Util.Extend(e,a))},parse:function(t,e){return d.Parse(t,d.Util.Extend(e,a))},preload:function(t){return d.Preload(d.Util.Extend(t,a))},log:d.Util.log}},t.html2canvas.log=d.Util.log,t.html2canvas.Renderer={Canvas:n},d.Renderer.Canvas=function(t){function r(t,e){t.beginPath(),e.forEach(function(e){t[e.name].apply(t,e.arguments)}),t.closePath()}function a(t){if(-1===l.indexOf(t.arguments[0].src)){c.drawImage(t.arguments[0],0,0);try{c.getImageData(0,0,1,1)}catch(e){return s=i.createElement("canvas"),c=s.getContext("2d"),!1}l.push(t.arguments[0].src)}return!0}function o(e,n){switch(n.type){case"variable":e[n.name]=n.arguments;break;case"function":switch(n.name){case"createPattern":if(n.arguments[0].width>0&&n.arguments[0].height>0)try{e.fillStyle=e.createPattern(n.arguments[0],"repeat")}catch(o){h.log("html2canvas: Renderer: Error creating pattern",o.message)}break;case"drawShape":r(e,n.arguments);break;case"drawImage":n.arguments[8]>0&&n.arguments[7]>0&&(!t.taintTest||t.taintTest&&a(n))&&e.drawImage.apply(e,n.arguments);break;default:e[n.name].apply(e,n.arguments)}}}t=t||{};var i=e,l=[],s=e.createElement("canvas"),c=s.getContext("2d"),h=d.Util,u=t.canvas||i.createElement("canvas");return function(t,e,r,a,i){var l,s,c,d=u.getContext("2d"),f=t.stack;return u.width=u.style.width=e.width||f.ctx.width,u.height=u.style.height=e.height||f.ctx.height,c=d.fillStyle,d.fillStyle=h.isTransparent(t.backgroundColor)&&e.background!==n?e.background:t.backgroundColor,d.fillRect(0,0,u.width,u.height),d.fillStyle=c,a.forEach(function(t){d.textBaseline="bottom",d.save(),t.transform.matrix&&(d.translate(t.transform.origin[0],t.transform.origin[1]),d.transform.apply(d,t.transform.matrix),d.translate(-t.transform.origin[0],-t.transform.origin[1])),t.clip&&(d.beginPath(),d.rect(t.clip.left,t.clip.top,t.clip.width,t.clip.height),d.clip()),t.ctx.storage&&t.ctx.storage.forEach(function(t){o(d,t)}),d.restore()}),h.log("html2canvas: Renderer: Canvas renderer done - returning canvas obj"),1===e.elements.length&&"object"==typeof e.elements[0]&&"BODY"!==e.elements[0].nodeName?(s=i.Util.Bounds(e.elements[0]),l=r.createElement("canvas"),l.width=Math.ceil(s.width),l.height=Math.ceil(s.height),d=l.getContext("2d"),d.drawImage(u,s.left,s.top,s.width,s.height,0,0,s.width,s.height),u=null,l):u}}})(window,document); \ No newline at end of file diff --git a/src/Core.js b/src/Core.js index 044dec8..4b3573a 100644 --- a/src/Core.js +++ b/src/Core.js @@ -48,7 +48,6 @@ _html2canvas.Util.asFloat = function(v) { }; })(); - _html2canvas.Util.parseBackgroundImage = function (value) { var whitespace = ' \r\n\t', method, definition, prefix, prefix_i, block, results = [], @@ -222,6 +221,10 @@ function asInt(val) { return parseInt(val, 10); } +function isPercentage(value) { + return value.toString().indexOf("%") !== -1; +} + function parseBackgroundSizePosition(value, element, attribute, index) { value = (value || '').split(','); value = value[index || 0] || value[0] || 'auto'; @@ -250,13 +253,6 @@ _html2canvas.Util.getCSS = function (element, attribute, index) { } var value = computedCSS[attribute]; - if(attribute==="backgroundRepeat" && value.indexOf(" ")!==-1){ - value = ( - "no-repeat repeat"===value ? "repeat-y" : ( - "repeat no-repeat"===value ? "repeat-x" : value - ) - ); - } if (/^background(Size|Position)$/.test(attribute)) { return parseBackgroundSizePosition(value, element, attribute, index); @@ -301,7 +297,7 @@ _html2canvas.Util.BackgroundPosition = function(element, bounds, image, imageInd backgroundPosition = [backgroundPosition[0], backgroundPosition[0]]; } - if (backgroundPosition[0].toString().indexOf("%") !== -1){ + if (isPercentage(backgroundPosition[0])){ leftPosition = (bounds.width - (backgroundSize || image).width) * (parseFloat(backgroundPosition[0]) / 100); } else { leftPosition = parseInt(backgroundPosition[0], 10); @@ -309,7 +305,7 @@ _html2canvas.Util.BackgroundPosition = function(element, bounds, image, imageInd if (backgroundPosition[1] === 'auto') { topPosition = leftPosition / image.width * image.height; - } else if (backgroundPosition[1].toString().indexOf("%") !== -1){ + } else if (isPercentage(backgroundPosition[1])){ topPosition = (bounds.height - (backgroundSize || image).height) * parseFloat(backgroundPosition[1]) / 100; } else { topPosition = parseInt(backgroundPosition[1], 10); @@ -323,41 +319,40 @@ _html2canvas.Util.BackgroundPosition = function(element, bounds, image, imageInd }; _html2canvas.Util.BackgroundSize = function(element, bounds, image, imageIndex) { - var backgroundSize = _html2canvas.Util.getCSS(element, 'backgroundSize', imageIndex), - width, - height; + var backgroundSize = _html2canvas.Util.getCSS(element, 'backgroundSize', imageIndex), width, height; - if (backgroundSize.length === 1){ - backgroundSize = [backgroundSize[0], backgroundSize[0]]; - } + if (backgroundSize.length === 1) { + backgroundSize = [backgroundSize[0], backgroundSize[0]]; + } - if (backgroundSize[0].toString().indexOf("%") !== -1){ - width = bounds.width * parseFloat(backgroundSize[0]) / 100; - } else if(backgroundSize[0] === 'auto') { - width = image.width; - } else { - if (/contain|cover/.test(backgroundSize[0])) { - var resized = _html2canvas.Util.resizeBounds(image.width, image.height, bounds.width, bounds.height, backgroundSize[0]); - return {width: resized.width, height: resized.height}; - } else { - width = parseInt(backgroundSize[0], 10); - } - } + if (isPercentage(backgroundSize[0])) { + width = bounds.width * parseFloat(backgroundSize[0]) / 100; + } else if (/contain|cover/.test(backgroundSize[0])) { + return _html2canvas.Util.resizeBounds(image.width, image.height, bounds.width, bounds.height, backgroundSize[0]); + } else { + width = parseInt(backgroundSize[0], 10); + } - if(backgroundSize[1] === 'auto') { - height = width / image.width * image.height; - } else if (backgroundSize[1].toString().indexOf("%") !== -1){ - height = bounds.height * parseFloat(backgroundSize[1]) / 100; - } else { - height = parseInt(backgroundSize[1],10); - } + if (backgroundSize[0] === 'auto' && backgroundSize[1] === 'auto') { + height = image.height; + } else if (backgroundSize[1] === 'auto') { + height = width / image.width * image.height; + } else if (isPercentage(backgroundSize[1])) { + height = bounds.height * parseFloat(backgroundSize[1]) / 100; + } else { + height = parseInt(backgroundSize[1], 10); + } + if (backgroundSize[0] === 'auto') { + width = height / image.height * image.width; + } - if (backgroundSize[0] === 'auto') { - width = height / image.height * image.width; - } + return {width: width, height: height}; +}; - return {width: width, height: height}; +_html2canvas.Util.BackgroundRepeat = function(element, imageIndex) { + var backgroundRepeat = _html2canvas.Util.getCSS(element, "backgroundRepeat").split(",").map(_html2canvas.Util.trimText); + return backgroundRepeat[imageIndex] || backgroundRepeat[0]; }; _html2canvas.Util.Extend = function (options, defaults) { diff --git a/src/Parse.js b/src/Parse.js index 1bca773..123fb7e 100644 --- a/src/Parse.js +++ b/src/Parse.js @@ -12,7 +12,7 @@ _html2canvas.Parse = function (images, options, cb) { pseudoHide = "___html2canvas___pseudoelement", hidePseudoElementsStyles = doc.createElement('style'); - hidePseudoElementsStyles.innerHTML = '.' + pseudoHide + + hidePseudoElementsStyles.innerHTML = '.' + pseudoHide + '-parent:before { content: "" !important; display: none !important; }' + '.' + pseudoHide + '-parent:after { content: "" !important; display: none !important; }'; @@ -29,7 +29,7 @@ _html2canvas.Parse = function (images, options, cb) { // create pseudo elements in a single pass to prevent synchronous layouts addPseudoElements(element); - + parseChildren(element, stack, function() { if (transparentBackground) { background = stack.backgroundColor; @@ -46,8 +46,8 @@ _html2canvas.Parse = function (images, options, cb) { }); } - // Given a root element, find all pseudo elements below, create elements mocking pseudo element styles - // so we can process them as normal elements, and hide the original pseudo elements so they don't interfere + // Given a root element, find all pseudo elements below, create elements mocking pseudo element styles + // so we can process them as normal elements, and hide the original pseudo elements so they don't interfere // with layout. function addPseudoElements(el) { // These are done in discrete steps to prevent a relayout loop caused by addClass() invalidating @@ -164,7 +164,7 @@ _html2canvas.Parse = function (images, options, cb) { // Note that this doesn't work in < IE8, but we don't support that anyhow function nodeListToArray (nodeList) { - return Array.prototype.slice.call(nodeList); + return Array.prototype.slice.call(nodeList); } function documentWidth () { @@ -931,8 +931,8 @@ _html2canvas.Parse = function (images, options, cb) { var parentStyle = window.getComputedStyle(el); // If no content attribute is present, the pseudo element is hidden, // or the parent has a content property equal to the content on the pseudo element, - // move along. - if(!elStyle || !elStyle.content || elStyle.content === "none" || elStyle.content === "-moz-alt-content" || + // move along. + if(!elStyle || !elStyle.content || elStyle.content === "none" || elStyle.content === "-moz-alt-content" || elStyle.display === "none" || parentStyle.content === elStyle.content) { return; } @@ -1006,28 +1006,25 @@ _html2canvas.Parse = function (images, options, cb) { function renderBackgroundRepeating(el, bounds, ctx, image, imageIndex) { var backgroundSize = Util.BackgroundSize(el, bounds, image, imageIndex), backgroundPosition = Util.BackgroundPosition(el, bounds, image, imageIndex, backgroundSize), - backgroundRepeat = getCSS(el, "backgroundRepeat").split(",").map(Util.trimText); + backgroundRepeat = Util.BackgroundRepeat(el, imageIndex); image = resizeImage(image, backgroundSize); - backgroundRepeat = backgroundRepeat[imageIndex] || backgroundRepeat[0]; - switch (backgroundRepeat) { case "repeat-x": + case "repeat no-repeat": backgroundRepeatShape(ctx, image, backgroundPosition, bounds, bounds.left, bounds.top + backgroundPosition.top, 99999, image.height); break; - case "repeat-y": + case "no-repeat repeat": backgroundRepeatShape(ctx, image, backgroundPosition, bounds, bounds.left + backgroundPosition.left, bounds.top, image.width, 99999); break; - case "no-repeat": backgroundRepeatShape(ctx, image, backgroundPosition, bounds, bounds.left + backgroundPosition.left, bounds.top + backgroundPosition.top, image.width, image.height); break; - default: renderBackgroundRepeat(ctx, image, backgroundPosition, { top: bounds.top, @@ -1245,7 +1242,7 @@ _html2canvas.Parse = function (images, options, cb) { // We add one and kick it off so this will still work when children.length === 0. // Note that unless async is true, this will happen synchronously, just will callbacks. var jobs = children.length + 1; - finished(); + finished(); if (options.async) { children.forEach(function(node) { diff --git a/src/renderers/Canvas.js b/src/renderers/Canvas.js index 30b0f58..57fc1f5 100644 --- a/src/renderers/Canvas.js +++ b/src/renderers/Canvas.js @@ -17,7 +17,7 @@ _html2canvas.Renderer.Canvas = function(options) { } function safeImage(item) { - if (safeImages.indexOf(item['arguments'][0].src ) === -1) { + if (safeImages.indexOf(item['arguments'][0].src) === -1) { testctx.drawImage(item['arguments'][0], 0, 0); try { testctx.getImageData(0, 0, 1, 1); @@ -42,8 +42,7 @@ _html2canvas.Renderer.Canvas = function(options) { if (item['arguments'][0].width > 0 && item['arguments'][0].height > 0) { try { ctx.fillStyle = ctx.createPattern(item['arguments'][0], "repeat"); - } - catch(e) { + } catch(e) { Util.log("html2canvas: Renderer: Error creating pattern", e.message); } } @@ -79,7 +78,6 @@ _html2canvas.Renderer.Canvas = function(options) { ctx.fillStyle = (Util.isTransparent(parsedData.backgroundColor) && options.background !== undefined) ? options.background : parsedData.backgroundColor; ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = fstyle; - queue.forEach(function(storageContext) { // set common settings for canvas ctx.textBaseline = "bottom";