Skip to content

Commit c24223c

Browse files
committed
renamed html2canvas.log to h2clog (minifies better)
renamed the html2canvas.canvasContext to h2cRenderContext, it's used by both backends and thus not canvas specific
1 parent b82be02 commit c24223c

6 files changed

Lines changed: 28 additions & 26 deletions

File tree

src/Core.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ var html2canvas = {};
1010

1111
html2canvas.logging = false;
1212

13-
html2canvas.log = function (a) {
13+
function h2clog(a) {
1414
if (html2canvas.logging && window.console && window.console.log) {
1515
window.console.log(a);
1616
}
17-
};
17+
}
18+
19+
html2canvas.log = h2clog; // for compatibility with the jquery plugin
1820

1921
html2canvas.Util = {};
2022

@@ -140,8 +142,8 @@ html2canvas.Util.Children = function(el) {
140142
try {
141143
children = $(el).contents();
142144
} catch (ex) {
143-
html2canvas.log("html2canvas.Util.Children failed with exception: " + ex.message);
145+
h2clog("html2canvas.Util.Children failed with exception: " + ex.message);
144146
children = [];
145147
}
146148
return children;
147-
}
149+
};

src/Generate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ html2canvas.Generate.Gradient = function(src, bounds) {
108108
lingrad.addColorStop(increment * i, steps[i]);
109109
}
110110
catch(e) {
111-
html2canvas.log(['failed to add color stop: ', e, '; tried to add: ', steps[i], '; stop: ', i, '; in: ', src]);
111+
h2clog(['failed to add color stop: ', e, '; tried to add: ', steps[i], '; stop: ', i, '; in: ', src]);
112112
}
113113
}
114114

src/Parse.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ html2canvas.Parse = function (element, images, opts) {
10021002

10031003
}
10041004
}else{
1005-
html2canvas.log("html2canvas: Error loading background:" + background_image);
1005+
h2clog("html2canvas: Error loading background:" + background_image);
10061006
//console.log(images);
10071007
}
10081008

