diff --git a/Gruntfile.js b/Gruntfile.js index 8fcbe8d..a3d5eb5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -25,7 +25,7 @@ module.exports = function(grunt) { src: [ 'src/promise.js', 'src/fallback.js', 'src/**/*.js' ], - dest: 'build/<%= pkg.name %>.js' + dest: 'dist/<%= pkg.name %>.js' }, options:{ banner: meta.banner + meta.pre, @@ -71,7 +71,7 @@ module.exports = function(grunt) { uglify: { dist: { src: ['<%= concat.dist.dest %>'], - dest: 'build/<%= pkg.name %>.min.js' + dest: 'dist/<%= pkg.name %>.min.js' }, options: { banner: meta.banner diff --git a/bower.json b/bower.json index 901c337..40cec5a 100644 --- a/bower.json +++ b/bower.json @@ -1,10 +1,10 @@ { "name": "html2canvas", - "version": "0.4.1", + "version": "0.5.0-alpha", "description": "Screenshots with JavaScript", - "main": "build/html2canvas.js", + "main": "dist/html2canvas.js", "ignore": [ "tests", ".travis.yml" ] -} \ No newline at end of file +} diff --git a/build/html2canvas.min.js b/build/html2canvas.min.js deleted file mode 100644 index 38a52cb..0000000 --- a/build/html2canvas.min.js +++ /dev/null @@ -1,8 +0,0 @@ -/* - html2canvas 0.5.0-rc1 - Copyright (c) 2014 Niklas von Hertzen - - Released under MIT License -*/ -(function(t,e,n){function r(t,e,n,r){return c(t,n,r,e).then(function(a){b("Document cloned");var c="["+me+"='true']";t.querySelector(c).removeAttribute(me);var h=a.contentWindow,u=h.document.querySelector(c),p=new le(h.document),l=new m(e,p),d=S(u),f="view"===e.type?Math.min(d.width,n):i(),g="view"===e.type?Math.min(d.height,r):s(),y=new ue(f,g,l),v=new B(u,y,p,l,e);return v.ready.then(function(){return b("Finished rendering"),e.removeContainer&&a.parentNode.removeChild(a),"view"===e.type||u!==h.document.body&&u!==h.document.documentElement?o(y.canvas,d):y.canvas})})}function o(t,n){var r=e.createElement("canvas"),o=Math.min(t.width-1,Math.max(0,n.left)),i=Math.min(t.width,Math.max(1,n.left+n.width)),s=Math.min(t.height-1,Math.max(0,n.top)),a=Math.min(t.height,Math.max(1,n.top+n.height)),c=r.width=i-o,h=r.height=a-s;return b("Cropping canvas at:","left:",n.left,"top:",n.top,"width:",n.width,"height:",n.height),b("Resulting crop with width",c,"and height",h," with x",o,"and y",s),r.getContext("2d").drawImage(t,o,s,c,h,0,0,c,h),r}function i(){return Math.max(Math.max(e.body.scrollWidth,e.documentElement.scrollWidth),Math.max(e.body.offsetWidth,e.documentElement.offsetWidth),Math.max(e.body.clientWidth,e.documentElement.clientWidth))}function s(){return Math.max(Math.max(e.body.scrollHeight,e.documentElement.scrollHeight),Math.max(e.body.offsetHeight,e.documentElement.offsetHeight),Math.max(e.body.clientHeight,e.documentElement.clientHeight))}function a(){return"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}function c(e,n,r,o){var i=e.documentElement.cloneNode(!0),s=e.createElement("iframe");return s.style.visibility="hidden",s.style.position="absolute",s.style.left=s.style.top="-10000px",s.width=n,s.height=r,s.scrolling="no",e.body.appendChild(s),new Promise(function(e){var n=s.contentWindow.document;s.contentWindow.onload=s.onload=function(){e(s)},n.open(),n.write(""),n.close(),n.replaceChild(h(n.adoptNode(i)),n.documentElement),"view"===o.type&&s.contentWindow.scrollTo(t.pageXOffset,t.pageYOffset)})}function h(t){return[].slice.call(t.childNodes,0).filter(u).forEach(function(e){"SCRIPT"===e.tagName?t.removeChild(e):h(e)}),t}function u(t){return t.nodeType===Node.ELEMENT_NODE}function p(t){if(this.src=t,b("DummyImageContainer for",t),!this.promise||!this.image){b("Initiating DummyImageContainer"),p.prototype.image=new Image;var e=this.image;p.prototype.promise=new Promise(function(t,n){e.onload=t,e.onerror=n,e.src=a(),e.complete===!0&&t(e)})}}function l(t,n){var r,o,i=e.createElement("div"),s=e.createElement("img"),c=e.createElement("span"),h="Hidden Text";i.style.visibility="hidden",i.style.fontFamily=t,i.style.fontSize=n,i.style.margin=0,i.style.padding=0,e.body.appendChild(i),s.src=a(),s.width=1,s.height=1,s.style.margin=0,s.style.padding=0,s.style.verticalAlign="baseline",c.style.fontFamily=t,c.style.fontSize=n,c.style.margin=0,c.style.padding=0,c.appendChild(e.createTextNode(h)),i.appendChild(c),i.appendChild(s),r=s.offsetTop-c.offsetTop+1,i.removeChild(c),i.appendChild(e.createTextNode(h)),i.style.lineHeight="normal",s.style.verticalAlign="super",o=s.offsetTop-i.offsetTop+1,e.body.removeChild(i),this.baseline=r,this.lineWidth=1,this.middle=o}function d(){this.data={}}function f(t){this.src=t.value,this.colorStops=[],this.type=null,this.x0=.5,this.y0=.5,this.x1=.5,this.y1=.5,this.promise=Promise.resolve(!0)}function g(t,e){this.src=t,this.image=new Image;var n=this;this.promise=new Promise(function(r,o){n.image.onload=r,n.image.onerror=o,e&&(n.image.crossOrigin="anonymous"),n.image.src=t,n.image.complete===!0&&r(n.image)})["catch"](function(){var e=new p(t);return e.promise.then(function(t){n.image=t})})}function m(e,n){this.link=null,this.options=e,this.support=n,this.origin=t.location.protocol+t.location.hostname+t.location.port}function y(t){return"IMG"===t.node.nodeName}function v(t){return{args:[t.node.src],method:"url"}}function w(t){f.apply(this,arguments),this.type=this.TYPES.LINEAR;var e=null===t.args[0].match(this.stepRegExp);e?t.args[0].split(" ").reverse().forEach(function(t){switch(t){case"left":this.x0=0,this.x1=1;break;case"top":this.y0=0,this.y1=1;break;case"right":this.x0=1,this.x1=0;break;case"bottom":this.y0=1,this.y1=0;break;case"to":var e=this.y0,n=this.x0;this.y0=this.y1,this.x0=this.x1,this.x1=n,this.y1=e}},this):(this.y0=0,this.y1=1),this.colorStops=t.args.slice(e?1:0).map(function(t){var e=t.match(this.stepRegExp);return{color:e[1],stop:"%"===e[3]?e[2]/100:null}},this),null===this.colorStops[0].stop&&(this.colorStops[0].stop=0),null===this.colorStops[this.colorStops.length-1].stop&&(this.colorStops[this.colorStops.length-1].stop=1),this.colorStops.forEach(function(t,e){null===t.stop&&this.colorStops.slice(e).some(function(n,r){return null!==n.stop?(t.stop=(n.stop-this.colorStops[e-1].stop)/(r+1)+this.colorStops[e-1].stop,!0):!1},this)},this)}function b(){t.html2canvas.logging&&t.console&&t.console.log&&Function.prototype.bind.call(t.console.log,t.console).apply(t.console,[Date.now()-t.html2canvas.start+"ms","html2canvas:"].concat([].slice.call(arguments,0)))}function x(t,e){this.node=t,this.parent=e,this.stack=null,this.bounds=null,this.offsetBounds=null,this.visible=null,this.computedStyles=null,this.styles={},this.backgroundImages=null,this.transformData=null,this.transformMatrix=null}function T(t){var e=t.options[t.selectedIndex||0];return e?e.text||"":""}function E(t){return t&&"matrix"===t[1]?t[2].split(",").map(function(t){return parseFloat(t.trim())}):n}function k(t){return-1!==(""+t).indexOf("%")}function I(t){var e,r,o,i,s,a,c,h=" \r\n ",u=[],p=0,l=0,d=function(){e&&('"'===r.substr(0,1)&&(r=r.substr(1,r.length-2)),r&&c.push(r),"-"===e.substr(0,1)&&(i=e.indexOf("-",1)+1)>0&&(o=e.substr(0,i),e=e.substr(i)),u.push({prefix:o,method:e.toLowerCase(),value:s,args:c,image:null})),c=[],e=o=r=s=""};return c=[],e=o=r=s="",t.split("").forEach(function(t){if(!(0===p&&h.indexOf(t)>-1)){switch(t){case'"':a?a===t&&(a=null):a=t;break;case"(":if(a)break;if(0===p)return p=1,s+=t,n;l++;break;case")":if(a)break;if(1===p){if(0===l)return p=0,s+=t,d(),n;l--}break;case",":if(a)break;if(0===p)return d(),n;if(1===p&&0===l&&!e.match(/^url$/i))return c.push(r),r="",s+=t,n}s+=t,0===p?e+=t:r+=t}}),d(),u}function R(t){return t.replace("px","")}function C(t){return parseFloat(t)}function S(t){if(t.getBoundingClientRect){var e=t.getBoundingClientRect(),n="BODY"===t.nodeName,r=n?t.scrollWidth:t.offsetWidth;return{top:e.top,bottom:e.bottom||e.top+e.height,right:e.left+r,left:e.left,width:r,height:n?t.scrollHeight:t.offsetHeight}}return{}}function O(t){var e=t.offsetParent?O(t.offsetParent):{top:0,left:0};return{top:t.offsetTop+e.top,bottom:t.offsetTop+t.offsetHeight+e.top,right:t.offsetLeft+e.left+t.offsetWidth,left:t.offsetLeft+e.left,width:t.offsetWidth,height:t.offsetHeight}}function B(t,e,n,r,o){b("Starting NodeParser"),this.renderer=e,this.options=o,this.range=null,this.support=n,this.renderQueue=[],this.stack=new pe(!0,1,t.ownerDocument,null);var i=new x(t,null);t!==t.ownerDocument.documentElement&&this.renderer.isTransparent(i.css("backgroundColor"))&&e.rectangle(0,0,e.width,e.height,new x(t.ownerDocument.documentElement,null).css("backgroundColor")),i.visibile=i.isElementVisible(),this.createPseudoHideStyles(t.ownerDocument),this.nodes=se([i].concat(this.getChildren(i)).filter(function(t){return t.visible=t.isElementVisible()}).map(this.getPseudoElements,this)),this.fontMetrics=new d,b("Fetched nodes"),this.images=r.fetch(this.nodes.filter(K)),b("Creating stacking contexts"),this.createStackingContexts(),b("Sorting stacking contexts"),this.sortStackingContexts(this.stack),this.ready=this.images.ready.then(ne(function(){return b("Images loaded, starting parsing"),this.parse(this.stack),b("Render queue created with "+this.renderQueue.length+" items"),new Promise(ne(function(t){o.async?"function"==typeof o.async?o.async.call(this,this.renderQueue,t):(this.renderIndex=0,this.asyncRenderer(this.renderQueue,t)):(this.renderQueue.forEach(this.paint,this),t())},this))},this))}function A(t){return t.replace(/(\-[a-z])/g,function(t){return t.toUpperCase().replace("-","")})}function M(){}function N(t,e,n,r){var o=4*((Math.sqrt(2)-1)/3),i=n*o,s=r*o,a=t+n,c=e+r;return{topLeft:L({x:t,y:c},{x:t,y:c-s},{x:a-i,y:e},{x:a,y:e}),topRight:L({x:t,y:e},{x:t+i,y:e},{x:a,y:c-s},{x:a,y:c}),bottomRight:L({x:a,y:e},{x:a,y:e+s},{x:t+i,y:c},{x:t,y:c}),bottomLeft:L({x:a,y:c},{x:a-i,y:c},{x:t,y:e+s},{x:t,y:e})}}function P(t,e,n){var r=t.left,o=t.top,i=t.width,s=t.height,a=e[0][0],c=e[0][1],h=e[1][0],u=e[1][1],p=e[2][0],l=e[2][1],d=e[3][0],f=e[3][1],g=i-h,m=s-l,y=i-p,v=s-f;return{topLeftOuter:N(r,o,a,c).topLeft.subdivide(.5),topLeftInner:N(r+n[3].width,o+n[0].width,Math.max(0,a-n[3].width),Math.max(0,c-n[0].width)).topLeft.subdivide(.5),topRightOuter:N(r+g,o,h,u).topRight.subdivide(.5),topRightInner:N(r+Math.min(g,i+n[3].width),o+n[0].width,g>i+n[3].width?0:h-n[3].width,u-n[0].width).topRight.subdivide(.5),bottomRightOuter:N(r+y,o+m,p,l).bottomRight.subdivide(.5),bottomRightInner:N(r+Math.min(y,i+n[3].width),o+Math.min(m,s+n[0].width),Math.max(0,p-n[1].width),Math.max(0,l-n[2].width)).bottomRight.subdivide(.5),bottomLeftOuter:N(r,o+v,d,f).bottomLeft.subdivide(.5),bottomLeftInner:N(r+n[3].width,o+v,Math.max(0,d-n[3].width),Math.max(0,f-n[2].width)).bottomLeft.subdivide(.5)}}function L(t,e,n,r){var o=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(i){var s=o(t,e,i),a=o(e,n,i),c=o(n,r,i),h=o(s,a,i),u=o(a,c,i),p=o(h,u,i);return[L(t,s,h,p),L(p,u,c,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,o,i,s){var a=[];return e[0]>0||e[1]>0?(a.push(["line",r[1].start.x,r[1].start.y]),r[1].curveTo(a)):a.push(["line",t.c1[0],t.c1[1]]),n[0]>0||n[1]>0?(a.push(["line",i[0].start.x,i[0].start.y]),i[0].curveTo(a),a.push(["line",s[0].end.x,s[0].end.y]),s[0].curveToReversed(a)):(a.push(["line",t.c2[0],t.c2[1]]),a.push(["line",t.c3[0],t.c3[1]])),e[0]>0||e[1]>0?(a.push(["line",o[1].end.x,o[1].end.y]),o[1].curveToReversed(a)):a.push(["line",t.c4[0],t.c4[1]]),a}function _(t,e,n,r,o,i,s){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",i,s]),(n[0]>0||n[1]>0)&&t.push(["line",o[0].start.x,o[0].start.y])}function W(t){return 0>t.cssInt("zIndex")}function F(t){return t.cssInt("zIndex")>0}function H(t){return 0===t.cssInt("zIndex")}function j(t){return-1!==["inline","inline-block","inline-table"].indexOf(t.css("display"))}function z(t){return t instanceof pe}function V(t){return t.node.data.trim().length>0}function Y(t){return/^(normal|none|0px)$/.test(t.parent.css("letterSpacing"))}function X(t){return["TopLeft","TopRight","BottomRight","BottomLeft"].map(function(e){var n=t.css("border"+e+"Radius"),r=n.split(" ");return 1>=r.length&&(r[1]=r[0]),r.map(re)})}function U(t){return t.nodeType===Node.TEXT_NODE||t.nodeType===Node.ELEMENT_NODE}function Q(t){var e=t.css("position"),n="absolute"===e||"relative"===e?t.css("zIndex"):"auto";return"auto"!==n}function G(t){return"static"!==t.css("position")}function q(t){return"none"!==t.css("float")}function $(t){return-1!==["inline-block","inline-table"].indexOf(t.css("display"))}function J(t){var e=this;return function(){return!t.apply(e,arguments)}}function K(t){return t.node.nodeType===Node.ELEMENT_NODE}function Z(t){return t.node.nodeType===Node.TEXT_NODE}function te(t,e){return t.cssInt("zIndex")-e.cssInt("zIndex")}function ee(t){return 1>t.css("opacity")}function ne(t,e){return function(){return t.apply(e,arguments)}}function re(t){return parseInt(t,10)}function oe(t){return t.width}function ie(t){return t.node.nodeType!==Node.ELEMENT_NODE||-1===["SCRIPT","HEAD","TITLE","OBJECT","BR","OPTION"].indexOf(t.node.nodeName)}function se(t){return[].concat.apply([],t)}function ae(t){var e=t.substr(0,1);return e===t.substr(t.length-1)&&e.match(/'|"/)?t.substr(1,t.length-2):t}function ce(r,o){var i="html2canvas_"+ye++,s=e.createElement("script"),a=e.createElement("a");a.href=r,r=a.href;var c=o+(o.indexOf("?")>-1?"&":"?")+"url="+encodeURIComponent(r)+"&callback="+i;this.src=r,this.image=new Image;var h=this;this.promise=new Promise(function(r,o){h.image.onload=r,h.image.onerror=o,t[i]=function(e){"error:"===e.substring(0,6)?o():h.image.src=e,t[i]=n;try{delete t[i]}catch(r){}s.parentNode.removeChild(s)},s.setAttribute("type","text/javascript"),s.setAttribute("src",c),e.body.appendChild(s)})["catch"](function(){var t=new p(r);return t.promise.then(function(t){h.image=t})})}function he(t,e,n){this.width=t,this.height=e,this.images=n}function ue(t,n){he.apply(this,arguments),this.canvas=e.createElement("canvas"),this.canvas.width=t,this.canvas.height=n,this.ctx=this.canvas.getContext("2d"),this.ctx.textBaseline="bottom",this.variables={},b("Initialized CanvasRenderer")}function pe(t,e,n,r){x.call(this,n,r),this.ownStacking=t,this.contexts=[],this.children=[],this.opacity=(this.parent?this.parent.stack.opacity:1)*e}function le(t){this.rangeBounds=this.testRangeBounds(t),this.cors=this.testCORS()}function de(t,e){x.call(this,t,e)}function fe(t,e,r){return t.length>0?e+r.toUpperCase():n}function ge(t){f.apply(this,arguments),this.type="linear"===t.args[0]?this.TYPES.LINEAR:this.TYPES.RADIAL}if(!function(){var r,o,i,s;!function(){var t={},e={};r=function(e,n,r){t[e]={deps:n,callback:r}},s=i=o=function(n){function r(t){if("."!==t.charAt(0))return t;for(var e=t.split("/"),r=n.split("/").slice(0,-1),o=0,i=e.length;i>o;o++){var s=e[o];if(".."===s)r.pop();else{if("."===s)continue;r.push(s)}}return r.join("/")}if(s._eak_seen=t,e[n])return e[n];if(e[n]={},!t[n])throw Error("Could not find module "+n);for(var i,a=t[n],c=a.deps,h=a.callback,u=[],p=0,l=c.length;l>p;p++)"exports"===c[p]?u.push(i={}):u.push(o(r(c[p])));var d=h.apply(this,u);return e[n]=i||d}}(),r("promise/all",["./utils","exports"],function(t,e){"use strict";function n(t){var e=this;if(!r(t))throw new TypeError("You must pass an array to all.");return new e(function(e,n){function r(t){return function(e){i(t,e)}}function i(t,n){a[t]=n,0===--c&&e(a)}var s,a=[],c=t.length;0===c&&e([]);for(var h=0;t.length>h;h++)s=t[h],s&&o(s.then)?s.then(r(h),n):i(h,s)})}var r=t.isArray,o=t.isFunction;e.all=n}),r("promise/asap",["exports"],function(r){"use strict";function o(){return function(){process.nextTick(a)}}function i(){var t=0,n=new p(a),r=e.createTextNode("");return n.observe(r,{characterData:!0}),function(){r.data=t=++t%2}}function s(){return function(){l.setTimeout(a,1)}}function a(){for(var t=0;d.length>t;t++){var e=d[t],n=e[0],r=e[1];n(r)}d=[]}function c(t,e){var n=d.push([t,e]);1===n&&h()}var h,u=t!==n?t:{},p=u.MutationObserver||u.WebKitMutationObserver,l="undefined"!=typeof global?global:this,d=[];h="undefined"!=typeof process&&"[object process]"==={}.toString.call(process)?o():p?i():s(),r.asap=c}),r("promise/cast",["exports"],function(t){"use strict";function e(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var e=this;return new e(function(e){e(t)})}t.cast=e}),r("promise/config",["exports"],function(t){"use strict";function e(t,e){return 2!==arguments.length?n[t]:(n[t]=e,void 0)}var n={instrument:!1};t.config=n,t.configure=e}),r("promise/polyfill",["./promise","./utils","exports"],function(e,n,r){"use strict";function o(){var e="Promise"in t&&"cast"in t.Promise&&"resolve"in t.Promise&&"reject"in t.Promise&&"all"in t.Promise&&"race"in t.Promise&&function(){var e;return new t.Promise(function(t){e=t}),s(e)}();e||(t.Promise=i)}var i=e.Promise,s=n.isFunction;r.polyfill=o}),r("promise/promise",["./config","./utils","./cast","./all","./race","./resolve","./reject","./asap","exports"],function(t,e,n,r,o,i,s,a,c){"use strict";function h(t){if(!T(t))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof h))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this._subscribers=[],u(t,this)}function u(t,e){function n(t){g(e,t)}function r(t){y(e,t)}try{t(n,r)}catch(o){r(o)}}function p(t,e,n,r){var o,i,s,a,c=T(n);if(c)try{o=n(r),s=!0}catch(h){a=!0,i=h}else o=r,s=!0;f(e,o)||(c&&s?g(e,o):a?y(e,i):t===A?g(e,o):t===M&&y(e,o))}function l(t,e,n,r){var o=t._subscribers,i=o.length;o[i]=e,o[i+A]=n,o[i+M]=r}function d(t,e){for(var n,r,o=t._subscribers,i=t._detail,s=0;o.length>s;s+=3)n=o[s],r=o[s+e],p(e,n,r,i);t._subscribers=null}function f(t,e){var n,r=null;try{if(t===e)throw new TypeError("A promises callback cannot return that same promise.");if(x(e)&&(r=e.then,T(r)))return r.call(e,function(r){return n?!0:(n=!0,e!==r?g(t,r):m(t,r),void 0)},function(e){return n?!0:(n=!0,y(t,e),void 0)}),!0}catch(o){return n?!0:(y(t,o),!0)}return!1}function g(t,e){t===e?m(t,e):f(t,e)||m(t,e)}function m(t,e){t._state===O&&(t._state=B,t._detail=e,b.async(v,t))}function y(t,e){t._state===O&&(t._state=B,t._detail=e,b.async(w,t))}function v(t){d(t,t._state=A)}function w(t){d(t,t._state=M)}var b=t.config,x=(t.configure,e.objectOrFunction),T=e.isFunction,E=(e.now,n.cast),k=r.all,I=o.race,R=i.resolve,C=s.reject,S=a.asap;b.async=S;var O=void 0,B=0,A=1,M=2;h.prototype={constructor:h,_state:void 0,_detail:void 0,_subscribers:void 0,then:function(t,e){var n=this,r=new this.constructor(function(){});if(this._state){var o=arguments;b.async(function(){p(n._state,r,o[n._state-1],n._detail)})}else l(this,r,t,e);return r},"catch":function(t){return this.then(null,t)}},h.all=k,h.cast=E,h.race=I,h.resolve=R,h.reject=C,c.Promise=h}),r("promise/race",["./utils","exports"],function(t,e){"use strict";function n(t){var e=this;if(!r(t))throw new TypeError("You must pass an array to race.");return new e(function(e,n){for(var r,o=0;t.length>o;o++)r=t[o],r&&"function"==typeof r.then?r.then(e,n):e(r)})}var r=t.isArray;e.race=n}),r("promise/reject",["exports"],function(t){"use strict";function e(t){var e=this;return new e(function(e,n){n(t)})}t.reject=e}),r("promise/resolve",["exports"],function(t){"use strict";function e(t){var e=this;return new e(function(e){e(t)})}t.resolve=e}),r("promise/utils",["exports"],function(t){"use strict";function e(t){return n(t)||"object"==typeof t&&null!==t}function n(t){return"function"==typeof t}function r(t){return"[object Array]"===Object.prototype.toString.call(t)}var o=Date.now||function(){return(new Date).getTime()};t.objectOrFunction=e,t.isFunction=n,t.isArray=r,t.now=o}),o("promise/polyfill").polyfill()}(),"function"!=typeof Object.create||"function"!=typeof e.createElement("canvas").getContext)return t.html2canvas=function(){return Promise.reject("No canvas support")},n;var me="data-html2canvas-node";t.html2canvas=function(o,i){i=i||{},i.logging&&(t.html2canvas.logging=!0,t.html2canvas.start=Date.now()),i.async=i.async===n?!0:i.async,i.removeContainer=i.removeContainer===n?!0:i.removeContainer;var s=(o===n?[e.documentElement]:o.length?o:[o])[0];return s.setAttribute(me,"true"),r(s.ownerDocument,i,t.innerWidth,t.innerHeight).then(function(t){return"function"==typeof i.onrendered&&(b("options.onrendered is deprecated, html2canvas returns a Promise containing the canvas"),i.onrendered(t)),t})},d.prototype.getMetrics=function(t,e){return this.data[t+"-"+e]===n&&(this.data[t+"-"+e]=new l(t,e)),this.data[t+"-"+e]},f.prototype.TYPES={LINEAR:1,RADIAL:2},f.prototype.angleRegExp=/([+-]?\d*\.?\d+)(deg|grad|rad|turn)/,m.prototype.findImages=function(t){var e=[];return t.filter(y).map(v).forEach(this.addImage(e,this.loadImage),this),e},m.prototype.findBackgroundImage=function(t,e){return e.parseBackgroundImages().filter(this.hasImageBackground).forEach(this.addImage(t,this.loadImage),this),t},m.prototype.addImage=function(t,e){return function(n){this.imageExists(t,n)||(t.splice(0,0,e.apply(this,arguments)),b("Added image #"+t.length,n))}},m.prototype.hasImageBackground=function(t){return"none"!==t.method},m.prototype.loadImage=function(t){if("url"===t.method){var e=t.args[0];return e.match(/data:image\/.*;base64,/i)?new g(e.replace(/url\(['"]{0,}|['"]{0,}\)$/gi,""),!1):this.isSameOrigin(e)||this.options.allowTaint===!0?new g(e,!1):this.support.cors&&!this.options.allowTaint&&this.options.useCORS?new g(e,!0):this.options.proxy?new ce(e,this.options.proxy):new p(e)}return"linear-gradient"===t.method?new w(t):"gradient"===t.method?new ge(t):new p(t)},m.prototype.imageExists=function(t,e){return t.some(function(t){return t.src===e})},m.prototype.isSameOrigin=function(t){var n=this.link||(this.link=e.createElement("a"));n.href=t,n.href=n.href;var r=n.protocol+n.hostname+n.port;return r===this.origin},m.prototype.getPromise=function(t){return t.promise},m.prototype.get=function(t){var e=null;return this.images.some(function(n){return(e=n).src===t})?e:null},m.prototype.fetch=function(t){return this.images=t.reduce(ne(this.findBackgroundImage,this),this.findImages(t)),this.images.forEach(function(t,e){t.promise.then(function(){b("Succesfully loaded image #"+(e+1))},function(){b("Failed loading image #"+(e+1))})}),this.ready=Promise.all(this.images.map(this.getPromise)),b("Finished searching images"),this},w.prototype=Object.create(f.prototype),w.prototype.stepRegExp=/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\))\s*(\d{1,3})?(%|px)?/,x.prototype.assignStack=function(t){this.stack=t,t.children.push(this)},x.prototype.isElementVisible=function(){return this.node.nodeType===Node.TEXT_NODE?this.parent.visible:"none"!==this.css("display")&&"hidden"!==this.css("visibility")&&!this.node.hasAttribute("data-html2canvas-ignore")},x.prototype.css=function(t){return this.computedStyles||(this.computedStyles=this.computedStyle(null)),this.styles[t]||(this.styles[t]=this.computedStyles[t])},x.prototype.prefixedCss=function(t){var e=["webkit","moz","ms","o"],r=this.css(t);return r===n&&e.some(function(e){return r=this.css(e+t.substr(0,1).toUpperCase()+t.substr(1)),r!==n},this),r===n?null:r},x.prototype.computedStyle=function(t){return this.node.ownerDocument.defaultView.getComputedStyle(this.node,t)},x.prototype.cssInt=function(t){var e=parseInt(this.css(t),10);return isNaN(e)?0:e},x.prototype.cssFloat=function(t){var e=parseFloat(this.css(t));return isNaN(e)?0:e},x.prototype.fontWeight=function(){var t=this.css("fontWeight");switch(parseInt(t,10)){case 401:t="bold";break;case 400:t="normal"}return t},x.prototype.parseBackgroundImages=function(){return this.backgroundImages||(this.backgroundImages=I(this.css("backgroundImage")))},x.prototype.cssList=function(t,e){var n=(this.css(t)||"").split(",");return n=n[e||0]||n[0]||"auto",n=n.trim().split(" "),1===n.length&&(n=[n[0],n[0]]),n},x.prototype.parseBackgroundSize=function(t,e,n){var r,o,i=this.cssList("backgroundSize",n);if(k(i[0]))r=t.width*parseFloat(i[0])/100;else{if(/contain|cover/.test(i[0])){var s=t.width/t.height,a=e.width/e.height;return a>s^"contain"===i[0]?{width:t.height*a,height:t.height}:{width:t.width,height:t.width/a}}r=parseInt(i[0],10)}return o="auto"===i[0]&&"auto"===i[1]?e.height:"auto"===i[1]?r/e.width*e.height:k(i[1])?t.height*parseFloat(i[1])/100:parseInt(i[1],10),"auto"===i[0]&&(r=o/e.height*e.width),{width:r,height:o}},x.prototype.parseBackgroundPosition=function(t,e,n,r){var o,i,s=this.cssList("backgroundPosition",n);return o=k(s[0])?(t.width-(r||e).width)*(parseFloat(s[0])/100):parseInt(s[0],10),i="auto"===s[1]?o/e.width*e.height:k(s[1])?(t.height-(r||e).height)*parseFloat(s[1])/100:parseInt(s[1],10),"auto"===s[0]&&(o=i/e.height*e.width),{left:o,top:i}},x.prototype.parseBackgroundRepeat=function(t){return this.cssList("backgroundRepeat",t)[0]},x.prototype.parseTextShadows=function(){var t=this.css("textShadow"),e=[];if(t&&"none"!==t)for(var n=t.match(this.TEXT_SHADOW_PROPERTY),r=0;n&&n.length>r;r++){var o=n[r].match(this.TEXT_SHADOW_VALUES);e.push({color:o[0],offsetX:o[1]?o[1].replace("px",""):0,offsetY:o[2]?o[2].replace("px",""):0,blur:o[3]?o[3].replace("px",""):0})}return e},x.prototype.parseTransform=function(){if(!this.transformData)if(this.hasTransform()){var t=this.parseBounds(),e=this.prefixedCss("transformOrigin").split(" ").map(R).map(C);e[0]+=t.left,e[1]+=t.top,this.transformData={origin:e,matrix:this.parseTransformMatrix()}}else this.transformData={origin:[0,0],matrix:[1,0,0,1,0,0]};return this.transformData},x.prototype.parseTransformMatrix=function(){if(!this.transformMatrix){var t=this.prefixedCss("transform"),e=t?E(t.match(this.MATRIX_PROPERTY)):null;this.transformMatrix=e?e:[1,0,0,1,0,0]}return this.transformMatrix},x.prototype.parseBounds=function(){return this.bounds||(this.bounds=this.hasTransform()?O(this.node):S(this.node))},x.prototype.hasTransform=function(){return"1,0,0,1,0,0"!==this.parseTransformMatrix().join(",")||this.parent&&this.parent.hasTransform()},x.prototype.getValue=function(){var t=this.node.value||"";return t="SELECT"===this.node.tagName?T(this.node):t,0===t.length?this.node.placeholder||"":t},x.prototype.MATRIX_PROPERTY=/(matrix)\((.+)\)/,x.prototype.TEXT_SHADOW_PROPERTY=/((rgba|rgb)\([^\)]+\)(\s-?\d+px){0,})/g,x.prototype.TEXT_SHADOW_VALUES=/(-?\d+px)|(#.+)|(rgb\(.+\))|(rgba\(.+\))/g,B.prototype.asyncRenderer=function(t,e,n){n=n||Date.now(),this.paint(t[this.renderIndex++]),t.length===this.renderIndex?e():n+20>Date.now()?this.asyncRenderer(t,e,n):setTimeout(ne(function(){this.asyncRenderer(t,e)},this),0)},B.prototype.createPseudoHideStyles=function(t){var e=t.createElement("style");e.innerHTML="."+this.pseudoHideClass+':before { content: "" !important; display: none !important; }'+"."+this.pseudoHideClass+':after { content: "" !important; display: none !important; }',t.body.appendChild(e)},B.prototype.getPseudoElements=function(t){var e=[[t]];if(t.node.nodeType===Node.ELEMENT_NODE){var n=this.getPseudoElement(t,":before"),r=this.getPseudoElement(t,":after");n&&(t.node.insertBefore(n[0].node,t.node.firstChild),e.push(n)),r&&(t.node.appendChild(r[0].node),e.push(r)),(n||r)&&(t.node.className+=" "+this.pseudoHideClass)}return se(e)},B.prototype.getPseudoElement=function(t,n){var r=t.computedStyle(n);if(!r||!r.content||"none"===r.content||"-moz-alt-content"===r.content||"none"===r.display)return null;for(var o=ae(r.content),i="url"===o.substr(0,3),s=e.createElement(i?"img":"html2canvaspseudoelement"),a=new x(s,t),c=r.length-1;c>=0;c--){var h=A(r.item(c));s.style[h]=r[h]}if(s.className=this.pseudoHideClass,i)return s.src=I(o)[0].args[0],[a];var u=e.createTextNode(o);return s.appendChild(u),[a,new de(u,a)]},B.prototype.getChildren=function(t){return se([].filter.call(t.node.childNodes,U).map(function(e){var n=[e.nodeType===Node.TEXT_NODE?new de(e,t):new x(e,t)].filter(ie);return e.nodeType===Node.ELEMENT_NODE&&n.length&&"TEXTAREA"!==e.tagName?n[0].isElementVisible()?n.concat(this.getChildren(n[0])):[]:n},this))},B.prototype.newStackingContext=function(t,e){var n=new pe(e,t.cssFloat("opacity"),t.node,t.parent);n.visible=t.visible;var r=e?n.getParentStack(this):n.parent.stack;r.contexts.push(n),t.stack=n},B.prototype.createStackingContexts=function(){this.nodes.forEach(function(t){K(t)&&(this.isRootElement(t)||ee(t)||Q(t)||this.isBodyWithTransparentRoot(t)||t.hasTransform())?this.newStackingContext(t,!0):K(t)&&(G(t)&&H(t)||$(t)||q(t))?this.newStackingContext(t,!1):t.assignStack(t.parent.stack)},this)},B.prototype.isBodyWithTransparentRoot=function(t){return"BODY"===t.node.nodeName&&this.renderer.isTransparent(t.parent.css("backgroundColor"))},B.prototype.isRootElement=function(t){return null===t.parent},B.prototype.sortStackingContexts=function(t){t.contexts.sort(te),t.contexts.forEach(this.sortStackingContexts,this)},B.prototype.parseTextBounds=function(t){return function(e,n,r){if("none"!==t.parent.css("textDecoration").substr(0,4)||0!==e.trim().length){if(this.support.rangeBounds&&!t.parent.hasTransform()){var o=r.slice(0,n).join("").length;return this.getRangeBounds(t.node,o,e.length)}if(t.node&&"string"==typeof t.node.data){var i=t.node.splitText(e.length),s=this.getWrapperBounds(t.node,t.parent.hasTransform());return t.node=i,s}}else(!this.support.rangeBounds||t.parent.hasTransform())&&(t.node=t.node.splitText(e.length));return{}}},B.prototype.getWrapperBounds=function(t,e){var n=t.ownerDocument.createElement("html2canvaswrapper"),r=t.parentNode,o=t.cloneNode(!0);n.appendChild(t.cloneNode(!0)),r.replaceChild(n,t);var i=e?O(n):S(n);return r.replaceChild(o,n),i},B.prototype.getRangeBounds=function(t,e,n){var r=this.range||(this.range=t.ownerDocument.createRange());return r.setStart(t,e),r.setEnd(t,e+n),r.getBoundingClientRect()},B.prototype.parse=function(t){var e=t.contexts.filter(W),n=t.children.filter(K),r=n.filter(J(q)),o=r.filter(J(G)).filter(J(j)),i=n.filter(J(G)).filter(q),s=r.filter(J(G)).filter(j),a=t.contexts.concat(r.filter(G)).filter(H),c=t.children.filter(Z).filter(V),h=t.contexts.filter(F);e.concat(o).concat(i).concat(s).concat(a).concat(c).concat(h).forEach(function(t){this.renderQueue.push(t),z(t)&&(this.parse(t),this.renderQueue.push(new M))},this)},B.prototype.paint=function(t){try{t instanceof M?this.renderer.ctx.restore():Z(t)?this.paintText(t):this.paintNode(t)}catch(e){b(e)}},B.prototype.paintNode=function(t){z(t)&&(this.renderer.setOpacity(t.opacity),this.renderer.ctx.save(),t.hasTransform()&&this.renderer.setTransform(t.parseTransform()));var e=t.parseBounds(),n=this.parseBorders(t);switch(this.renderer.clip(n.clip,function(){this.renderer.renderBackground(t,e,n.borders.map(oe))},this),this.renderer.renderBorders(n.borders),t.node.nodeName){case"IMG":var r=this.images.get(t.node.src);r?this.renderer.renderImage(t,e,n,r.image):b("Error loading ",t.node.src);break;case"SELECT":case"INPUT":case"TEXTAREA":this.paintFormValue(t)}},B.prototype.paintFormValue=function(t){if(t.getValue().length>0){var e=t.node.ownerDocument,n=e.createElement("html2canvaswrapper"),r=["lineHeight","textAlign","fontFamily","fontWeight","fontSize","color","paddingLeft","paddingTop","paddingRight","paddingBottom","width","height","borderLeftStyle","borderTopStyle","borderLeftWidth","borderTopWidth","boxSizing","whiteSpace","wordWrap"];r.forEach(function(e){try{n.style[e]=t.css(e)}catch(r){b("html2canvas: Parse: Exception caught in renderFormValue: "+r.message)}});var o=t.parseBounds();n.style.position="absolute",n.style.left=o.left+"px",n.style.top=o.top+"px",n.textContent=t.getValue(),e.body.appendChild(n),this.paintText(new de(n.firstChild,t)),e.body.removeChild(n)}},B.prototype.paintText=function(t){t.applyTextTransform();var e=t.node.data.split(!this.options.letterRendering||Y(t)?/(\b| )/:""),n=t.parent.fontWeight(),r=t.parent.css("fontSize"),o=t.parent.css("fontFamily"),i=t.parent.parseTextShadows();this.renderer.font(t.parent.css("color"),t.parent.css("fontStyle"),t.parent.css("fontVariant"),n,r,o),i.length?this.renderer.fontShadow(i[0].color,i[0].offsetX,i[0].offsetY,i[0].blur):this.renderer.clearShadow(),e.map(this.parseTextBounds(t),this).forEach(function(n,i){n&&(this.renderer.text(e[i],n.left,n.bottom),this.renderTextDecoration(t.parent,n,this.fontMetrics.getMetrics(o,r)))},this)},B.prototype.renderTextDecoration=function(t,e,n){switch(t.css("textDecoration").split(" ")[0]){case"underline":this.renderer.rectangle(e.left,Math.round(e.top+n.baseline+n.lineWidth),e.width,1,t.css("color"));break;case"overline":this.renderer.rectangle(e.left,Math.round(e.top),e.width,1,t.css("color"));break;case"line-through":this.renderer.rectangle(e.left,Math.ceil(e.top+n.middle+n.lineWidth),e.width,1,t.css("color"))}},B.prototype.parseBorders=function(t){var e=t.bounds,n=X(t),r=["Top","Right","Bottom","Left"].map(function(e){return{width:t.cssInt("border"+e+"Width"),color:t.css("border"+e+"Color"),args:null}}),o=P(e,n,r);return{clip:this.parseBackgroundClip(t,o,r,n,e),borders:r.map(function(t,i){if(t.width>0){var s=e.left,a=e.top,c=e.width,h=e.height-r[2].width;switch(i){case 0:h=r[0].width,t.args=D({c1:[s,a],c2:[s+c,a],c3:[s+c-r[1].width,a+h],c4:[s+r[3].width,a+h]},n[0],n[1],o.topLeftOuter,o.topLeftInner,o.topRightOuter,o.topRightInner); -break;case 1:s=e.left+e.width-r[1].width,c=r[1].width,t.args=D({c1:[s+c,a],c2:[s+c,a+h+r[2].width],c3:[s,a+h],c4:[s,a+r[0].width]},n[1],n[2],o.topRightOuter,o.topRightInner,o.bottomRightOuter,o.bottomRightInner);break;case 2:a=a+e.height-r[2].width,h=r[2].width,t.args=D({c1:[s+c,a+h],c2:[s,a+h],c3:[s+r[3].width,a],c4:[s+c-r[3].width,a]},n[2],n[3],o.bottomRightOuter,o.bottomRightInner,o.bottomLeftOuter,o.bottomLeftInner);break;case 3:c=r[3].width,t.args=D({c1:[s,a+h+r[2].width],c2:[s,a],c3:[s+c,a+r[0].width],c4:[s+c,a+h]},n[3],n[0],o.bottomLeftOuter,o.bottomLeftInner,o.topLeftOuter,o.topLeftInner)}}return t})}},B.prototype.parseBackgroundClip=function(t,e,n,r,o){var i=t.css("backgroundClip"),s=[];switch(i){case"content-box":case"padding-box":_(s,r[0],r[1],e.topLeftInner,e.topRightInner,o.left+n[3].width,o.top+n[0].width),_(s,r[1],r[2],e.topRightInner,e.bottomRightInner,o.left+o.width-n[1].width,o.top+n[0].width),_(s,r[2],r[3],e.bottomRightInner,e.bottomLeftInner,o.left+o.width-n[1].width,o.top+o.height-n[2].width),_(s,r[3],r[0],e.bottomLeftInner,e.topLeftInner,o.left+n[3].width,o.top+o.height-n[2].width);break;default:_(s,r[0],r[1],e.topLeftOuter,e.topRightOuter,o.left,o.top),_(s,r[1],r[2],e.topRightOuter,e.bottomRightOuter,o.left+o.width,o.top),_(s,r[2],r[3],e.bottomRightOuter,e.bottomLeftOuter,o.left+o.width,o.top+o.height),_(s,r[3],r[0],e.bottomLeftOuter,e.topLeftOuter,o.left,o.top+o.height)}return s},B.prototype.pseudoHideClass="___html2canvas___pseudoelement";var ye=0;he.prototype.renderImage=function(t,e,n,r){var o=t.cssInt("paddingLeft"),i=t.cssInt("paddingTop"),s=t.cssInt("paddingRight"),a=t.cssInt("paddingBottom"),c=n.borders;this.drawImage(r,0,0,r.width,r.height,e.left+o+c[3].width,e.top+i+c[0].width,e.width-(c[1].width+c[3].width+o+s),e.height-(c[0].width+c[2].width+i+a))},he.prototype.renderBackground=function(t,e,n){e.height>0&&e.width>0&&(this.renderBackgroundColor(t,e),this.renderBackgroundImage(t,e,n))},he.prototype.renderBackgroundColor=function(t,e){var n=t.css("backgroundColor");this.isTransparent(n)||this.rectangle(e.left,e.top,e.width,e.height,t.css("backgroundColor"))},he.prototype.renderBorders=function(t){t.forEach(this.renderBorder,this)},he.prototype.renderBorder=function(t){this.isTransparent(t.color)||null===t.args||this.drawShape(t.args,t.color)},he.prototype.renderBackgroundImage=function(t,e,n){var r=t.parseBackgroundImages();r.reverse().forEach(function(r,o,i){switch(r.method){case"url":var s=this.images.get(r.args[0]);s?this.renderBackgroundRepeating(t,e,s,i.length-(o+1),n):b("Error loading background-image",r.args[0]);break;case"linear-gradient":case"gradient":var a=this.images.get(r.value);a?this.renderBackgroundGradient(a,e,n):b("Error loading background-image",r.args[0]);break;case"none":break;default:b("Unknown background-image type",r.args[0])}},this)},he.prototype.renderBackgroundRepeating=function(t,e,n,r,o){var i=t.parseBackgroundSize(e,n.image,r),s=t.parseBackgroundPosition(e,n.image,r,i),a=t.parseBackgroundRepeat(r);switch(a){case"repeat-x":case"repeat no-repeat":this.backgroundRepeatShape(n,s,i,e,e.left+o[3],e.top+s.top+o[0],99999,n.image.height,o);break;case"repeat-y":case"no-repeat repeat":this.backgroundRepeatShape(n,s,i,e,e.left+s.left+o[3],e.top+o[0],n.image.width,99999,o);break;case"no-repeat":this.backgroundRepeatShape(n,s,i,e,e.left+s.left+o[3],e.top+s.top+o[0],n.image.width,n.image.height,o);break;default:this.renderBackgroundRepeat(n,s,i,{top:e.top,left:e.left},o[3],o[0])}},he.prototype.isTransparent=function(t){return!t||"transparent"===t||"rgba(0, 0, 0, 0)"===t},ue.prototype=Object.create(he.prototype),ue.prototype.setFillStyle=function(t){return this.ctx.fillStyle=t,this.ctx},ue.prototype.rectangle=function(t,e,n,r,o){this.setFillStyle(o).fillRect(t,e,n,r)},ue.prototype.drawShape=function(t,e){this.shape(t),this.setFillStyle(e).fill()},ue.prototype.drawImage=function(t,e,n,r,o,i,s,a,c){this.ctx.drawImage(t,e,n,r,o,i,s,a,c)},ue.prototype.clip=function(t,e,n){this.ctx.save(),this.shape(t).clip(),e.call(n),this.ctx.restore()},ue.prototype.shape=function(t){return this.ctx.beginPath(),t.forEach(function(t,e){this.ctx[0===e?"moveTo":t[0]+"To"].apply(this.ctx,t.slice(1))},this),this.ctx.closePath(),this.ctx},ue.prototype.font=function(t,e,n,r,o,i){this.setFillStyle(t).font=[e,n,r,o,i].join(" ")},ue.prototype.fontShadow=function(t,e,n,r){this.setVariable("shadowColor",t).setVariable("shadowOffsetY",e).setVariable("shadowOffsetX",n).setVariable("shadowBlur",r)},ue.prototype.clearShadow=function(){this.setVariable("shadowColor","rgba(0,0,0,0)")},ue.prototype.setOpacity=function(t){this.ctx.globalAlpha=t},ue.prototype.setTransform=function(t){this.ctx.translate(t.origin[0],t.origin[1]),this.ctx.transform.apply(this.ctx,t.matrix),this.ctx.translate(-t.origin[0],-t.origin[1])},ue.prototype.setVariable=function(t,e){return this.variables[t]!==e&&(this.variables[t]=this.ctx[t]=e),this},ue.prototype.text=function(t,e,n){this.ctx.fillText(t,e,n)},ue.prototype.backgroundRepeatShape=function(t,e,n,r,o,i,s,a,c){var h=[["line",Math.round(o),Math.round(i)],["line",Math.round(o+s),Math.round(i)],["line",Math.round(o+s),Math.round(a+i)],["line",Math.round(o),Math.round(a+i)]];this.clip(h,function(){this.renderBackgroundRepeat(t,e,n,r,c[3],c[0])},this)},ue.prototype.renderBackgroundRepeat=function(t,e,n,r,o,i){var s=Math.round(r.left+e.left+o),a=Math.round(r.top+e.top+i);this.setFillStyle(this.ctx.createPattern(this.resizeImage(t,n),"repeat")),this.ctx.translate(s,a),this.ctx.fill(),this.ctx.translate(-s,-a)},ue.prototype.renderBackgroundGradient=function(t,e){if(t instanceof w){var n=this.ctx.createLinearGradient(e.left+e.width*t.x0,e.top+e.height*t.y0,e.left+e.width*t.x1,e.top+e.height*t.y1);t.colorStops.forEach(function(t){n.addColorStop(t.stop,t.color)}),this.rectangle(e.left,e.top,e.width,e.height,n)}},ue.prototype.resizeImage=function(t,n){var r=t.image;if(r.width===n.width&&r.height===n.height)return r;var o,i=e.createElement("canvas");return i.width=n.width,i.height=n.height,o=i.getContext("2d"),o.drawImage(r,0,0,r.width,r.height,0,0,n.width,n.height),i},pe.prototype=Object.create(x.prototype),pe.prototype.getParentStack=function(t){var e=this.parent?this.parent.stack:null;return e?e.ownStacking?e:e.getParentStack(t):t.stack},le.prototype.testRangeBounds=function(t){var e,n,r,o,i=!1;return t.createRange&&(e=t.createRange(),e.getBoundingClientRect&&(n=t.createElement("boundtest"),n.style.height="123px",n.style.display="block",t.body.appendChild(n),e.selectNode(n),r=e.getBoundingClientRect(),o=r.height,123===o&&(i=!0),t.body.removeChild(n))),i},le.prototype.testCORS=function(){return(new Image).crossOrigin!==n},de.prototype=Object.create(x.prototype),de.prototype.applyTextTransform=function(){this.node.data=this.transform(this.parent.css("textTransform"))},de.prototype.transform=function(t){var e=this.node.data;switch(t){case"lowercase":return e.toLowerCase();case"capitalize":return e.replace(/(^|\s|:|-|\(|\))([a-z])/g,fe);case"uppercase":return e.toUpperCase();default:return e}},ge.prototype=Object.create(f.prototype)})(window,document); \ No newline at end of file diff --git a/build/html2canvas.js b/dist/html2canvas.js similarity index 98% rename from build/html2canvas.js rename to dist/html2canvas.js index 69e24d4..16d0abd 100644 --- a/build/html2canvas.js +++ b/dist/html2canvas.js @@ -1,5 +1,5 @@ /* - html2canvas 0.5.0-rc1 + html2canvas 0.5.0-alpha Copyright (c) 2014 Niklas von Hertzen Released under MIT License @@ -420,6 +420,32 @@ function LinearGradientContainer(imageData) { this.x1 = x0; this.y1 = y0; break; + default: + var angle = position.match(this.angleRegExp); + if (angle) { + switch(angle[2]) { + case "deg": + var angleDeg = parseFloat(angle[1]); + var radians = angleDeg / (180 / Math.PI); + var slope = Math.tan(radians); // m + + var perpendicularSlope = -1 / slope; + + + + // y = 2 + // y = m * x + // 2 = m * x + + this.y0 = 2 / Math.tan(slope) / 2; // 1 + // console.log(radians, angle); + this.x0 = 0; + this.x1 = 1; + this.y1 = 0; + + break; + } + } } }, this); } else { diff --git a/dist/html2canvas.min.js b/dist/html2canvas.min.js new file mode 100644 index 0000000..7898c09 --- /dev/null +++ b/dist/html2canvas.min.js @@ -0,0 +1,8 @@ +/* + html2canvas 0.5.0-alpha + Copyright (c) 2014 Niklas von Hertzen + + Released under MIT License +*/ +!function(a,b,c){function d(a,b,c,d){return i(a,c,d,b).then(function(h){u("Document cloned");var i="["+qb+"='true']";a.querySelector(i).removeAttribute(qb);var j=h.contentWindow,k=j.document.querySelector(i),l=new mb(j.document),m=new q(b,l),n=C(k),o="view"===b.type?Math.min(n.width,c):f(),p="view"===b.type?Math.min(n.height,d):g(),r=new kb(o,p,m),s=new E(k,r,l,m,b);return s.ready.then(function(){return u("Finished rendering"),b.removeContainer&&h.parentNode.removeChild(h),"view"===b.type||k!==j.document.body&&k!==j.document.documentElement?e(r.canvas,n):r.canvas})})}function e(a,c){var d=b.createElement("canvas"),e=Math.min(a.width-1,Math.max(0,c.left)),f=Math.min(a.width,Math.max(1,c.left+c.width)),g=Math.min(a.height-1,Math.max(0,c.top)),h=Math.min(a.height,Math.max(1,c.top+c.height)),i=d.width=f-e,j=d.height=h-g;return u("Cropping canvas at:","left:",c.left,"top:",c.top,"width:",c.width,"height:",c.height),u("Resulting crop with width",i,"and height",j," with x",e,"and y",g),d.getContext("2d").drawImage(a,e,g,i,j,0,0,i,j),d}function f(){return Math.max(Math.max(b.body.scrollWidth,b.documentElement.scrollWidth),Math.max(b.body.offsetWidth,b.documentElement.offsetWidth),Math.max(b.body.clientWidth,b.documentElement.clientWidth))}function g(){return Math.max(Math.max(b.body.scrollHeight,b.documentElement.scrollHeight),Math.max(b.body.offsetHeight,b.documentElement.offsetHeight),Math.max(b.body.clientHeight,b.documentElement.clientHeight))}function h(){return"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}function i(b,c,d,e){var f=b.documentElement.cloneNode(!0),g=b.createElement("iframe");return g.style.visibility="hidden",g.style.position="absolute",g.style.left=g.style.top="-10000px",g.width=c,g.height=d,g.scrolling="no",b.body.appendChild(g),new Promise(function(b){var c=g.contentWindow.document;g.contentWindow.onload=g.onload=function(){b(g)},c.open(),c.write(""),c.close(),c.replaceChild(j(c.adoptNode(f)),c.documentElement),"view"===e.type&&g.contentWindow.scrollTo(a.pageXOffset,a.pageYOffset)})}function j(a){return[].slice.call(a.childNodes,0).filter(k).forEach(function(b){"SCRIPT"===b.tagName?a.removeChild(b):j(b)}),a}function k(a){return a.nodeType===Node.ELEMENT_NODE}function l(a){if(this.src=a,u("DummyImageContainer for",a),!this.promise||!this.image){u("Initiating DummyImageContainer"),l.prototype.image=new Image;var b=this.image;l.prototype.promise=new Promise(function(a,c){b.onload=a,b.onerror=c,b.src=h(),b.complete===!0&&a(b)})}}function m(a,c){var d,e,f=b.createElement("div"),g=b.createElement("img"),i=b.createElement("span"),j="Hidden Text";f.style.visibility="hidden",f.style.fontFamily=a,f.style.fontSize=c,f.style.margin=0,f.style.padding=0,b.body.appendChild(f),g.src=h(),g.width=1,g.height=1,g.style.margin=0,g.style.padding=0,g.style.verticalAlign="baseline",i.style.fontFamily=a,i.style.fontSize=c,i.style.margin=0,i.style.padding=0,i.appendChild(b.createTextNode(j)),f.appendChild(i),f.appendChild(g),d=g.offsetTop-i.offsetTop+1,f.removeChild(i),f.appendChild(b.createTextNode(j)),f.style.lineHeight="normal",g.style.verticalAlign="super",e=g.offsetTop-f.offsetTop+1,b.body.removeChild(f),this.baseline=d,this.lineWidth=1,this.middle=e}function n(){this.data={}}function o(a){this.src=a.value,this.colorStops=[],this.type=null,this.x0=.5,this.y0=.5,this.x1=.5,this.y1=.5,this.promise=Promise.resolve(!0)}function p(a,b){this.src=a,this.image=new Image;var c=this;this.promise=new Promise(function(d,e){c.image.onload=d,c.image.onerror=e,b&&(c.image.crossOrigin="anonymous"),c.image.src=a,c.image.complete===!0&&d(c.image)})["catch"](function(){var b=new l(a);return b.promise.then(function(a){c.image=a})})}function q(b,c){this.link=null,this.options=b,this.support=c,this.origin=a.location.protocol+a.location.hostname+a.location.port}function r(a){return"IMG"===a.node.nodeName}function s(a){return{args:[a.node.src],method:"url"}}function t(a){o.apply(this,arguments),this.type=this.TYPES.LINEAR;var b=null===a.args[0].match(this.stepRegExp);b?a.args[0].split(" ").reverse().forEach(function(a){switch(a){case"left":this.x0=0,this.x1=1;break;case"top":this.y0=0,this.y1=1;break;case"right":this.x0=1,this.x1=0;break;case"bottom":this.y0=1,this.y1=0;break;case"to":var b=this.y0,c=this.x0;this.y0=this.y1,this.x0=this.x1,this.x1=c,this.y1=b;break;default:var d=a.match(this.angleRegExp);if(d)switch(d[2]){case"deg":var e=parseFloat(d[1]),f=e/(180/Math.PI),g=Math.tan(f);this.y0=2/Math.tan(g)/2,this.x0=0,this.x1=1,this.y1=0}}},this):(this.y0=0,this.y1=1),this.colorStops=a.args.slice(b?1:0).map(function(a){var b=a.match(this.stepRegExp);return{color:b[1],stop:"%"===b[3]?b[2]/100:null}},this),null===this.colorStops[0].stop&&(this.colorStops[0].stop=0),null===this.colorStops[this.colorStops.length-1].stop&&(this.colorStops[this.colorStops.length-1].stop=1),this.colorStops.forEach(function(a,b){null===a.stop&&this.colorStops.slice(b).some(function(c,d){return null!==c.stop?(a.stop=(c.stop-this.colorStops[b-1].stop)/(d+1)+this.colorStops[b-1].stop,!0):!1},this)},this)}function u(){a.html2canvas.logging&&a.console&&a.console.log&&Function.prototype.bind.call(a.console.log,a.console).apply(a.console,[Date.now()-a.html2canvas.start+"ms","html2canvas:"].concat([].slice.call(arguments,0)))}function v(a,b){this.node=a,this.parent=b,this.stack=null,this.bounds=null,this.offsetBounds=null,this.visible=null,this.computedStyles=null,this.styles={},this.backgroundImages=null,this.transformData=null,this.transformMatrix=null}function w(a){var b=a.options[a.selectedIndex||0];return b?b.text||"":""}function x(a){return a&&"matrix"===a[1]?a[2].split(",").map(function(a){return parseFloat(a.trim())}):void 0}function y(a){return-1!==a.toString().indexOf("%")}function z(a){var b,c,d,e,f,g,h,i=" \r\n ",j=[],k=0,l=0,m=function(){b&&('"'===c.substr(0,1)&&(c=c.substr(1,c.length-2)),c&&h.push(c),"-"===b.substr(0,1)&&(e=b.indexOf("-",1)+1)>0&&(d=b.substr(0,e),b=b.substr(e)),j.push({prefix:d,method:b.toLowerCase(),value:f,args:h,image:null})),h=[],b=d=c=f=""};return h=[],b=d=c=f="",a.split("").forEach(function(a){if(!(0===k&&i.indexOf(a)>-1)){switch(a){case'"':g?g===a&&(g=null):g=a;break;case"(":if(g)break;if(0===k)return k=1,void(f+=a);l++;break;case")":if(g)break;if(1===k){if(0===l)return k=0,f+=a,void m();l--}break;case",":if(g)break;if(0===k)return void m();if(1===k&&0===l&&!b.match(/^url$/i))return h.push(c),c="",void(f+=a)}f+=a,0===k?b+=a:c+=a}}),m(),j}function A(a){return a.replace("px","")}function B(a){return parseFloat(a)}function C(a){if(a.getBoundingClientRect){var b=a.getBoundingClientRect(),c="BODY"===a.nodeName,d=c?a.scrollWidth:a.offsetWidth;return{top:b.top,bottom:b.bottom||b.top+b.height,right:b.left+d,left:b.left,width:d,height:c?a.scrollHeight:a.offsetHeight}}return{}}function D(a){var b=a.offsetParent?D(a.offsetParent):{top:0,left:0};return{top:a.offsetTop+b.top,bottom:a.offsetTop+a.offsetHeight+b.top,right:a.offsetLeft+b.left+a.offsetWidth,left:a.offsetLeft+b.left,width:a.offsetWidth,height:a.offsetHeight}}function E(a,b,c,d,e){u("Starting NodeParser"),this.renderer=b,this.options=e,this.range=null,this.support=c,this.renderQueue=[],this.stack=new lb(!0,1,a.ownerDocument,null);var f=new v(a,null);a!==a.ownerDocument.documentElement&&this.renderer.isTransparent(f.css("backgroundColor"))&&b.rectangle(0,0,b.width,b.height,new v(a.ownerDocument.documentElement,null).css("backgroundColor")),f.visibile=f.isElementVisible(),this.createPseudoHideStyles(a.ownerDocument),this.nodes=gb([f].concat(this.getChildren(f)).filter(function(a){return a.visible=a.isElementVisible()}).map(this.getPseudoElements,this)),this.fontMetrics=new n,u("Fetched nodes"),this.images=d.fetch(this.nodes.filter($)),u("Creating stacking contexts"),this.createStackingContexts(),u("Sorting stacking contexts"),this.sortStackingContexts(this.stack),this.ready=this.images.ready.then(cb(function(){return u("Images loaded, starting parsing"),this.parse(this.stack),u("Render queue created with "+this.renderQueue.length+" items"),new Promise(cb(function(a){e.async?"function"==typeof e.async?e.async.call(this,this.renderQueue,a):(this.renderIndex=0,this.asyncRenderer(this.renderQueue,a)):(this.renderQueue.forEach(this.paint,this),a())},this))},this))}function F(a){return a.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function G(){}function H(a,b,c,d){var e=4*((Math.sqrt(2)-1)/3),f=c*e,g=d*e,h=a+c,i=b+d;return{topLeft:J({x:a,y:i},{x:a,y:i-g},{x:h-f,y:b},{x:h,y:b}),topRight:J({x:a,y:b},{x:a+f,y:b},{x:h,y:i-g},{x:h,y:i}),bottomRight:J({x:h,y:b},{x:h,y:b+g},{x:a+f,y:i},{x:a,y:i}),bottomLeft:J({x:h,y:i},{x:h-f,y:i},{x:a,y:b+g},{x:a,y:b})}}function I(a,b,c){var d=a.left,e=a.top,f=a.width,g=a.height,h=b[0][0],i=b[0][1],j=b[1][0],k=b[1][1],l=b[2][0],m=b[2][1],n=b[3][0],o=b[3][1],p=f-j,q=g-m,r=f-l,s=g-o;return{topLeftOuter:H(d,e,h,i).topLeft.subdivide(.5),topLeftInner:H(d+c[3].width,e+c[0].width,Math.max(0,h-c[3].width),Math.max(0,i-c[0].width)).topLeft.subdivide(.5),topRightOuter:H(d+p,e,j,k).topRight.subdivide(.5),topRightInner:H(d+Math.min(p,f+c[3].width),e+c[0].width,p>f+c[3].width?0:j-c[3].width,k-c[0].width).topRight.subdivide(.5),bottomRightOuter:H(d+r,e+q,l,m).bottomRight.subdivide(.5),bottomRightInner:H(d+Math.min(r,f+c[3].width),e+Math.min(q,g+c[0].width),Math.max(0,l-c[1].width),Math.max(0,m-c[2].width)).bottomRight.subdivide(.5),bottomLeftOuter:H(d,e+s,n,o).bottomLeft.subdivide(.5),bottomLeftInner:H(d+c[3].width,e+s,Math.max(0,n-c[3].width),Math.max(0,o-c[2].width)).bottomLeft.subdivide(.5)}}function J(a,b,c,d){var e=function(a,b,c){return{x:a.x+(b.x-a.x)*c,y:a.y+(b.y-a.y)*c}};return{start:a,startControl:b,endControl:c,end:d,subdivide:function(f){var g=e(a,b,f),h=e(b,c,f),i=e(c,d,f),j=e(g,h,f),k=e(h,i,f),l=e(j,k,f);return[J(a,g,j,l),J(l,k,i,d)]},curveTo:function(a){a.push(["bezierCurve",b.x,b.y,c.x,c.y,d.x,d.y])},curveToReversed:function(d){d.push(["bezierCurve",c.x,c.y,b.x,b.y,a.x,a.y])}}}function K(a,b,c,d,e,f,g){var h=[];return b[0]>0||b[1]>0?(h.push(["line",d[1].start.x,d[1].start.y]),d[1].curveTo(h)):h.push(["line",a.c1[0],a.c1[1]]),c[0]>0||c[1]>0?(h.push(["line",f[0].start.x,f[0].start.y]),f[0].curveTo(h),h.push(["line",g[0].end.x,g[0].end.y]),g[0].curveToReversed(h)):(h.push(["line",a.c2[0],a.c2[1]]),h.push(["line",a.c3[0],a.c3[1]])),b[0]>0||b[1]>0?(h.push(["line",e[1].end.x,e[1].end.y]),e[1].curveToReversed(h)):h.push(["line",a.c4[0],a.c4[1]]),h}function L(a,b,c,d,e,f,g){b[0]>0||b[1]>0?(a.push(["line",d[0].start.x,d[0].start.y]),d[0].curveTo(a),d[1].curveTo(a)):a.push(["line",f,g]),(c[0]>0||c[1]>0)&&a.push(["line",e[0].start.x,e[0].start.y])}function M(a){return a.cssInt("zIndex")<0}function N(a){return a.cssInt("zIndex")>0}function O(a){return 0===a.cssInt("zIndex")}function P(a){return-1!==["inline","inline-block","inline-table"].indexOf(a.css("display"))}function Q(a){return a instanceof lb}function R(a){return a.node.data.trim().length>0}function S(a){return/^(normal|none|0px)$/.test(a.parent.css("letterSpacing"))}function T(a){return["TopLeft","TopRight","BottomRight","BottomLeft"].map(function(b){var c=a.css("border"+b+"Radius"),d=c.split(" ");return d.length<=1&&(d[1]=d[0]),d.map(db)})}function U(a){return a.nodeType===Node.TEXT_NODE||a.nodeType===Node.ELEMENT_NODE}function V(a){var b=a.css("position"),c="absolute"===b||"relative"===b?a.css("zIndex"):"auto";return"auto"!==c}function W(a){return"static"!==a.css("position")}function X(a){return"none"!==a.css("float")}function Y(a){return-1!==["inline-block","inline-table"].indexOf(a.css("display"))}function Z(a){var b=this;return function(){return!a.apply(b,arguments)}}function $(a){return a.node.nodeType===Node.ELEMENT_NODE}function _(a){return a.node.nodeType===Node.TEXT_NODE}function ab(a,b){return a.cssInt("zIndex")-b.cssInt("zIndex")}function bb(a){return a.css("opacity")<1}function cb(a,b){return function(){return a.apply(b,arguments)}}function db(a){return parseInt(a,10)}function eb(a){return a.width}function fb(a){return a.node.nodeType!==Node.ELEMENT_NODE||-1===["SCRIPT","HEAD","TITLE","OBJECT","BR","OPTION"].indexOf(a.node.nodeName)}function gb(a){return[].concat.apply([],a)}function hb(a){var b=a.substr(0,1);return b===a.substr(a.length-1)&&b.match(/'|"/)?a.substr(1,a.length-2):a}function ib(d,e){var f="html2canvas_"+rb++,g=b.createElement("script"),h=b.createElement("a");h.href=d,d=h.href;var i=e+(e.indexOf("?")>-1?"&":"?")+"url="+encodeURIComponent(d)+"&callback="+f;this.src=d,this.image=new Image;var j=this;this.promise=new Promise(function(d,e){j.image.onload=d,j.image.onerror=e,a[f]=function(b){"error:"===b.substring(0,6)?e():j.image.src=b,a[f]=c;try{delete a[f]}catch(d){}g.parentNode.removeChild(g)},g.setAttribute("type","text/javascript"),g.setAttribute("src",i),b.body.appendChild(g)})["catch"](function(){var a=new l(d);return a.promise.then(function(a){j.image=a})})}function jb(a,b,c){this.width=a,this.height=b,this.images=c}function kb(a,c){jb.apply(this,arguments),this.canvas=b.createElement("canvas"),this.canvas.width=a,this.canvas.height=c,this.ctx=this.canvas.getContext("2d"),this.ctx.textBaseline="bottom",this.variables={},u("Initialized CanvasRenderer")}function lb(a,b,c,d){v.call(this,c,d),this.ownStacking=a,this.contexts=[],this.children=[],this.opacity=(this.parent?this.parent.stack.opacity:1)*b}function mb(a){this.rangeBounds=this.testRangeBounds(a),this.cors=this.testCORS()}function nb(a,b){v.call(this,a,b)}function ob(a,b,c){return a.length>0?b+c.toUpperCase():void 0}function pb(a){o.apply(this,arguments),this.type="linear"===a.args[0]?this.TYPES.LINEAR:this.TYPES.RADIAL}if(!function(){var c,d,e,f;!function(){var a={},b={};c=function(b,c,d){a[b]={deps:c,callback:d}},f=e=d=function(c){function e(a){if("."!==a.charAt(0))return a;for(var b=a.split("/"),d=c.split("/").slice(0,-1),e=0,f=b.length;f>e;e++){var g=b[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(f._eak_seen=a,b[c])return b[c];if(b[c]={},!a[c])throw new Error("Could not find module "+c);for(var g,h=a[c],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)k.push("exports"===i[l]?g={}:d(e(i[l])));var n=j.apply(this,k);return b[c]=g||n}}(),c("promise/all",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to all.");return new b(function(b,c){function d(a){return function(b){f(a,b)}}function f(a,c){h[a]=c,0===--i&&b(h)}var g,h=[],i=a.length;0===i&&b([]);for(var j=0;jg^"contain"===f[0]?{width:a.height*h,height:a.height}:{width:a.width,height:a.width/h}}d=parseInt(f[0],10)}return e="auto"===f[0]&&"auto"===f[1]?b.height:"auto"===f[1]?d/b.width*b.height:y(f[1])?a.height*parseFloat(f[1])/100:parseInt(f[1],10),"auto"===f[0]&&(d=e/b.height*b.width),{width:d,height:e}},v.prototype.parseBackgroundPosition=function(a,b,c,d){var e,f,g=this.cssList("backgroundPosition",c);return e=y(g[0])?(a.width-(d||b).width)*(parseFloat(g[0])/100):parseInt(g[0],10),f="auto"===g[1]?e/b.width*b.height:y(g[1])?(a.height-(d||b).height)*parseFloat(g[1])/100:parseInt(g[1],10),"auto"===g[0]&&(e=f/b.height*b.width),{left:e,top:f}},v.prototype.parseBackgroundRepeat=function(a){return this.cssList("backgroundRepeat",a)[0]},v.prototype.parseTextShadows=function(){var a=this.css("textShadow"),b=[];if(a&&"none"!==a)for(var c=a.match(this.TEXT_SHADOW_PROPERTY),d=0;c&&dDate.now()?this.asyncRenderer(a,b,c):setTimeout(cb(function(){this.asyncRenderer(a,b)},this),0)},E.prototype.createPseudoHideStyles=function(a){var b=a.createElement("style");b.innerHTML="."+this.pseudoHideClass+':before { content: "" !important; display: none !important; }.'+this.pseudoHideClass+':after { content: "" !important; display: none !important; }',a.body.appendChild(b)},E.prototype.getPseudoElements=function(a){var b=[[a]];if(a.node.nodeType===Node.ELEMENT_NODE){var c=this.getPseudoElement(a,":before"),d=this.getPseudoElement(a,":after");c&&(a.node.insertBefore(c[0].node,a.node.firstChild),b.push(c)),d&&(a.node.appendChild(d[0].node),b.push(d)),(c||d)&&(a.node.className+=" "+this.pseudoHideClass)}return gb(b)},E.prototype.getPseudoElement=function(a,c){var d=a.computedStyle(c);if(!d||!d.content||"none"===d.content||"-moz-alt-content"===d.content||"none"===d.display)return null;for(var e=hb(d.content),f="url"===e.substr(0,3),g=b.createElement(f?"img":"html2canvaspseudoelement"),h=new v(g,a),i=d.length-1;i>=0;i--){var j=F(d.item(i));g.style[j]=d[j]}if(g.className=this.pseudoHideClass,f)return g.src=z(e)[0].args[0],[h];var k=b.createTextNode(e);return g.appendChild(k),[h,new nb(k,h)]},E.prototype.getChildren=function(a){return gb([].filter.call(a.node.childNodes,U).map(function(b){var c=[b.nodeType===Node.TEXT_NODE?new nb(b,a):new v(b,a)].filter(fb);return b.nodeType===Node.ELEMENT_NODE&&c.length&&"TEXTAREA"!==b.tagName?c[0].isElementVisible()?c.concat(this.getChildren(c[0])):[]:c},this))},E.prototype.newStackingContext=function(a,b){var c=new lb(b,a.cssFloat("opacity"),a.node,a.parent);c.visible=a.visible;var d=b?c.getParentStack(this):c.parent.stack;d.contexts.push(c),a.stack=c},E.prototype.createStackingContexts=function(){this.nodes.forEach(function(a){$(a)&&(this.isRootElement(a)||bb(a)||V(a)||this.isBodyWithTransparentRoot(a)||a.hasTransform())?this.newStackingContext(a,!0):$(a)&&(W(a)&&O(a)||Y(a)||X(a))?this.newStackingContext(a,!1):a.assignStack(a.parent.stack)},this)},E.prototype.isBodyWithTransparentRoot=function(a){return"BODY"===a.node.nodeName&&this.renderer.isTransparent(a.parent.css("backgroundColor"))},E.prototype.isRootElement=function(a){return null===a.parent},E.prototype.sortStackingContexts=function(a){a.contexts.sort(ab),a.contexts.forEach(this.sortStackingContexts,this)},E.prototype.parseTextBounds=function(a){return function(b,c,d){if("none"!==a.parent.css("textDecoration").substr(0,4)||0!==b.trim().length){if(this.support.rangeBounds&&!a.parent.hasTransform()){var e=d.slice(0,c).join("").length;return this.getRangeBounds(a.node,e,b.length)}if(a.node&&"string"==typeof a.node.data){var f=a.node.splitText(b.length),g=this.getWrapperBounds(a.node,a.parent.hasTransform());return a.node=f,g}}else(!this.support.rangeBounds||a.parent.hasTransform())&&(a.node=a.node.splitText(b.length));return{}}},E.prototype.getWrapperBounds=function(a,b){var c=a.ownerDocument.createElement("html2canvaswrapper"),d=a.parentNode,e=a.cloneNode(!0);c.appendChild(a.cloneNode(!0)),d.replaceChild(c,a);var f=b?D(c):C(c);return d.replaceChild(e,c),f},E.prototype.getRangeBounds=function(a,b,c){var d=this.range||(this.range=a.ownerDocument.createRange());return d.setStart(a,b),d.setEnd(a,b+c),d.getBoundingClientRect()},E.prototype.parse=function(a){var b=a.contexts.filter(M),c=a.children.filter($),d=c.filter(Z(X)),e=d.filter(Z(W)).filter(Z(P)),f=c.filter(Z(W)).filter(X),g=d.filter(Z(W)).filter(P),h=a.contexts.concat(d.filter(W)).filter(O),i=a.children.filter(_).filter(R),j=a.contexts.filter(N);b.concat(e).concat(f).concat(g).concat(h).concat(i).concat(j).forEach(function(a){this.renderQueue.push(a),Q(a)&&(this.parse(a),this.renderQueue.push(new G))},this)},E.prototype.paint=function(a){try{a instanceof G?this.renderer.ctx.restore():_(a)?this.paintText(a):this.paintNode(a)}catch(b){u(b)}},E.prototype.paintNode=function(a){Q(a)&&(this.renderer.setOpacity(a.opacity),this.renderer.ctx.save(),a.hasTransform()&&this.renderer.setTransform(a.parseTransform()));var b=a.parseBounds(),c=this.parseBorders(a);switch(this.renderer.clip(c.clip,function(){this.renderer.renderBackground(a,b,c.borders.map(eb))},this),this.renderer.renderBorders(c.borders),a.node.nodeName){case"IMG":var d=this.images.get(a.node.src);d?this.renderer.renderImage(a,b,c,d.image):u("Error loading ",a.node.src);break;case"SELECT":case"INPUT":case"TEXTAREA":this.paintFormValue(a)}},E.prototype.paintFormValue=function(a){if(a.getValue().length>0){var b=a.node.ownerDocument,c=b.createElement("html2canvaswrapper"),d=["lineHeight","textAlign","fontFamily","fontWeight","fontSize","color","paddingLeft","paddingTop","paddingRight","paddingBottom","width","height","borderLeftStyle","borderTopStyle","borderLeftWidth","borderTopWidth","boxSizing","whiteSpace","wordWrap"];d.forEach(function(b){try{c.style[b]=a.css(b)}catch(d){u("html2canvas: Parse: Exception caught in renderFormValue: "+d.message)}});var e=a.parseBounds();c.style.position="absolute",c.style.left=e.left+"px",c.style.top=e.top+"px",c.textContent=a.getValue(),b.body.appendChild(c),this.paintText(new nb(c.firstChild,a)),b.body.removeChild(c)}},E.prototype.paintText=function(a){a.applyTextTransform();var b=a.node.data.split(!this.options.letterRendering||S(a)?/(\b| )/:""),c=a.parent.fontWeight(),d=a.parent.css("fontSize"),e=a.parent.css("fontFamily"),f=a.parent.parseTextShadows();this.renderer.font(a.parent.css("color"),a.parent.css("fontStyle"),a.parent.css("fontVariant"),c,d,e),f.length?this.renderer.fontShadow(f[0].color,f[0].offsetX,f[0].offsetY,f[0].blur):this.renderer.clearShadow(),b.map(this.parseTextBounds(a),this).forEach(function(c,f){c&&(this.renderer.text(b[f],c.left,c.bottom),this.renderTextDecoration(a.parent,c,this.fontMetrics.getMetrics(e,d)))},this)},E.prototype.renderTextDecoration=function(a,b,c){switch(a.css("textDecoration").split(" ")[0]){case"underline":this.renderer.rectangle(b.left,Math.round(b.top+c.baseline+c.lineWidth),b.width,1,a.css("color"));break;case"overline":this.renderer.rectangle(b.left,Math.round(b.top),b.width,1,a.css("color"));break;case"line-through":this.renderer.rectangle(b.left,Math.ceil(b.top+c.middle+c.lineWidth),b.width,1,a.css("color"))}},E.prototype.parseBorders=function(a){var b=a.bounds,c=T(a),d=["Top","Right","Bottom","Left"].map(function(b){return{width:a.cssInt("border"+b+"Width"),color:a.css("border"+b+"Color"),args:null} +}),e=I(b,c,d);return{clip:this.parseBackgroundClip(a,e,d,c,b),borders:d.map(function(a,f){if(a.width>0){var g=b.left,h=b.top,i=b.width,j=b.height-d[2].width;switch(f){case 0:j=d[0].width,a.args=K({c1:[g,h],c2:[g+i,h],c3:[g+i-d[1].width,h+j],c4:[g+d[3].width,h+j]},c[0],c[1],e.topLeftOuter,e.topLeftInner,e.topRightOuter,e.topRightInner);break;case 1:g=b.left+b.width-d[1].width,i=d[1].width,a.args=K({c1:[g+i,h],c2:[g+i,h+j+d[2].width],c3:[g,h+j],c4:[g,h+d[0].width]},c[1],c[2],e.topRightOuter,e.topRightInner,e.bottomRightOuter,e.bottomRightInner);break;case 2:h=h+b.height-d[2].width,j=d[2].width,a.args=K({c1:[g+i,h+j],c2:[g,h+j],c3:[g+d[3].width,h],c4:[g+i-d[3].width,h]},c[2],c[3],e.bottomRightOuter,e.bottomRightInner,e.bottomLeftOuter,e.bottomLeftInner);break;case 3:i=d[3].width,a.args=K({c1:[g,h+j+d[2].width],c2:[g,h],c3:[g+i,h+d[0].width],c4:[g+i,h+j]},c[3],c[0],e.bottomLeftOuter,e.bottomLeftInner,e.topLeftOuter,e.topLeftInner)}}return a})}},E.prototype.parseBackgroundClip=function(a,b,c,d,e){var f=a.css("backgroundClip"),g=[];switch(f){case"content-box":case"padding-box":L(g,d[0],d[1],b.topLeftInner,b.topRightInner,e.left+c[3].width,e.top+c[0].width),L(g,d[1],d[2],b.topRightInner,b.bottomRightInner,e.left+e.width-c[1].width,e.top+c[0].width),L(g,d[2],d[3],b.bottomRightInner,b.bottomLeftInner,e.left+e.width-c[1].width,e.top+e.height-c[2].width),L(g,d[3],d[0],b.bottomLeftInner,b.topLeftInner,e.left+c[3].width,e.top+e.height-c[2].width);break;default:L(g,d[0],d[1],b.topLeftOuter,b.topRightOuter,e.left,e.top),L(g,d[1],d[2],b.topRightOuter,b.bottomRightOuter,e.left+e.width,e.top),L(g,d[2],d[3],b.bottomRightOuter,b.bottomLeftOuter,e.left+e.width,e.top+e.height),L(g,d[3],d[0],b.bottomLeftOuter,b.topLeftOuter,e.left,e.top+e.height)}return g},E.prototype.pseudoHideClass="___html2canvas___pseudoelement";var rb=0;jb.prototype.renderImage=function(a,b,c,d){var e=a.cssInt("paddingLeft"),f=a.cssInt("paddingTop"),g=a.cssInt("paddingRight"),h=a.cssInt("paddingBottom"),i=c.borders;this.drawImage(d,0,0,d.width,d.height,b.left+e+i[3].width,b.top+f+i[0].width,b.width-(i[1].width+i[3].width+e+g),b.height-(i[0].width+i[2].width+f+h))},jb.prototype.renderBackground=function(a,b,c){b.height>0&&b.width>0&&(this.renderBackgroundColor(a,b),this.renderBackgroundImage(a,b,c))},jb.prototype.renderBackgroundColor=function(a,b){var c=a.css("backgroundColor");this.isTransparent(c)||this.rectangle(b.left,b.top,b.width,b.height,a.css("backgroundColor"))},jb.prototype.renderBorders=function(a){a.forEach(this.renderBorder,this)},jb.prototype.renderBorder=function(a){this.isTransparent(a.color)||null===a.args||this.drawShape(a.args,a.color)},jb.prototype.renderBackgroundImage=function(a,b,c){var d=a.parseBackgroundImages();d.reverse().forEach(function(d,e,f){switch(d.method){case"url":var g=this.images.get(d.args[0]);g?this.renderBackgroundRepeating(a,b,g,f.length-(e+1),c):u("Error loading background-image",d.args[0]);break;case"linear-gradient":case"gradient":var h=this.images.get(d.value);h?this.renderBackgroundGradient(h,b,c):u("Error loading background-image",d.args[0]);break;case"none":break;default:u("Unknown background-image type",d.args[0])}},this)},jb.prototype.renderBackgroundRepeating=function(a,b,c,d,e){var f=a.parseBackgroundSize(b,c.image,d),g=a.parseBackgroundPosition(b,c.image,d,f),h=a.parseBackgroundRepeat(d);switch(h){case"repeat-x":case"repeat no-repeat":this.backgroundRepeatShape(c,g,f,b,b.left+e[3],b.top+g.top+e[0],99999,c.image.height,e);break;case"repeat-y":case"no-repeat repeat":this.backgroundRepeatShape(c,g,f,b,b.left+g.left+e[3],b.top+e[0],c.image.width,99999,e);break;case"no-repeat":this.backgroundRepeatShape(c,g,f,b,b.left+g.left+e[3],b.top+g.top+e[0],c.image.width,c.image.height,e);break;default:this.renderBackgroundRepeat(c,g,f,{top:b.top,left:b.left},e[3],e[0])}},jb.prototype.isTransparent=function(a){return!a||"transparent"===a||"rgba(0, 0, 0, 0)"===a},kb.prototype=Object.create(jb.prototype),kb.prototype.setFillStyle=function(a){return this.ctx.fillStyle=a,this.ctx},kb.prototype.rectangle=function(a,b,c,d,e){this.setFillStyle(e).fillRect(a,b,c,d)},kb.prototype.drawShape=function(a,b){this.shape(a),this.setFillStyle(b).fill()},kb.prototype.drawImage=function(a,b,c,d,e,f,g,h,i){this.ctx.drawImage(a,b,c,d,e,f,g,h,i)},kb.prototype.clip=function(a,b,c){this.ctx.save(),this.shape(a).clip(),b.call(c),this.ctx.restore()},kb.prototype.shape=function(a){return this.ctx.beginPath(),a.forEach(function(a,b){this.ctx[0===b?"moveTo":a[0]+"To"].apply(this.ctx,a.slice(1))},this),this.ctx.closePath(),this.ctx},kb.prototype.font=function(a,b,c,d,e,f){this.setFillStyle(a).font=[b,c,d,e,f].join(" ")},kb.prototype.fontShadow=function(a,b,c,d){this.setVariable("shadowColor",a).setVariable("shadowOffsetY",b).setVariable("shadowOffsetX",c).setVariable("shadowBlur",d)},kb.prototype.clearShadow=function(){this.setVariable("shadowColor","rgba(0,0,0,0)")},kb.prototype.setOpacity=function(a){this.ctx.globalAlpha=a},kb.prototype.setTransform=function(a){this.ctx.translate(a.origin[0],a.origin[1]),this.ctx.transform.apply(this.ctx,a.matrix),this.ctx.translate(-a.origin[0],-a.origin[1])},kb.prototype.setVariable=function(a,b){return this.variables[a]!==b&&(this.variables[a]=this.ctx[a]=b),this},kb.prototype.text=function(a,b,c){this.ctx.fillText(a,b,c)},kb.prototype.backgroundRepeatShape=function(a,b,c,d,e,f,g,h,i){var j=[["line",Math.round(e),Math.round(f)],["line",Math.round(e+g),Math.round(f)],["line",Math.round(e+g),Math.round(h+f)],["line",Math.round(e),Math.round(h+f)]];this.clip(j,function(){this.renderBackgroundRepeat(a,b,c,d,i[3],i[0])},this)},kb.prototype.renderBackgroundRepeat=function(a,b,c,d,e,f){var g=Math.round(d.left+b.left+e),h=Math.round(d.top+b.top+f);this.setFillStyle(this.ctx.createPattern(this.resizeImage(a,c),"repeat")),this.ctx.translate(g,h),this.ctx.fill(),this.ctx.translate(-g,-h)},kb.prototype.renderBackgroundGradient=function(a,b){if(a instanceof t){var c=this.ctx.createLinearGradient(b.left+b.width*a.x0,b.top+b.height*a.y0,b.left+b.width*a.x1,b.top+b.height*a.y1);a.colorStops.forEach(function(a){c.addColorStop(a.stop,a.color)}),this.rectangle(b.left,b.top,b.width,b.height,c)}},kb.prototype.resizeImage=function(a,c){var d=a.image;if(d.width===c.width&&d.height===c.height)return d;var e,f=b.createElement("canvas");return f.width=c.width,f.height=c.height,e=f.getContext("2d"),e.drawImage(d,0,0,d.width,d.height,0,0,c.width,c.height),f},lb.prototype=Object.create(v.prototype),lb.prototype.getParentStack=function(a){var b=this.parent?this.parent.stack:null;return b?b.ownStacking?b:b.getParentStack(a):a.stack},mb.prototype.testRangeBounds=function(a){var b,c,d,e,f=!1;return a.createRange&&(b=a.createRange(),b.getBoundingClientRect&&(c=a.createElement("boundtest"),c.style.height="123px",c.style.display="block",a.body.appendChild(c),b.selectNode(c),d=b.getBoundingClientRect(),e=d.height,123===e&&(f=!0),a.body.removeChild(c))),f},mb.prototype.testCORS=function(){return"undefined"!=typeof(new Image).crossOrigin},nb.prototype=Object.create(v.prototype),nb.prototype.applyTextTransform=function(){this.node.data=this.transform(this.parent.css("textTransform"))},nb.prototype.transform=function(a){var b=this.node.data;switch(a){case"lowercase":return b.toLowerCase();case"capitalize":return b.replace(/(^|\s|:|-|\(|\))([a-z])/g,ob);case"uppercase":return b.toUpperCase();default:return b}},pb.prototype=Object.create(o.prototype)}(window,document); \ No newline at end of file diff --git a/examples/demo.html b/examples/demo.html index 41f2467..58bb90c 100644 --- a/examples/demo.html +++ b/examples/demo.html @@ -171,7 +171,7 @@

This is a nonsensical document, but syntactically valid HTML 4.0. All 100% conformant CSS1 agents should be able to render the document elements above this paragraph indistinguishably (to the pixel) from this reference rendering, (except font rasterization and form widgets). All discrepancies should be traceable to CSS1 implementation shortcomings. Once you have finished evaluating this test, you can return to the parent page.

- + +