@microsoft/office-js
Version:
Office JavaScript APIs
1,479 lines (1,478 loc) • 111 kB
JavaScript
/*!
html2canvas <http://html2canvas.hertzen.com>
Copyright (c) 2016 Niklas von Hertzen
*/
/*! Copyright Mathias Bynens <https://mathiasbynens.be/> */
var PunyCode;
(function (PunyCode_1) {
var maxInt = 2147483647, base = 36, tMin = 1, tMax = 26, skew = 38, damp = 700, initialBias = 72, initialN = 128, delimiter = '-', regexPunycode = /^xn--/, regexNonASCII = /[^\x20-\x7E]/, regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, errors = {
'overflow': 'Overflow: input needs wider integers to process',
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
'invalid-input': 'Invalid input'
}, baseMinusTMin = base - tMin, floor = Math.floor, stringFromCharCode = String.fromCharCode, key;
function error(type) {
throw RangeError(errors[type]);
}
function map(array, fn) {
var length = array.length;
var result = [];
while (length--) {
result[length] = fn(array[length]);
}
return result;
}
function mapDomain(string, fn) {
var parts = string.split('@');
var result = '';
if (parts.length > 1) {
result = parts[0] + '@';
string = parts[1];
}
string = string.replace(regexSeparators, '\x2E');
var labels = string.split('.');
var encoded = map(labels, fn).join('.');
return result + encoded;
}
function ucs2decode(string) {
var output = [], counter = 0, length = string.length, value, extra;
while (counter < length) {
value = string.charCodeAt(counter++);
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
extra = string.charCodeAt(counter++);
if ((extra & 0xFC00) == 0xDC00) {
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
}
else {
output.push(value);
counter--;
}
}
else {
output.push(value);
}
}
return output;
}
function ucs2encode(array) {
return map(array, function (value) {
var output = '';
if (value > 0xFFFF) {
value -= 0x10000;
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
value = 0xDC00 | value & 0x3FF;
}
output += stringFromCharCode(value);
return output;
}).join('');
}
function basicToDigit(codePoint) {
if (codePoint - 48 < 10) {
return codePoint - 22;
}
if (codePoint - 65 < 26) {
return codePoint - 65;
}
if (codePoint - 97 < 26) {
return codePoint - 97;
}
return base;
}
function digitToBasic(digit, flag) {
return digit + 22 + 75 * (Number)(digit < 26) - ((Number)(flag != 0) << 5);
}
function adapt(delta, numPoints, firstTime) {
var k = 0;
delta = firstTime ? floor(delta / damp) : delta >> 1;
delta += floor(delta / numPoints);
for (; delta > baseMinusTMin * tMax >> 1; k += base) {
delta = floor(delta / baseMinusTMin);
}
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
}
function decode(input) {
var output = [], inputLength = input.length, out, i = 0, n = initialN, bias = initialBias, basic, j, index, oldi, w, k, digit, t, baseMinusT;
basic = input.lastIndexOf(delimiter);
if (basic < 0) {
basic = 0;
}
for (j = 0; j < basic; ++j) {
if (input.charCodeAt(j) >= 0x80) {
error('not-basic');
}
output.push(input.charCodeAt(j));
}
for (index = basic > 0 ? basic + 1 : 0; index < inputLength;) {
for (oldi = i, w = 1, k = base; ; k += base) {
if (index >= inputLength) {
error('invalid-input');
}
digit = basicToDigit(input.charCodeAt(index++));
if (digit >= base || digit > floor((maxInt - i) / w)) {
error('overflow');
}
i += digit * w;
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
if (digit < t) {
break;
}
baseMinusT = base - t;
if (w > floor(maxInt / baseMinusT)) {
error('overflow');
}
w *= baseMinusT;
}
out = output.length + 1;
bias = adapt(i - oldi, out, oldi == 0);
if (floor(i / out) > maxInt - n) {
error('overflow');
}
n += floor(i / out);
i %= out;
output.splice(i++, 0, n);
}
return ucs2encode(output);
}
function encode(input) {
var n, delta, handledCPCount, basicLength, bias, j, m, q, k, t, currentValue, output = [], inputLength, handledCPCountPlusOne, baseMinusT, qMinusT;
input = ucs2decode(input);
inputLength = input.length;
n = initialN;
delta = 0;
bias = initialBias;
for (j = 0; j < inputLength; ++j) {
currentValue = input[j];
if (currentValue < 0x80) {
output.push(stringFromCharCode(currentValue));
}
}
handledCPCount = basicLength = output.length;
if (basicLength) {
output.push(delimiter);
}
while (handledCPCount < inputLength) {
for (m = maxInt, j = 0; j < inputLength; ++j) {
currentValue = input[j];
if (currentValue >= n && currentValue < m) {
m = currentValue;
}
}
handledCPCountPlusOne = handledCPCount + 1;
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
error('overflow');
}
delta += (m - n) * handledCPCountPlusOne;
n = m;
for (j = 0; j < inputLength; ++j) {
currentValue = input[j];
if (currentValue < n && ++delta > maxInt) {
error('overflow');
}
if (currentValue == n) {
for (q = delta, k = base; ; k += base) {
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
if (q < t) {
break;
}
qMinusT = q - t;
baseMinusT = base - t;
output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
q = floor(qMinusT / baseMinusT);
}
output.push(stringFromCharCode(digitToBasic(q, 0)));
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
delta = 0;
++handledCPCount;
}
}
++delta;
++n;
}
return output.join('');
}
function toUnicode(input) {
return mapDomain(input, function (string) {
return regexPunycode.test(string)
? decode(string.slice(4).toLowerCase())
: string;
});
}
function toASCII(input) {
return mapDomain(input, function (string) {
return regexNonASCII.test(string)
? 'xn--' + encode(string)
: string;
});
}
PunyCode_1.PunyCode = {
'version': '1.3.2',
'ucs2': {
'decode': ucs2decode,
'encode': ucs2encode
},
'decode': decode,
'encode': encode,
'toASCII': toASCII,
'toUnicode': toUnicode
};
})(PunyCode || (PunyCode = {}));
var Html2canvas;
(function (Html2canvas) {
Html2canvas.Color = function (value) {
this.r = 0;
this.g = 0;
this.b = 0;
this.a = null;
var result = this.fromArray(value) ||
this.namedColor(value) ||
this.rgb(value) ||
this.rgba(value) ||
this.hex6(value) ||
this.hex3(value);
};
Html2canvas.Color.prototype.darken = function (amount) {
var a = 1 - amount;
return new Html2canvas.Color([
Math.round(this.r * a),
Math.round(this.g * a),
Math.round(this.b * a),
this.a
]);
};
Html2canvas.Color.prototype.isTransparent = function () {
return this.a === 0;
};
Html2canvas.Color.prototype.isBlack = function () {
return this.r === 0 && this.g === 0 && this.b === 0;
};
Html2canvas.Color.prototype.fromArray = function (array) {
if (Array.isArray(array)) {
this.r = Math.min(array[0], 255);
this.g = Math.min(array[1], 255);
this.b = Math.min(array[2], 255);
if (array.length > 3) {
this.a = array[3];
}
}
return (Array.isArray(array));
};
var _hex3 = /^#([a-f0-9]{3})$/i;
Html2canvas.Color.prototype.hex3 = function (value) {
var match = null;
if ((match = value.match(_hex3)) !== null) {
this.r = parseInt(match[1][0] + match[1][0], 16);
this.g = parseInt(match[1][1] + match[1][1], 16);
this.b = parseInt(match[1][2] + match[1][2], 16);
}
return match !== null;
};
var _hex6 = /^#([a-f0-9]{6})$/i;
Html2canvas.Color.prototype.hex6 = function (value) {
var match = null;
if ((match = value.match(_hex6)) !== null) {
this.r = parseInt(match[1].substring(0, 2), 16);
this.g = parseInt(match[1].substring(2, 4), 16);
this.b = parseInt(match[1].substring(4, 6), 16);
}
return match !== null;
};
var _rgb = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/;
Html2canvas.Color.prototype.rgb = function (value) {
var match = null;
if ((match = value.match(_rgb)) !== null) {
this.r = Number(match[1]);
this.g = Number(match[2]);
this.b = Number(match[3]);
}
return match !== null;
};
var _rgba = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d?\.?\d+)\s*\)$/;
Html2canvas.Color.prototype.rgba = function (value) {
var match = null;
if ((match = value.match(_rgba)) !== null) {
this.r = Number(match[1]);
this.g = Number(match[2]);
this.b = Number(match[3]);
this.a = Number(match[4]);
}
return match !== null;
};
Html2canvas.Color.prototype.toString = function () {
return this.a !== null && this.a !== 1 ?
"rgba(" + [this.r, this.g, this.b, this.a].join(",") + ")" :
"rgb(" + [this.r, this.g, this.b].join(",") + ")";
};
Html2canvas.Color.prototype.namedColor = function (value) {
value = value.toLowerCase();
var color = colors[value];
if (color) {
this.r = color[0];
this.g = color[1];
this.b = color[2];
}
else if (value === "transparent") {
this.r = this.g = this.b = this.a = 0;
return true;
}
return !!color;
};
Html2canvas.Color.prototype.isColor = true;
var colors = {
"aliceblue": [240, 248, 255],
"antiquewhite": [250, 235, 215],
"aqua": [0, 255, 255],
"aquamarine": [127, 255, 212],
"azure": [240, 255, 255],
"beige": [245, 245, 220],
"bisque": [255, 228, 196],
"black": [0, 0, 0],
"blanchedalmond": [255, 235, 205],
"blue": [0, 0, 255],
"blueviolet": [138, 43, 226],
"brown": [165, 42, 42],
"burlywood": [222, 184, 135],
"cadetblue": [95, 158, 160],
"chartreuse": [127, 255, 0],
"chocolate": [210, 105, 30],
"coral": [255, 127, 80],
"cornflowerblue": [100, 149, 237],
"cornsilk": [255, 248, 220],
"crimson": [220, 20, 60],
"cyan": [0, 255, 255],
"darkblue": [0, 0, 139],
"darkcyan": [0, 139, 139],
"darkgoldenrod": [184, 134, 11],
"darkgray": [169, 169, 169],
"darkgreen": [0, 100, 0],
"darkgrey": [169, 169, 169],
"darkkhaki": [189, 183, 107],
"darkmagenta": [139, 0, 139],
"darkolivegreen": [85, 107, 47],
"darkorange": [255, 140, 0],
"darkorchid": [153, 50, 204],
"darkred": [139, 0, 0],
"darksalmon": [233, 150, 122],
"darkseagreen": [143, 188, 143],
"darkslateblue": [72, 61, 139],
"darkslategray": [47, 79, 79],
"darkslategrey": [47, 79, 79],
"darkturquoise": [0, 206, 209],
"darkviolet": [148, 0, 211],
"deeppink": [255, 20, 147],
"deepskyblue": [0, 191, 255],
"dimgray": [105, 105, 105],
"dimgrey": [105, 105, 105],
"dodgerblue": [30, 144, 255],
"firebrick": [178, 34, 34],
"floralwhite": [255, 250, 240],
"forestgreen": [34, 139, 34],
"fuchsia": [255, 0, 255],
"gainsboro": [220, 220, 220],
"ghostwhite": [248, 248, 255],
"gold": [255, 215, 0],
"goldenrod": [218, 165, 32],
"gray": [128, 128, 128],
"green": [0, 128, 0],
"greenyellow": [173, 255, 47],
"grey": [128, 128, 128],
"honeydew": [240, 255, 240],
"hotpink": [255, 105, 180],
"indianred": [205, 92, 92],
"indigo": [75, 0, 130],
"ivory": [255, 255, 240],
"khaki": [240, 230, 140],
"lavender": [230, 230, 250],
"lavenderblush": [255, 240, 245],
"lawngreen": [124, 252, 0],
"lemonchiffon": [255, 250, 205],
"lightblue": [173, 216, 230],
"lightcoral": [240, 128, 128],
"lightcyan": [224, 255, 255],
"lightgoldenrodyellow": [250, 250, 210],
"lightgray": [211, 211, 211],
"lightgreen": [144, 238, 144],
"lightgrey": [211, 211, 211],
"lightpink": [255, 182, 193],
"lightsalmon": [255, 160, 122],
"lightseagreen": [32, 178, 170],
"lightskyblue": [135, 206, 250],
"lightslategray": [119, 136, 153],
"lightslategrey": [119, 136, 153],
"lightsteelblue": [176, 196, 222],
"lightyellow": [255, 255, 224],
"lime": [0, 255, 0],
"limegreen": [50, 205, 50],
"linen": [250, 240, 230],
"magenta": [255, 0, 255],
"maroon": [128, 0, 0],
"mediumaquamarine": [102, 205, 170],
"mediumblue": [0, 0, 205],
"mediumorchid": [186, 85, 211],
"mediumpurple": [147, 112, 219],
"mediumseagreen": [60, 179, 113],
"mediumslateblue": [123, 104, 238],
"mediumspringgreen": [0, 250, 154],
"mediumturquoise": [72, 209, 204],
"mediumvioletred": [199, 21, 133],
"midnightblue": [25, 25, 112],
"mintcream": [245, 255, 250],
"mistyrose": [255, 228, 225],
"moccasin": [255, 228, 181],
"navajowhite": [255, 222, 173],
"navy": [0, 0, 128],
"oldlace": [253, 245, 230],
"olive": [128, 128, 0],
"olivedrab": [107, 142, 35],
"orange": [255, 165, 0],
"orangered": [255, 69, 0],
"orchid": [218, 112, 214],
"palegoldenrod": [238, 232, 170],
"palegreen": [152, 251, 152],
"paleturquoise": [175, 238, 238],
"palevioletred": [219, 112, 147],
"papayawhip": [255, 239, 213],
"peachpuff": [255, 218, 185],
"peru": [205, 133, 63],
"pink": [255, 192, 203],
"plum": [221, 160, 221],
"powderblue": [176, 224, 230],
"purple": [128, 0, 128],
"rebeccapurple": [102, 51, 153],
"red": [255, 0, 0],
"rosybrown": [188, 143, 143],
"royalblue": [65, 105, 225],
"saddlebrown": [139, 69, 19],
"salmon": [250, 128, 114],
"sandybrown": [244, 164, 96],
"seagreen": [46, 139, 87],
"seashell": [255, 245, 238],
"sienna": [160, 82, 45],
"silver": [192, 192, 192],
"skyblue": [135, 206, 235],
"slateblue": [106, 90, 205],
"slategray": [112, 128, 144],
"slategrey": [112, 128, 144],
"snow": [255, 250, 250],
"springgreen": [0, 255, 127],
"steelblue": [70, 130, 180],
"tan": [210, 180, 140],
"teal": [0, 128, 128],
"thistle": [216, 191, 216],
"tomato": [255, 99, 71],
"turquoise": [64, 224, 208],
"violet": [238, 130, 238],
"wheat": [245, 222, 179],
"white": [255, 255, 255],
"whitesmoke": [245, 245, 245],
"yellow": [255, 255, 0],
"yellowgreen": [154, 205, 50]
};
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
Html2canvas.Log = function () {
if (Html2canvas.Log.options.logging && window.console && window.console.log) {
Function.prototype.bind.call(window.console.log, (window.console)).apply(window.console, [(Date.now() - Html2canvas.Log.options.start) + "ms", "html2canvas:"].concat([].slice.call(arguments, 0)));
}
};
Html2canvas.Log.options = { logging: false };
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
Html2canvas.Support = function (document) {
this.rangeBounds = this.testRangeBounds(document);
this.cors = this.testCORS();
this.svg = this.testSVG();
};
Html2canvas.Support.prototype.testRangeBounds = function (document) {
var range, testElement, rangeBounds, rangeHeight, support = false;
if (document.createRange) {
range = document.createRange();
if (range.getBoundingClientRect) {
testElement = document.createElement('boundtest');
testElement.style.height = "123px";
testElement.style.display = "block";
document.body.appendChild(testElement);
range.selectNode(testElement);
rangeBounds = range.getBoundingClientRect();
rangeHeight = rangeBounds.height;
if (rangeHeight === 123) {
support = true;
}
document.body.removeChild(testElement);
}
}
return support;
};
Html2canvas.Support.prototype.testCORS = function () {
return typeof ((new Image()).crossOrigin) !== "undefined";
};
Html2canvas.Support.prototype.testSVG = function () {
var img = new Image();
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
img.src = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";
try {
ctx.drawImage(img, 0, 0);
canvas.toDataURL();
}
catch (e) {
return false;
}
return true;
};
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
Html2canvas.Utils = {};
Html2canvas.Promise = (typeof (window.Promise) !== "undefined") ? window.Promise : OfficeExtension.Promise;
Html2canvas.Utils.smallImage = function () {
return "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
};
Html2canvas.Utils.bind = function (callback, context) {
return function () {
return callback.apply(context, arguments);
};
};
Html2canvas.Utils.decode64 = function (base64) {
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var len = base64.length, i, encoded1, encoded2, encoded3, encoded4, byte1, byte2, byte3;
var output = "";
for (i = 0; i < len; i += 4) {
encoded1 = chars.indexOf(base64[i]);
encoded2 = chars.indexOf(base64[i + 1]);
encoded3 = chars.indexOf(base64[i + 2]);
encoded4 = chars.indexOf(base64[i + 3]);
byte1 = (encoded1 << 2) | (encoded2 >> 4);
byte2 = ((encoded2 & 15) << 4) | (encoded3 >> 2);
byte3 = ((encoded3 & 3) << 6) | encoded4;
if (encoded3 === 64) {
output += String.fromCharCode(byte1);
}
else if (encoded4 === 64 || encoded4 === -1) {
output += String.fromCharCode(byte1, byte2);
}
else {
output += String.fromCharCode(byte1, byte2, byte3);
}
}
return output;
};
Html2canvas.Utils.getBounds = function (node) {
if (node.getBoundingClientRect) {
var clientRect = node.getBoundingClientRect();
var width = node.offsetWidth == null ? clientRect.width : node.offsetWidth;
return {
top: clientRect.top,
bottom: clientRect.bottom || (clientRect.top + clientRect.height),
right: clientRect.left + width,
left: clientRect.left,
width: width,
height: node.offsetHeight == null ? clientRect.height : node.offsetHeight
};
}
return {};
};
Html2canvas.Utils.offsetBounds = function (node) {
var parent = node.offsetParent ? Html2canvas.Utils.offsetBounds(node.offsetParent) : { top: 0, left: 0 };
return {
top: node.offsetTop + parent.top,
bottom: node.offsetTop + node.offsetHeight + parent.top,
right: node.offsetLeft + parent.left + node.offsetWidth,
left: node.offsetLeft + parent.left,
width: node.offsetWidth,
height: node.offsetHeight
};
};
Html2canvas.Utils.parseBackgrounds = function (backgroundImage) {
var whitespace = ' \r\n\t', method, definition, prefix, prefix_i, block, results = [], mode = 0, numParen = 0, quote, args;
var appendResult = function () {
if (method) {
if (definition.substr(0, 1) === '"') {
definition = definition.substr(1, definition.length - 2);
}
if (definition) {
args.push(definition);
}
if (method.substr(0, 1) === '-' && (prefix_i = method.indexOf('-', 1) + 1) > 0) {
prefix = method.substr(0, prefix_i);
method = method.substr(prefix_i);
}
results.push({
prefix: prefix,
method: method.toLowerCase(),
value: block,
args: args,
image: null
});
}
args = [];
method = prefix = definition = block = '';
};
args = [];
method = prefix = definition = block = '';
backgroundImage.split("").forEach(function (c) {
if (mode === 0 && whitespace.indexOf(c) > -1) {
return;
}
switch (c) {
case '"':
if (!quote) {
quote = c;
}
else if (quote === c) {
quote = null;
}
break;
case '(':
if (quote) {
break;
}
else if (mode === 0) {
mode = 1;
block += c;
return;
}
else {
numParen++;
}
break;
case ')':
if (quote) {
break;
}
else if (mode === 1) {
if (numParen === 0) {
mode = 0;
block += c;
appendResult();
return;
}
else {
numParen--;
}
}
break;
case ',':
if (quote) {
break;
}
else if (mode === 0) {
appendResult();
return;
}
else if (mode === 1) {
if (numParen === 0 && !method.match(/^url$/i)) {
args.push(definition);
definition = '';
block += c;
return;
}
}
break;
}
block += c;
if (mode === 0) {
method += c;
}
else {
definition += c;
}
});
appendResult();
return results;
};
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
Html2canvas.XHR = function (url) {
return new Html2canvas.Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onload = function () {
if (xhr.status === 200) {
resolve(xhr.responseText);
}
else {
reject(new Error(xhr.statusText));
}
};
xhr.onerror = function () {
reject(new Error("Network Error"));
};
xhr.send();
});
};
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
var log = Html2canvas.Log;
function restoreOwnerScroll(ownerDocument, x, y) {
if (ownerDocument.defaultView && (x !== ownerDocument.defaultView.pageXOffset || y !== ownerDocument.defaultView.pageYOffset)) {
ownerDocument.defaultView.scrollTo(x, y);
}
}
function cloneCanvasContents(canvas, clonedCanvas) {
try {
if (clonedCanvas) {
clonedCanvas.width = canvas.width;
clonedCanvas.height = canvas.height;
clonedCanvas.getContext("2d").putImageData(canvas.getContext("2d").getImageData(0, 0, canvas.width, canvas.height), 0, 0);
}
}
catch (e) {
log("Unable to copy canvas content from", canvas, e);
}
}
function cloneNode(node, javascriptEnabled) {
var clone = node.nodeType === 3 ? document.createTextNode(node.nodeValue) : node.cloneNode(false);
var child = node.firstChild;
while (child) {
if (javascriptEnabled === true || child.nodeType !== 1 || child.nodeName !== 'SCRIPT') {
clone.appendChild(cloneNode(child, javascriptEnabled));
}
child = child.nextSibling;
}
if (node.nodeType === 1) {
clone._scrollTop = node.scrollTop;
clone._scrollLeft = node.scrollLeft;
if (node.nodeName === "CANVAS") {
cloneCanvasContents(node, clone);
}
else if (node.nodeName === "TEXTAREA" || node.nodeName === "SELECT") {
clone.value = node.value;
}
}
return clone;
}
function initNode(node) {
if (node.nodeType === 1) {
node.scrollTop = node._scrollTop;
node.scrollLeft = node._scrollLeft;
var child = node.firstChild;
while (child) {
initNode(child);
child = child.nextSibling;
}
}
}
Html2canvas.CreateWindowClone = function (ownerDocument, containerDocument, width, height, options, x, y) {
var documentElement = cloneNode(ownerDocument.documentElement, options.javascriptEnabled);
var container = containerDocument.createElement("iframe");
container.className = "html2canvas-container";
container.style.visibility = "hidden";
container.style.position = "fixed";
container.style.left = "-10000px";
container.style.top = "0px";
container.style.border = "0";
container.width = width;
container.height = height;
container.scrolling = "no";
containerDocument.body.appendChild(container);
return new Html2canvas.Promise(function (resolve) {
var documentClone = container.contentWindow.document;
container.contentWindow.onload = container.onload = function () {
var interval = setInterval(function () {
if (documentClone.body.childNodes.length > 0) {
initNode(documentClone.documentElement);
clearInterval(interval);
if (options.type === "view") {
container.contentWindow.scrollTo(x, y);
if ((/(iPad|iPhone|iPod)/g).test(navigator.userAgent) && (container.contentWindow.scrollY !== y || container.contentWindow.scrollX !== x)) {
documentClone.documentElement.style.top = (-y) + "px";
documentClone.documentElement.style.left = (-x) + "px";
documentClone.documentElement.style.position = 'absolute';
}
}
resolve(container);
}
}, 50);
};
documentClone.open();
documentClone.write("<!DOCTYPE html><html></html>");
restoreOwnerScroll(ownerDocument, x, y);
documentClone.replaceChild(documentClone.adoptNode(documentElement), documentClone.documentElement);
documentClone.close();
});
};
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
var log = Html2canvas.Log;
var smallImage = Html2canvas.Utils.smallImage;
Html2canvas.DummyImageContainer = function (src) {
this.src = src;
log("DummyImageContainer for", src);
if (!this.promise || !this.image) {
log("Initiating DummyImageContainer");
Html2canvas.DummyImageContainer.prototype.image = new Image();
var image = this.image;
Html2canvas.DummyImageContainer.prototype.promise = new Html2canvas.Promise(function (resolve, reject) {
image.onload = resolve;
image.onerror = reject;
image.src = smallImage();
if (image.complete === true) {
resolve(image);
}
});
}
};
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
var smallImage = Html2canvas.Utils.smallImage;
Html2canvas.Font = function (family, size) {
var container = document.createElement('div'), img = document.createElement('img'), span = document.createElement('span'), sampleText = 'Hidden Text', baseline, middle;
container.style.visibility = "hidden";
container.style.fontFamily = family;
container.style.fontSize = size;
container.style.margin = '0';
container.style.padding = '0';
document.body.appendChild(container);
img.src = smallImage();
img.width = 1;
img.height = 1;
img.style.margin = '0';
img.style.padding = '0';
img.style.verticalAlign = "baseline";
span.style.fontFamily = family;
span.style.fontSize = size;
span.style.margin = '0';
span.style.padding = '0';
span.appendChild(document.createTextNode(sampleText));
container.appendChild(span);
container.appendChild(img);
baseline = (img.offsetTop - span.offsetTop) + 1;
container.removeChild(span);
container.appendChild(document.createTextNode(sampleText));
container.style.lineHeight = "normal";
img.style.verticalAlign = "super";
middle = (img.offsetTop - container.offsetTop) + 1;
document.body.removeChild(container);
this.baseline = baseline;
this.lineWidth = 1;
this.middle = middle;
};
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
var Font = Html2canvas.Font;
Html2canvas.FontMetrics = function () {
this.data = {};
};
Html2canvas.FontMetrics.prototype.getMetrics = function (family, size) {
if (this.data[family + "-" + size] === undefined) {
this.data[family + "-" + size] = new Font(family, size);
}
return this.data[family + "-" + size];
};
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
Html2canvas.GradientContainer = function (imageData) {
this.src = imageData.value;
this.colorStops = [];
this.type = null;
this.x0 = 0.5;
this.y0 = 0.5;
this.x1 = 0.5;
this.y1 = 0.5;
this.promise = Html2canvas.Promise.resolve(true);
};
Html2canvas.GradientContainer.TYPES = {
LINEAR: 1,
RADIAL: 2
};
Html2canvas.GradientContainer.REGEXP_COLORSTOP = /^\s*(rgba?\(\s*\d{1,3},\s*\d{1,3},\s*\d{1,3}(?:,\s*[0-9\.]+)?\s*\)|[a-z]{3,20}|#[a-f0-9]{3,6})(?:\s+(\d{1,3}(?:\.\d+)?)(%|px)?)?(?:\s|$)/i;
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
Html2canvas.ImageContainer = function (src, cors) {
this.src = src;
this.image = new Image();
var self = this;
this.tainted = null;
this.promise = new Html2canvas.Promise(function (resolve, reject) {
self.image.onload = resolve;
self.image.onerror = reject;
if (cors) {
self.image.crossOrigin = "anonymous";
}
self.image.src = src;
if (self.image.complete === true) {
resolve(self.image);
}
});
};
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
var GradientContainer = Html2canvas.GradientContainer;
var Color = Html2canvas.Color;
Html2canvas.LinearGradientContainer = function (imageData) {
GradientContainer.apply(this, arguments);
this.type = GradientContainer.TYPES.LINEAR;
var hasDirection = Html2canvas.LinearGradientContainer.REGEXP_DIRECTION.test(imageData.args[0]) ||
!GradientContainer.REGEXP_COLORSTOP.test(imageData.args[0]);
if (hasDirection) {
imageData.args[0].split(/\s+/).reverse().forEach(function (position, index) {
switch (position) {
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 y0 = this.y0;
var x0 = this.x0;
this.y0 = this.y1;
this.x0 = this.x1;
this.x1 = x0;
this.y1 = y0;
break;
case "center":
break;
default:
var ratio = parseFloat(position) * 1e-2;
if (isNaN(ratio)) {
break;
}
if (index === 0) {
this.y0 = ratio;
this.y1 = 1 - this.y0;
}
else {
this.x0 = ratio;
this.x1 = 1 - this.x0;
}
break;
}
}, this);
}
else {
this.y0 = 0;
this.y1 = 1;
}
this.colorStops = imageData.args.slice(hasDirection ? 1 : 0).map(function (colorStop) {
var colorStopMatch = colorStop.match(GradientContainer.REGEXP_COLORSTOP);
var value = +colorStopMatch[2];
var unit = value === 0 ? "%" : colorStopMatch[3];
return {
color: new Color(colorStopMatch[1]),
stop: unit === "%" ? value / 100 : null
};
});
if (this.colorStops[0].stop === null) {
this.colorStops[0].stop = 0;
}
if (this.colorStops[this.colorStops.length - 1].stop === null) {
this.colorStops[this.colorStops.length - 1].stop = 1;
}
this.colorStops.forEach(function (colorStop, index) {
if (colorStop.stop === null) {
this.colorStops.slice(index).some(function (find, count) {
if (find.stop !== null) {
colorStop.stop = ((find.stop - this.colorStops[index - 1].stop) / (count + 1)) + this.colorStops[index - 1].stop;
return true;
}
else {
return false;
}
}, this);
}
}, this);
};
Html2canvas.LinearGradientContainer.prototype = Object.create(GradientContainer.prototype);
Html2canvas.LinearGradientContainer.REGEXP_DIRECTION = /^\s*(?:to|left|right|top|bottom|center|\d{1,3}(?:\.\d+)?%?)(?:\s|$)/i;
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
var Color = Html2canvas.Color;
var utils = Html2canvas.Utils;
var getBounds = utils.getBounds;
var parseBackgrounds = utils.parseBackgrounds;
var offsetBounds = utils.offsetBounds;
Html2canvas.NodeContainer = function (node, parent) {
this.node = node;
this.parent = parent;
this.stack = null;
this.bounds = null;
this.borders = null;
this.clip = [];
this.backgroundClip = [];
this.offsetBounds = null;
this.visible = null;
this.computedStyles = null;
this.colors = {};
this.styles = {};
this.backgroundImages = null;
this.transformData = null;
this.transformMatrix = null;
this.isPseudoElement = false;
this.opacity = null;
};
Html2canvas.NodeContainer.prototype.cloneTo = function (stack) {
stack.visible = this.visible;
stack.borders = this.borders;
stack.bounds = this.bounds;
stack.clip = this.clip;
stack.backgroundClip = this.backgroundClip;
stack.computedStyles = this.computedStyles;
stack.styles = this.styles;
stack.backgroundImages = this.backgroundImages;
stack.opacity = this.opacity;
};
Html2canvas.NodeContainer.prototype.getOpacity = function () {
return this.opacity === null ? (this.opacity = this.cssFloat('opacity')) : this.opacity;
};
Html2canvas.NodeContainer.prototype.assignStack = function (stack) {
this.stack = stack;
stack.children.push(this);
};
Html2canvas.NodeContainer.prototype.isElementVisible = function () {
return this.node.nodeType === Node.TEXT_NODE ? this.parent.visible : (this.css('display') !== "none" &&
this.css('visibility') !== "hidden" &&
!this.node.hasAttribute("data-html2canvas-ignore") &&
(this.node.nodeName !== "INPUT" || this.node.getAttribute("type") !== "hidden"));
};
Html2canvas.NodeContainer.prototype.css = function (attribute) {
if (!this.computedStyles) {
this.computedStyles = this.isPseudoElement ? this.parent.computedStyle(this.before ? ":before" : ":after") : this.computedStyle(null);
}
return this.styles[attribute] || (this.styles[attribute] = this.computedStyles[attribute]);
};
Html2canvas.NodeContainer.prototype.prefixedCss = function (attribute) {
var prefixes = ["webkit", "moz", "ms", "o"];
var value = this.css(attribute);
if (value === undefined) {
prefixes.some(function (prefix) {
value = this.css(prefix + attribute.substr(0, 1).toUpperCase() + attribute.substr(1));
return value !== undefined;
}, this);
}
return value === undefined ? null : value;
};
Html2canvas.NodeContainer.prototype.computedStyle = function (type) {
return this.node.ownerDocument.defaultView.getComputedStyle(this.node, type);
};
Html2canvas.NodeContainer.prototype.cssInt = function (attribute) {
var value = parseInt(this.css(attribute), 10);
return (isNaN(value)) ? 0 : value;
};
Html2canvas.NodeContainer.prototype.color = function (attribute) {
return this.colors[attribute] || (this.colors[attribute] = new Color(this.css(attribute)));
};
Html2canvas.NodeContainer.prototype.cssFloat = function (attribute) {
var value = parseFloat(this.css(attribute));
return (isNaN(value)) ? 0 : value;
};
Html2canvas.NodeContainer.prototype.fontWeight = function () {
var weight = this.css("fontWeight");
switch (parseInt(weight, 10)) {
case 401:
weight = "bold";
break;
case 400:
weight = "normal";
break;
}
return weight;
};
Html2canvas.NodeContainer.prototype.parseClip = function () {
var matches = this.css('clip').match(this.CLIP);
if (matches) {
return {
top: parseInt(matches[1], 10),
right: parseInt(matches[2], 10),
bottom: parseInt(matches[3], 10),
left: parseInt(matches[4], 10)
};
}
return null;
};
Html2canvas.NodeContainer.prototype.parseBackgroundImages = function () {
return this.backgroundImages || (this.backgroundImages = parseBackgrounds(this.css("backgroundImage")));
};
Html2canvas.NodeContainer.prototype.cssList = function (property, index) {
var value = (this.css(property) || '').split(',');
value = value[index || 0] || value[0] || 'auto';
value = value.trim().split(' ');
if (value.length === 1) {
value = [value[0], isPercentage(value[0]) ? 'auto' : value[0]];
}
return value;
};
Html2canvas.NodeContainer.prototype.parseBackgroundSize = function (bounds, image, index) {
var size = this.cssList("backgroundSize", index);
var width, height;
if (isPercentage(size[0])) {
width = bounds.width * parseFloat(size[0]) / 100;
}
else if (/contain|cover/.test(size[0])) {
var targetRatio = bounds.width / bounds.height, currentRatio = image.width / image.height;
return ((Number)(targetRatio < currentRatio) ^ (Number)(size[0] === 'contain')) ?
{ width: bounds.height * currentRatio, height: bounds.height } :
{ width: bounds.width, height: bounds.width / currentRatio };
}
else {
width = parseInt(size[0], 10);
}
if (size[0] === 'auto' && size[1] === 'auto') {
height = image.height;
}
else if (size[1] === 'auto') {
height = width / image.width * image.height;
}
else if (isPercentage(size[1])) {
height = bounds.height * parseFloat(size[1]) / 100;
}
else {
height = parseInt(size[1], 10);
}
if (size[0] === 'auto') {
width = height / image.height * image.width;
}
return { width: width, height: height };
};
Html2canvas.NodeContainer.prototype.parseBackgroundPosition = function (bounds, image, index, backgroundSize) {
var position = this.cssList('backgroundPosition', index);
var left, top;
if (isPercentage(position[0])) {
left = (bounds.width - (backgroundSize || image).width) * (parseFloat(position[0]) / 100);
}
else {
left = parseInt(position[0], 10);
}
if (position[1] === 'auto') {
top = left / image.width * image.height;
}
else if (isPercentage(position[1])) {
top = (bounds.height - (backgroundSize || image).height) * parseFloat(position[1]) / 100;
}
else {
top = parseInt(position[1], 10);
}
if (position[0] === 'auto') {
left = top / image.height * image.width;
}
return { left: left, top: top };
};
Html2canvas.NodeContainer.prototype.parseBackgroundRepeat = function (index) {
return this.cssList("backgroundRepeat", index)[0];
};
Html2canvas.NodeContainer.prototype.parseTextShadows = function () {
var textShadow = this.css("textShadow");
var results = [];
if (textShadow && textShadow !== 'none') {
var shadows = textShadow.match(this.TEXT_SHADOW_PROPERTY);
for (var i = 0; shadows && (i < shadows.length) ; i++) {
var s = shadows[i].match(this.TEXT_SHADOW_VALUES);
results.push({
color: new Color(s[0]),
offsetX: s[1] ? parseFloat(s[1].replace('px', '')) : 0,
offsetY: s[2] ? parseFloat(s[2].replace('px', '')) : 0,
blur: s[3] ? s[3].replace('px', '') : 0
});
}
}
return results;
};
Html2canvas.NodeContainer.prototype.parseTransform = function () {
if (!this.transformData) {
if (this.hasTransform()) {
var offset = this.parseBounds();
var origin = this.prefixedCss("transformOrigin").split(" ").map(removePx).map(asFloat);
origin[0] += offset.left;
origin[1] += offset.top;
this.transformData = {
origin: origin,
matrix: this.parseTransformMatrix()
};
}
else {
this.transformData = {
origin: [0, 0],
matrix: [1, 0, 0, 1, 0, 0]
};
}
}
return this.transformData;
};
Html2canvas.NodeContainer.prototype.parseTransformMatrix = function () {
if (!this.transformMatrix) {
var transform = this.prefixedCss("transform");
var matrix = transform ? parseMatrix(transform.match(this.MATRIX_PROPERTY)) : null;
this.transformMatrix = matrix ? matrix : [1, 0, 0, 1, 0, 0];
}
return this.transformMatrix;
};
Html2canvas.NodeContainer.prototype.parseBounds = function () {
return this.bounds || (this.bounds = this.hasTransform() ? offsetBounds(this.node) : getBounds(this.node));
};
Html2canvas.NodeContainer.prototype.hasTransform = function () {
return this.parseTransformMatrix().join(",") !== "1,0,0,1,0,0" || (this.parent && this.parent.hasTransform());
};
Html2canvas.NodeContainer.prototype.getValue = function () {
var value = this.node.value || "";
if (this.node.tagName === "SELECT") {
value = selectionValue(this.node);
}
else if (this.node.type === "password") {
value = Array(value.length + 1).join('\u2022');
}
return value.length === 0 ? (this.node.placeholder || "") : value;
};
Html2canvas.NodeContainer.prototype.MATRIX_PROPERTY = /(matrix|matrix3d)\((.+)\)/;
Html2canvas.NodeContainer.prototype.TEXT_SHADOW_PROPERTY = /((rgba|rgb)\([^\)]+\)(\s-?\d+px){0,})/g;
Html2canvas.NodeContainer.prototype.TEXT_SHADOW_VALUES = /(-?\d+px)|(#.+)|(rgb\(.+\))|(rgba\(.+\))/g;
Html2canvas.NodeContainer.prototype.CLIP = /^rect\((\d+)px,? (\d+)px,? (\d+)px,? (\d+)px\)$/;
function selectionValue(node) {
var option = node.options[node.selectedIndex || 0];
return option ? (option.text || "") : "";
}
function parseMatrix(match) {
if (match && match[1] === "matrix") {
return match[2].split(",").map(function (s) {
return parseFloat(s.trim());
});
}
else if (match && match[1] === "matrix3d") {
var matrix3d = match[2].split(",").map(function (s) {
return parseFloat(s.trim());
});
return [matrix3d[0], matrix3d[1], matrix3d[4], matrix3d[5], matrix3d[12], matrix3d[13]];
}
}
function isPercentage(value) {
return value.toString().indexOf("%") !== -1;
}
function removePx(str) {
return str.replace("px", "");
}
function asFloat(str) {
return parseFloat(str);
}
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
var XHR = Html2canvas.XHR;
var utils = Html2canvas.Utils;
var log = Html2canvas.Log;
var createWindowClone = Html2canvas.CreateWindowClone;
var decode64 = utils.decode64;
Html2canvas.Proxy = function (src, proxyUrl, document) {
var supportsCORS = ('withCredentials' in new XMLHttpRequest());
if (!proxyUrl) {
return Html2canvas.Promise.reject("No proxy configured");
}
var callback = createCallback(supportsCORS);
var url = createProxyUrl(proxyUrl, src, callback);
return supportsCORS ? XHR(url) : (jsonp(document, url, callback).then(function (response) {
return decode64(response.content);
}));
};
var proxyCount = 0;
Html2canvas.ProxyURL = function (src, proxyUrl, document) {
var supportsCORSImage = ('crossOrigin' in new Image());
var callback = createCallback(supportsCORSImage);
var url = createProxyUrl(proxyUrl, src, callback);
return (supportsCORSImage ? Html2canvas.Promise.resolve(url) : jsonp(document, url, callback).then(function (response) {
return "data:" + response.type + ";base64," + response.content;
}));
};
function jsonp(document, url, callback) {
return new Html2canvas.Promise(function (resolve, reject) {
var s = document.createElement("script");
var cleanup = function () {
delete window.html2canvas.proxy[callback];
document.body.removeChild(s);
};
window.html2canvas.proxy[callback] = function (response) {
cleanup();
resolve(response);
};
s.src = url;
s.onerror = function (e) {
cleanup();
reject(e);
};
document.body.appendChild(s);
});
}
function createCallback(useCORS) {
return !useCORS ? "html2canvas_" + Date.now() + "_" + (++proxyCount) + "_" + Math.round(Math.random() * 100000) : "";
}
function createProxyUrl(proxyUrl, src, callback) {
return proxyUrl + "?url=" + encodeURIComponent(src) + (callback.length ? "&callback=html2canvas.proxy." + callback : "");
}
function documentFromHTML(src) {
return function (html) {
var parser = new DOMParser(), doc;
try {
doc = parser.parseFromString(html, "text/html");
}
catch (e) {
log("DOMParser not supported, falling back to createHTMLDocument");
doc = document.implementation.createHTMLDocument("");
try {
doc.open();
doc.write(html);
doc.close();
}
catch (ee) {
log("createHTMLDocument write not supported, falling back to document.body.innerHTML");
doc.body.innerHTML = html;
}
}
var b = doc.querySelector("base");
if (!b || !b.href.host) {
var base = doc.createElement("base");
base.href = src;
doc.head.insertBefore(base, doc.head.firstChild);
}
return doc;
};
}
Html2canvas.loadUrlDocument = function (src, proxy, document, width, height, options) {
return new Html2canvas.Proxy(src, proxy, window.document).then(documentFromHTML(src)).then(function (doc) {
return createWindowClone(doc, document, width, height, options, 0, 0);
});
};
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
var ProxyURL = Html2canvas.ProxyURL;
Html2canvas.ProxyImageContainer = function (src, proxy) {
var link = document.createElement("a");
link.href = src;
src = link.href;
this.src = src;
this.image = new Image();
var self = this;
this.promise = new Html2canvas.Promise(function (resolve, reject) {
self.image.crossOrigin = "Anonymous";
self.image.onload = resolve;
self.image.onerror = reject;
new ProxyURL(src, proxy, document).then(function (url) {
self.image.src = url;
})['catch'](reject);
});
};
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
var NodeContainer = Html2canvas.NodeContainer;
Html2canvas.PseudoElementContainer = function (node, parent, type) {
NodeContainer.call(this, node, parent);
this.isPseudoElement = true;
this.before = type === ":before";
};
Html2canvas.PseudoElementContainer.prototype.cloneTo = function (stack) {
Html2canvas.PseudoElementContainer.prototype.cloneTo.call(this, stack);
stack.isPseudoElement = true;
stack.before = this.before;
};
Html2canvas.PseudoElementContainer.prototype = Object.create(NodeContainer.prototype);
Html2canvas.PseudoElementContainer.prototype.appendToDOM = function () {
if (this.before) {
this.parent.node.insertBefore(this.node, this.parent.node.firstChild);
}
else {
this.parent.node.appendChild(this.node);
}
this.parent.node.className += " " + this.getHideClass();
};
Html2canvas.PseudoElementContainer.prototype.cleanDOM = function () {
this.node.parentNode.removeChild(this.node);
this.parent.node.className = this.parent.node.className.replace(this.getHideClass(), "");
};
Html2canvas.PseudoElementContainer.prototype.getHideClass = function () {
return this["PSEUDO_HIDE_ELEMENT_CLASS_" + (this.before ? "BEFORE" : "AFTER")];
};
Html2canvas.PseudoElementContainer.prototype.PSEUDO_HIDE_ELEMENT_CLASS_BEFORE = "___html2canvas___pseudoelement_before";
Html2canvas.PseudoElementContainer.prototype.PSEUDO_HIDE_ELEMENT_CLASS_AFTER = "___html2canvas___pseudoelement_after";
})(Html2canvas || (Html2canvas = {}));
var Html2canvas;
(function (Html2canvas) {
var log = Html2canvas.Log;
Html2canvas.Renderer = function (width, height, images, options, document) {
this.width = width;
this.height = height;
this.images = images;
this.options = options;
this.document = document;
};
Html2canvas.Renderer.prototype.renderImage = function (container, bounds, borderData, imageContainer) {
var paddingLeft = container.cssInt('paddingLeft'), paddingTop = container.cssInt('paddingTop'), paddingRight = container.cssInt('paddingRight'), paddingBottom = container.cssInt('paddingBottom'), borders = borderData.borders;
var width = bounds.width - (borders[1].width + borders[3].width + paddingLeft + paddingRight);
var height = bounds.height - (borders[0].width + borders[2].width + paddingTop + paddingBottom);
this.drawImage(imageContainer, 0, 0, imageContainer.image.width || width, imageContainer.image.height || height, bounds.left + paddingLeft + borders[3].width, bounds.top + paddingTop + borders[0].width, width, height);
};
Html2canvas.Renderer.prototype.renderBackground = function (container, bounds, borderData) {
if (bounds.height > 0 && bounds.width > 0) {
this.renderBackgroundColor(container, bounds);
this.renderBackgroundImage(container, bounds, borderData);
}
};
Html2canvas.Renderer.prototype.renderBackgroundColor = function (container, bounds) {
var color = container.color("backgroundColor");
if (!color.isTransparent()) {
this.rectangle(bounds.left, bounds.top, bounds.width, bounds.height, color);
}
};
Html2canvas.Renderer.prototype.renderBorders = function (borders) {
borders.forEach(this.renderBorder, this);
};
Html2canvas.Renderer.prototype.renderBorder = function (data) {
if (!data.color.isTransparent() && data.args !== null) {
this.drawShape(data.args, data.color);
}
};
Html2canvas.Renderer.prototype.renderBackgroundImage = function (container, bounds, borderData) {
var backgroundImages = container.parseBackgroundImages();
backgroundImages.reverse().forEach(function (backgroundImage, index, arr) {
switch (backgroundImage.method) {
case "url":
var image = this.images.get(backgroundImage.args[0]);
if (image) {
this.renderBackgroundRepeating(container, bounds, image, arr.length - (index + 1), borderData);
}
else {
log("Error loading background-image", backgroundImage.args[0]);
}
break;
case "linear-gradient":
case "gradient":
var gradientImage = this.images.get(backgroundImage.value);
if (gradientImage) {
this.renderBackgroundGradient(gradientImage, bounds, borderData);
}
else {
log("Error loading background-image", backgroundImage.args[0]);
}
break;
case "none":
break;
default:
log("Unknown background-image type", backgroundImage.args[0]);
}
}, this);
};
Html2canvas.Renderer.prototype.renderBackgroundRepeating = function (container, bounds, imageContainer, index, borderData) {
var size = container.parseBackgroundSize(bounds, imageContainer.image, index);
var position = container.parseBackgroundPosition(bounds, imageContainer.image, index, size);
var repeat = container.parseBackgroundRepeat(index);
switch (repeat) {
case "repeat-x":
case "repeat no-repeat":
this.backgroundRepeatShape(imageContainer, position, size, bounds, b