From 73a4804324d7e1af9e96da9397ee3f663bf40dc4 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Thu, 22 May 2014 02:56:00 +0000 Subject: [PATCH] Ensure all dependencies available for canvg-using extensions (server_moinsave, server_opensave) git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2849 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/extensions/ext-server_moinsave.js | 4 +- editor/extensions/ext-server_opensave.js | 68 ++++++++++++------------ 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/editor/extensions/ext-server_moinsave.js b/editor/extensions/ext-server_moinsave.js index 759710f1..c71efa65 100644 --- a/editor/extensions/ext-server_moinsave.js +++ b/editor/extensions/ext-server_moinsave.js @@ -32,7 +32,7 @@ svgEditor.addExtension("server_opensave", { var c = $('#export_canvas')[0]; c.width = svgCanvas.contentW; c.height = svgCanvas.contentH; - $.getScript('canvg/canvg.js', function() { + svgEditor.buildCanvgCallback(function () { canvg(c, svg, {renderCallback: function() { var datauri = c.toDataURL('image/png'); // var uiStrings = svgEditor.uiStrings; @@ -48,7 +48,7 @@ svgEditor.addExtension("server_opensave", { .appendTo('body') .submit().remove(); }}); - }); + })(); alert("Saved! Return to Item View!"); top.window.location = '/'+name; } diff --git a/editor/extensions/ext-server_opensave.js b/editor/extensions/ext-server_opensave.js index 2bd952aa..b4ccf293 100644 --- a/editor/extensions/ext-server_opensave.js +++ b/editor/extensions/ext-server_opensave.js @@ -68,41 +68,41 @@ svgEditor.addExtension("server_opensave", { c.width = svgCanvas.contentW; c.height = svgCanvas.contentH; - canvg(c, data.svg, {renderCallback: function() { - var pre, filename, suffix, - datauri = quality ? c.toDataURL(mimeType, quality) : c.toDataURL(mimeType), - // uiStrings = svgEditor.uiStrings, - note = ''; - - // Check if there are issues - if (issues.length) { - pre = "\n \u2022 "; - note += ("\n\n" + pre + issues.join(pre)); - } - - if(note.length) { - alert(note); - } - - filename = getFileNameFromTitle(); - suffix = '.' + data.type.toLowerCase(); - - if (clientDownloadSupport(filename, suffix, datauri)) { - return; - } + svgEditor.buildCanvgCallback(function () { + canvg(c, data.svg, {renderCallback: function() { + var pre, filename, suffix, + datauri = quality ? c.toDataURL(mimeType, quality) : c.toDataURL(mimeType), + // uiStrings = svgEditor.uiStrings, + note = ''; + + // Check if there are issues + if (issues.length) { + pre = "\n \u2022 "; + note += ("\n\n" + pre + issues.join(pre)); + } + + if(note.length) { + alert(note); + } + + filename = getFileNameFromTitle(); + suffix = '.' + data.type.toLowerCase(); + + if (clientDownloadSupport(filename, suffix, datauri)) { + return; + } - $('
').attr({ - method: 'post', - action: save_img_action, - target: 'output_frame' - }).append('') - .append('') - .append('') - .appendTo('body') - .submit().remove(); - }}); - - + $('').attr({ + method: 'post', + action: save_img_action, + target: 'output_frame' + }).append('') + .append('') + .append('') + .appendTo('body') + .submit().remove(); + }}); + })(); } });