From c3e9636e4f9e30df0ad38e5bcb7c8e8a7982ff0e Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Sat, 29 Dec 2012 17:43:15 +0200 Subject: [PATCH] Moved renderer logic to renderer.js --- src/Renderer.js | 17 +++++++++++++---- src/Util.js | 19 +++++-------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Renderer.js b/src/Renderer.js index 1703cc8..25abb00 100644 --- a/src/Renderer.js +++ b/src/Renderer.js @@ -1,5 +1,5 @@ _html2canvas.Renderer = function(parseQueue, options){ - var queue = []; + var queue = [], renderer; function sortZ(zStack){ var subStacks = [], @@ -47,11 +47,20 @@ _html2canvas.Renderer = function(parseQueue, options){ } - sortZ(parseQueue.zIndex); - if ( typeof options._renderer._create !== "function" ) { + + if (typeof options.renderer === "string" && _html2canvas.Renderer[options.renderer] !== undefined) { + renderer = _html2canvas.Renderer[options.renderer](options); + } else if (typeof options.renderer === "function") { + renderer = options.renderer(options); + } else { + throw new Error("Unknown renderer"); + } + + if ( typeof renderer._create !== "function" ) { throw new Error("Invalid renderer defined"); } - return options._renderer._create( parseQueue, options, document, queue, _html2canvas ); + + return renderer._create( parseQueue, options, document, queue, _html2canvas ); }; diff --git a/src/Util.js b/src/Util.js index f17a70d..939936d 100644 --- a/src/Util.js +++ b/src/Util.js @@ -1,5 +1,4 @@ -html2canvas = function( elements, opts ) { - +window.html2canvas = function(elements, opts) { var queue, canvas, options = { @@ -8,7 +7,7 @@ html2canvas = function( elements, opts ) { elements: elements, // preload options - proxy: "http://html2canvas.appspot.com/", + proxy: "", timeout: 0, // no timeout useCORS: false, // try to load images as CORS (where available), before falling back to proxy allowTaint: false, // whether to allow images to taint the canvas, won't need proxy if set to true @@ -27,18 +26,10 @@ html2canvas = function( elements, opts ) { height: null, taintTest: true, // do a taint test with all images before applying to canvas renderer: "Canvas" - }, renderer; + }; options = _html2canvas.Util.Extend(opts, options); - if (typeof options.renderer === "string" && _html2canvas.Renderer[options.renderer] !== undefined) { - options._renderer = _html2canvas.Renderer[options.renderer]( options ); - } else if (typeof options.renderer === "function") { - options._renderer = options.renderer( options ); - } else { - throw("Unknown renderer"); - } - _html2canvas.logging = options.logging; options.complete = function( images ) { @@ -83,7 +74,7 @@ html2canvas = function( elements, opts ) { }; }; -html2canvas.log = h2clog; // for renderers -html2canvas.Renderer = { +window.html2canvas.log = h2clog; // for renderers +window.html2canvas.Renderer = { Canvas: undefined // We are assuming this will be used }; \ No newline at end of file