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:
Obexer Christoph 2012-02-25 19:58:04 +01:00
parent b82be022b2
commit c24223ca85
6 changed files with 28 additions and 26 deletions

View File

@ -10,11 +10,13 @@ var html2canvas = {};
html2canvas.logging = false;
html2canvas.log = function (a) {
function h2clog(a) {
if (html2canvas.logging && window.console && window.console.log) {
window.console.log(a);
}
};
}
html2canvas.log = h2clog; // for compatibility with the jquery plugin
html2canvas.Util = {};
@ -140,8 +142,8 @@ html2canvas.Util.Children = function(el) {
try {
children = $(el).contents();
} catch (ex) {
html2canvas.log("html2canvas.Util.Children failed with exception: " + ex.message);
h2clog("html2canvas.Util.Children failed with exception: " + ex.message);
children = [];
}
return children;
}
};

View File

@ -108,7 +108,7 @@ html2canvas.Generate.Gradient = function(src, bounds) {
lingrad.addColorStop(increment * i, steps[i]);
}
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]);
}
}

View File

@ -1002,7 +1002,7 @@ html2canvas.Parse = function (element, images, opts) {
}
}else{
html2canvas.log("html2canvas: Error loading background:" + background_image);
h2clog("html2canvas: Error loading background:" + background_image);
//console.log(images);
}
@ -1051,7 +1051,7 @@ html2canvas.Parse = function (element, images, opts) {
stack = {
ctx: html2canvas.canvasContext( docDim.width || w , docDim.height || h ),
ctx: h2cRenderContext( docDim.width || w , docDim.height || h ),
zIndex: zindex,
opacity: opacity * parentStack.opacity,
cssPosition: cssPosition
@ -1162,7 +1162,7 @@ html2canvas.Parse = function (element, images, opts) {
);
}else{
html2canvas.log("html2canvas: Error loading <img>:" + imgSrc);
h2clog("html2canvas: Error loading <img>:" + imgSrc);
}
break;
case "INPUT":

View File

@ -45,7 +45,7 @@ html2canvas.Preload = function(element, opts){
}
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){
/*
@ -57,7 +57,7 @@ html2canvas.Preload = function(element, opts){
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;
} catch (ex) {
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){
@ -256,9 +256,9 @@ html2canvas.Preload = function(element, opts){
var img, src;
if (!images.cleanupDone) {
if (cause && typeof cause === "string") {
html2canvas.log("html2canvas: Cleanup because: " + cause);
h2clog("html2canvas: Cleanup because: " + cause);
} else {
html2canvas.log("html2canvas: Cleanup after timeout: " + options.timeout + " ms.");
h2clog("html2canvas: Cleanup after timeout: " + options.timeout + " ms.");
}
for (src in images) {
@ -276,7 +276,7 @@ html2canvas.Preload = function(element, opts){
}
images.numLoaded++;
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) {
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;
getImages( element );
html2canvas.log('html2canvas: Preload: Finding images');
h2clog('html2canvas: Preload: Finding images');
// load <img> images
for (i = 0; i < imgLen; i+=1){
methods.loadImage( domImages[i].getAttribute( "src" ) );
}
images.firstRun = false;
html2canvas.log('html2canvas: Preload: Done.');
h2clog('html2canvas: Preload: Done.');
if ( images.numTotal === images.numLoaded ) {
start();
}

View File

@ -5,7 +5,7 @@
Released under MIT License
*/
html2canvas.canvasContext = function (width, height) {
function h2cRenderContext(width, height) {
var storage = [];
return {
storage: storage,
@ -40,4 +40,4 @@ html2canvas.canvasContext = function (width, height) {
});
}
};
};
}

View File

@ -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);
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;
@ -405,11 +405,11 @@ html2canvas.Renderer = function(parseQueue, opts){
case "canvas":
canvas = doc.createElement('canvas');
if (canvas.getContext){
html2canvas.log("html2canvas: Renderer: using canvas renderer");
h2clog("html2canvas: Renderer: using canvas renderer");
return canvasRenderer(parseQueue);
} else {
usingFlashcanvas = true;
html2canvas.log("html2canvas: Renderer: canvas not available, using flashcanvas");
h2clog("html2canvas: Renderer: canvas not available, using flashcanvas");
var script = doc.createElement("script");
script.src = options.flashcanvas;
@ -436,7 +436,7 @@ html2canvas.Renderer = function(parseQueue, opts){
window.setTimeout( intervalFunc, 250 );
} 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(){
if (typeof FlashCanvas !== "undefined") {
html2canvas.log("html2canvas: Renderer: Flashcanvas initialized");
h2clog("html2canvas: Renderer: Flashcanvas initialized");
FlashCanvas.initElement( canvas );
canvasRenderer(parseQueue);
}
@ -460,7 +460,7 @@ html2canvas.Renderer = function(parseQueue, opts){
break;
case "svg":
if (doc.createElementNS){
html2canvas.log("html2canvas: Renderer: using SVG renderer");
h2clog("html2canvas: Renderer: using SVG renderer");
return svgRenderer(parseQueue);
}
break;