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
master
Brett Zamir 2014-05-22 02:56:00 +00:00
parent 905dac6979
commit 73a4804324
2 changed files with 36 additions and 36 deletions

View File

@ -32,7 +32,7 @@ svgEditor.addExtension("server_opensave", {
var c = $('#export_canvas')[0]; var c = $('#export_canvas')[0];
c.width = svgCanvas.contentW; c.width = svgCanvas.contentW;
c.height = svgCanvas.contentH; c.height = svgCanvas.contentH;
$.getScript('canvg/canvg.js', function() { svgEditor.buildCanvgCallback(function () {
canvg(c, svg, {renderCallback: function() { canvg(c, svg, {renderCallback: function() {
var datauri = c.toDataURL('image/png'); var datauri = c.toDataURL('image/png');
// var uiStrings = svgEditor.uiStrings; // var uiStrings = svgEditor.uiStrings;
@ -48,7 +48,7 @@ svgEditor.addExtension("server_opensave", {
.appendTo('body') .appendTo('body')
.submit().remove(); .submit().remove();
}}); }});
}); })();
alert("Saved! Return to Item View!"); alert("Saved! Return to Item View!");
top.window.location = '/'+name; top.window.location = '/'+name;
} }

View File

@ -68,41 +68,41 @@ svgEditor.addExtension("server_opensave", {
c.width = svgCanvas.contentW; c.width = svgCanvas.contentW;
c.height = svgCanvas.contentH; c.height = svgCanvas.contentH;
canvg(c, data.svg, {renderCallback: function() { svgEditor.buildCanvgCallback(function () {
var pre, filename, suffix, canvg(c, data.svg, {renderCallback: function() {
datauri = quality ? c.toDataURL(mimeType, quality) : c.toDataURL(mimeType), var pre, filename, suffix,
// uiStrings = svgEditor.uiStrings, datauri = quality ? c.toDataURL(mimeType, quality) : c.toDataURL(mimeType),
note = ''; // uiStrings = svgEditor.uiStrings,
note = '';
// Check if there are issues
if (issues.length) { // Check if there are issues
pre = "\n \u2022 "; if (issues.length) {
note += ("\n\n" + pre + issues.join(pre)); pre = "\n \u2022 ";
} note += ("\n\n" + pre + issues.join(pre));
}
if(note.length) {
alert(note); if(note.length) {
} alert(note);
}
filename = getFileNameFromTitle();
suffix = '.' + data.type.toLowerCase(); filename = getFileNameFromTitle();
suffix = '.' + data.type.toLowerCase();
if (clientDownloadSupport(filename, suffix, datauri)) {
return; if (clientDownloadSupport(filename, suffix, datauri)) {
} return;
}
$('<form>').attr({ $('<form>').attr({
method: 'post', method: 'post',
action: save_img_action, action: save_img_action,
target: 'output_frame' target: 'output_frame'
}).append('<input type="hidden" name="output_img" value="' + datauri + '">') }).append('<input type="hidden" name="output_img" value="' + datauri + '">')
.append('<input type="hidden" name="mime" value="' + mimeType + '">') .append('<input type="hidden" name="mime" value="' + mimeType + '">')
.append('<input type="hidden" name="filename" value="' + xhtmlEscape(filename) + '">') .append('<input type="hidden" name="filename" value="' + xhtmlEscape(filename) + '">')
.appendTo('body') .appendTo('body')
.submit().remove(); .submit().remove();
}}); }});
})();
} }
}); });