mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
renamed html2canvas.log to h2clog (minifies better)
renamed the html2canvas.canvasContext to h2cRenderContext, it's used by both backends and thus not canvas specific
This commit is contained in:
parent
0b1fb0dac7
commit
683742bfbe
10
src/Core.js
10
src/Core.js
@ -10,11 +10,13 @@ var html2canvas = {};
|
|||||||
|
|
||||||
html2canvas.logging = false;
|
html2canvas.logging = false;
|
||||||
|
|
||||||
html2canvas.log = function (a) {
|
function h2clog(a) {
|
||||||
if (html2canvas.logging && window.console && window.console.log) {
|
if (html2canvas.logging && window.console && window.console.log) {
|
||||||
window.console.log(a);
|
window.console.log(a);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
html2canvas.log = h2clog; // for compatibility with the jquery plugin
|
||||||
|
|
||||||
html2canvas.Util = {};
|
html2canvas.Util = {};
|
||||||
|
|
||||||
@ -140,8 +142,8 @@ html2canvas.Util.Children = function(el) {
|
|||||||
try {
|
try {
|
||||||
children = $(el).contents();
|
children = $(el).contents();
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
html2canvas.log("html2canvas.Util.Children failed with exception: " + ex.message);
|
h2clog("html2canvas.Util.Children failed with exception: " + ex.message);
|
||||||
children = [];
|
children = [];
|
||||||
}
|
}
|
||||||
return children;
|
return children;
|
||||||
}
|
};
|
||||||
|
@ -108,7 +108,7 @@ html2canvas.Generate.Gradient = function(src, bounds) {
|
|||||||
lingrad.addColorStop(increment * i, steps[i]);
|
lingrad.addColorStop(increment * i, steps[i]);
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
html2canvas.log(['failed to add color stop: ', e, '; tried to add: ', steps[i], '; stop: ', i, '; in: ', src]);
|
h2clog(['failed to add color stop: ', e, '; tried to add: ', steps[i], '; stop: ', i, '; in: ', src]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1002,7 +1002,7 @@ html2canvas.Parse = function (element, images, opts) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
html2canvas.log("html2canvas: Error loading background:" + background_image);
|
h2clog("html2canvas: Error loading background:" + background_image);
|
||||||
//console.log(images);
|
//console.log(images);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1051,7 +1051,7 @@ html2canvas.Parse = function (element, images, opts) {
|
|||||||
|
|
||||||
|
|
||||||
stack = {
|
stack = {
|
||||||
ctx: html2canvas.canvasContext( docDim.width || w , docDim.height || h ),
|
ctx: h2cRenderContext( docDim.width || w , docDim.height || h ),
|
||||||
zIndex: zindex,
|
zIndex: zindex,
|
||||||
opacity: opacity * parentStack.opacity,
|
opacity: opacity * parentStack.opacity,
|
||||||
cssPosition: cssPosition
|
cssPosition: cssPosition
|
||||||
@ -1162,7 +1162,7 @@ html2canvas.Parse = function (element, images, opts) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
html2canvas.log("html2canvas: Error loading <img>:" + imgSrc);
|
h2clog("html2canvas: Error loading <img>:" + imgSrc);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "INPUT":
|
case "INPUT":
|
||||||
|
@ -45,7 +45,7 @@ html2canvas.Preload = function(element, opts){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function start(){
|
function start(){
|
||||||
html2canvas.log("html2canvas: start: images: " + images.numLoaded + " / " + images.numTotal + " (failed: " + images.numFailed + ")");
|
h2clog("html2canvas: start: images: " + images.numLoaded + " / " + images.numTotal + " (failed: " + images.numFailed + ")");
|
||||||
if (!images.firstRun && images.numLoaded >= images.numTotal){
|
if (!images.firstRun && images.numLoaded >= images.numTotal){
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -57,7 +57,7 @@ html2canvas.Preload = function(element, opts){
|
|||||||
options.complete(images);
|
options.complete(images);
|
||||||
}
|
}
|
||||||
|
|
||||||
html2canvas.log("Finished loading images: # " + images.numTotal + " (failed: " + images.numFailed + ")");
|
h2clog("Finished loading images: # " + images.numTotal + " (failed: " + images.numFailed + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ html2canvas.Preload = function(element, opts){
|
|||||||
elNodeType = el.nodeType;
|
elNodeType = el.nodeType;
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
elNodeType = false;
|
elNodeType = false;
|
||||||
html2canvas.log("html2canvas: failed to access some element's nodeType - Exception: " + ex.message);
|
h2clog("html2canvas: failed to access some element's nodeType - Exception: " + ex.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elNodeType === 1 || elNodeType === undefined){
|
if (elNodeType === 1 || elNodeType === undefined){
|
||||||
@ -256,9 +256,9 @@ html2canvas.Preload = function(element, opts){
|
|||||||
var img, src;
|
var img, src;
|
||||||
if (!images.cleanupDone) {
|
if (!images.cleanupDone) {
|
||||||
if (cause && typeof cause === "string") {
|
if (cause && typeof cause === "string") {
|
||||||
html2canvas.log("html2canvas: Cleanup because: " + cause);
|
h2clog("html2canvas: Cleanup because: " + cause);
|
||||||
} else {
|
} else {
|
||||||
html2canvas.log("html2canvas: Cleanup after timeout: " + options.timeout + " ms.");
|
h2clog("html2canvas: Cleanup after timeout: " + options.timeout + " ms.");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (src in images) {
|
for (src in images) {
|
||||||
@ -276,7 +276,7 @@ html2canvas.Preload = function(element, opts){
|
|||||||
}
|
}
|
||||||
images.numLoaded++;
|
images.numLoaded++;
|
||||||
images.numFailed++;
|
images.numFailed++;
|
||||||
html2canvas.log("html2canvas: Cleaned up failed img: '" + src + "' Steps: " + images.numLoaded + " / " + images.numTotal);
|
h2clog("html2canvas: Cleaned up failed img: '" + src + "' Steps: " + images.numLoaded + " / " + images.numTotal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -307,19 +307,19 @@ html2canvas.Preload = function(element, opts){
|
|||||||
if (options.timeout > 0) {
|
if (options.timeout > 0) {
|
||||||
timeoutTimer = window.setTimeout(methods.cleanupDOM, options.timeout);
|
timeoutTimer = window.setTimeout(methods.cleanupDOM, options.timeout);
|
||||||
}
|
}
|
||||||
html2canvas.log('html2canvas: Preload starts: finding background-images');
|
h2clog('html2canvas: Preload starts: finding background-images');
|
||||||
images.firstRun = true;
|
images.firstRun = true;
|
||||||
|
|
||||||
getImages( element );
|
getImages( element );
|
||||||
|
|
||||||
html2canvas.log('html2canvas: Preload: Finding images');
|
h2clog('html2canvas: Preload: Finding images');
|
||||||
// load <img> images
|
// load <img> images
|
||||||
for (i = 0; i < imgLen; i+=1){
|
for (i = 0; i < imgLen; i+=1){
|
||||||
methods.loadImage( domImages[i].getAttribute( "src" ) );
|
methods.loadImage( domImages[i].getAttribute( "src" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
images.firstRun = false;
|
images.firstRun = false;
|
||||||
html2canvas.log('html2canvas: Preload: Done.');
|
h2clog('html2canvas: Preload: Done.');
|
||||||
if ( images.numTotal === images.numLoaded ) {
|
if ( images.numTotal === images.numLoaded ) {
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
Released under MIT License
|
Released under MIT License
|
||||||
*/
|
*/
|
||||||
html2canvas.canvasContext = function (width, height) {
|
function h2cRenderContext(width, height) {
|
||||||
var storage = [];
|
var storage = [];
|
||||||
return {
|
return {
|
||||||
storage: storage,
|
storage: storage,
|
||||||
@ -40,4 +40,4 @@ html2canvas.canvasContext = function (width, height) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
@ -176,7 +176,7 @@ html2canvas.Renderer = function(parseQueue, opts){
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
html2canvas.log("html2canvas: Renderer: Canvas renderer done - returning canvas obj");
|
h2clog("html2canvas: Renderer: Canvas renderer done - returning canvas obj");
|
||||||
|
|
||||||
// this.canvasRenderStorage(queue,this.ctx);
|
// this.canvasRenderStorage(queue,this.ctx);
|
||||||
queueLen = options.elements.length;
|
queueLen = options.elements.length;
|
||||||
@ -390,7 +390,7 @@ html2canvas.Renderer = function(parseQueue, opts){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
html2canvas.log("html2canvas: Renderer: SVG Renderer done - returning SVG DOM obj");
|
h2clog("html2canvas: Renderer: SVG Renderer done - returning SVG DOM obj");
|
||||||
|
|
||||||
return svg;
|
return svg;
|
||||||
|
|
||||||
@ -405,11 +405,11 @@ html2canvas.Renderer = function(parseQueue, opts){
|
|||||||
case "canvas":
|
case "canvas":
|
||||||
canvas = doc.createElement('canvas');
|
canvas = doc.createElement('canvas');
|
||||||
if (canvas.getContext){
|
if (canvas.getContext){
|
||||||
html2canvas.log("html2canvas: Renderer: using canvas renderer");
|
h2clog("html2canvas: Renderer: using canvas renderer");
|
||||||
return canvasRenderer(parseQueue);
|
return canvasRenderer(parseQueue);
|
||||||
} else {
|
} else {
|
||||||
usingFlashcanvas = true;
|
usingFlashcanvas = true;
|
||||||
html2canvas.log("html2canvas: Renderer: canvas not available, using flashcanvas");
|
h2clog("html2canvas: Renderer: canvas not available, using flashcanvas");
|
||||||
var script = doc.createElement("script");
|
var script = doc.createElement("script");
|
||||||
script.src = options.flashcanvas;
|
script.src = options.flashcanvas;
|
||||||
|
|
||||||
@ -436,7 +436,7 @@ html2canvas.Renderer = function(parseQueue, opts){
|
|||||||
window.setTimeout( intervalFunc, 250 );
|
window.setTimeout( intervalFunc, 250 );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
html2canvas.log("html2canvas: Renderer: Can't track when flashcanvas is loaded");
|
h2clog("html2canvas: Renderer: Can't track when flashcanvas is loaded");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ html2canvas.Renderer = function(parseQueue, opts){
|
|||||||
})(script, function(){
|
})(script, function(){
|
||||||
|
|
||||||
if (typeof FlashCanvas !== "undefined") {
|
if (typeof FlashCanvas !== "undefined") {
|
||||||
html2canvas.log("html2canvas: Renderer: Flashcanvas initialized");
|
h2clog("html2canvas: Renderer: Flashcanvas initialized");
|
||||||
FlashCanvas.initElement( canvas );
|
FlashCanvas.initElement( canvas );
|
||||||
canvasRenderer(parseQueue);
|
canvasRenderer(parseQueue);
|
||||||
}
|
}
|
||||||
@ -460,7 +460,7 @@ html2canvas.Renderer = function(parseQueue, opts){
|
|||||||
break;
|
break;
|
||||||
case "svg":
|
case "svg":
|
||||||
if (doc.createElementNS){
|
if (doc.createElementNS){
|
||||||
html2canvas.log("html2canvas: Renderer: using SVG renderer");
|
h2clog("html2canvas: Renderer: using SVG renderer");
|
||||||
return svgRenderer(parseQueue);
|
return svgRenderer(parseQueue);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user