@@ -1051,7 +1051,7 @@ html2canvas.Parse = function (element, images, opts) {
10511051

10521052

10531053
stack = {
1054-
ctx: html2canvas.canvasContext( docDim.width || w , docDim.height || h ),
1054+
ctx: h2cRenderContext( docDim.width || w , docDim.height || h ),
10551055
zIndex: zindex,
10561056
opacity: opacity * parentStack.opacity,
10571057
cssPosition: cssPosition
@@ -1162,7 +1162,7 @@ html2canvas.Parse = function (element, images, opts) {
11621162
);
11631163

11641164
}else{
1165-
html2canvas.log("html2canvas: Error loading <img>:" + imgSrc);
1165+
h2clog("html2canvas: Error loading <img>:" + imgSrc);
11661166
}
11671167
break;
11681168
case "INPUT":

src/Preload.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ html2canvas.Preload = function(element, opts){
4545
}
4646

4747
function start(){
48-
html2canvas.log("html2canvas: start: images: " + images.numLoaded + " / " + images.numTotal + " (failed: " + images.numFailed + ")");
48+
h2clog("html2canvas: start: images: " + images.numLoaded + " / " + images.numTotal + " (failed: " + images.numFailed + ")");
4949
if (!images.firstRun && images.numLoaded >= images.numTotal){
5050

5151
/*
@@ -57,7 +57,7 @@ html2canvas.Preload = function(element, opts){
5757
options.complete(images);
5858
}
5959

60-
html2canvas.log("Finished loading images: # " + images.numTotal + " (failed: " + images.numFailed + ")");
60+
h2clog("Finished loading images: # " + images.numTotal + " (failed: " + images.numFailed + ")");
6161
}
6262
}
6363

@@ -169,7 +169,7 @@ html2canvas.Preload = function(element, opts){
169169
elNodeType = el.nodeType;
170170
} catch (ex) {
171171
elNodeType = false;
172-
html2canvas.log("html2canvas: failed to access some element's nodeType - Exception: " + ex.message);
172+
h2clog("html2canvas: failed to access some element's nodeType - Exception: " + ex.message);
173173
}
174174

175175
if (elNodeType === 1 || elNodeType === undefined){
@@ -256,9 +256,9 @@ html2canvas.Preload = function(element, opts){
256256
var img, src;
257257
if (!images.cleanupDone) {
258258
if (cause && typeof cause === "string") {
259-
html2canvas.log("html2canvas: Cleanup because: " + cause);
259+
h2clog("html2canvas: Cleanup because: " + cause);
260260
} else {
261-
html2canvas.log("html2canvas: Cleanup after timeout: " + options.timeout + " ms.");
261+
h2clog("html2canvas: Cleanup after timeout: " + options.timeout + " ms.");
262262
}
263263

264264
for (src in images) {
@@ -276,7 +276,7 @@ html2canvas.Preload = function(element, opts){
276276
}
277277
images.numLoaded++;
278278
images.numFailed++;
279-
html2canvas.log("html2canvas: Cleaned up failed img: '" + src + "' Steps: " + images.numLoaded + " / " + images.numTotal);
279+
h2clog("html2canvas: Cleaned up failed img: '" + src + "' Steps: " + images.numLoaded + " / " + images.numTotal);
280280
}
281281
}
282282
}
@@ -307,19 +307,19 @@ html2canvas.Preload = function(element, opts){
307307
if (options.timeout > 0) {
308308
timeoutTimer = window.setTimeout(methods.cleanupDOM, options.timeout);
309309
}
310-
html2canvas.log('html2canvas: Preload starts: finding background-images');
310+
h2clog('html2canvas: Preload starts: finding background-images');
311311
images.firstRun = true;
312312

313313
getImages( element );
314314

315-
html2canvas.log('html2canvas: Preload: Finding images');
315+
h2clog('html2canvas: Preload: Finding images');
316316
// load <img> images
317317
for (i = 0; i < imgLen; i+=1){
318318
methods.loadImage( domImages[i].getAttribute( "src" ) );
319319
}
320320

321321
images.firstRun = false;
322-
html2canvas.log('html2canvas: Preload: Done.');
322+
h2clog('html2canvas: Preload: Done.');
323323
if ( images.numTotal === images.numLoaded ) {
324324
start();
325325
}

src/Queue.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
Released under MIT License
77
*/
8-
html2canvas.canvasContext = function (width, height) {
8+
function h2cRenderContext(width, height) {
99
var storage = [];
1010
return {
1111
storage: storage,
@@ -40,4 +40,4 @@ html2canvas.canvasContext = function (width, height) {
4040
});
4141
}
4242
};
43-
};
43+
}

src/Renderer.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ html2canvas.Renderer = function(parseQueue, opts){
176176

177177

178178
}
179-
html2canvas.log("html2canvas: Renderer: Canvas renderer done - returning canvas obj");
179+
h2clog("html2canvas: Renderer: Canvas renderer done - returning canvas obj");
180180

181181
// this.canvasRenderStorage(queue,this.ctx);
182182
queueLen = options.elements.length;
@@ -390,7 +390,7 @@ html2canvas.Renderer = function(parseQueue, opts){
390390

391391

392392

393-
html2canvas.log("html2canvas: Renderer: SVG Renderer done - returning SVG DOM obj");
393+
h2clog("html2canvas: Renderer: SVG Renderer done - returning SVG DOM obj");
394394

395395
return svg;
396396

@@ -405,11 +405,11 @@ html2canvas.Renderer = function(parseQueue, opts){
405405
case "canvas":
406406
canvas = doc.createElement('canvas');
407407
if (canvas.getContext){
408-
html2canvas.log("html2canvas: Renderer: using canvas renderer");
408+
h2clog("html2canvas: Renderer: using canvas renderer");
409409
return canvasRenderer(parseQueue);
410410
} else {
411411
usingFlashcanvas = true;
412-
html2canvas.log("html2canvas: Renderer: canvas not available, using flashcanvas");
412+
h2clog("html2canvas: Renderer: canvas not available, using flashcanvas");
413413
var script = doc.createElement("script");
414414
script.src = options.flashcanvas;
415415

@@ -436,7 +436,7 @@ html2canvas.Renderer = function(parseQueue, opts){
436436
window.setTimeout( intervalFunc, 250 );
437437

438438
} else {
439-
html2canvas.log("html2canvas: Renderer: Can't track when flashcanvas is loaded");
439+
h2clog("html2canvas: Renderer: Can't track when flashcanvas is loaded");
440440

441441
}
442442

@@ -447,7 +447,7 @@ html2canvas.Renderer = function(parseQueue, opts){
447447
})(script, function(){
448448

449449
if (typeof FlashCanvas !== "undefined") {
450-
html2canvas.log("html2canvas: Renderer: Flashcanvas initialized");
450+
h2clog("html2canvas: Renderer: Flashcanvas initialized");
451451
FlashCanvas.initElement( canvas );
452452
canvasRenderer(parseQueue);
453453
}
@@ -460,7 +460,7 @@ html2canvas.Renderer = function(parseQueue, opts){
460460
break;
461461
case "svg":
462462
if (doc.createElementNS){
463-
html2canvas.log("html2canvas: Renderer: using SVG renderer");
463+
h2clog("html2canvas: Renderer: using SVG renderer");
464464
return svgRenderer(parseQueue);
465465
}
466466
break;

0 commit comments

Comments
 (0)