diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 3c3cb32c..262027c7 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -28,6 +28,14 @@ function svg_edit_setup() { var fillPaint = new $.jGraduate.Paint({solidColor: "FF0000"}); // solid red var strokePaint = new $.jGraduate.Paint({solidColor: "000000"}); // solid black + // TODO: Unfortunately Mozilla does not handle internal references to gradients + // inside a data: URL document. This means that any elements filled/stroked + // with a gradient will appear black in Firefox, etc. See bug 308590 + // https://bugzilla.mozilla.org/show_bug.cgi?id=308590 + var saveHandler = function(window,svg) { + window.open("data:image/svg+xml;base64," + Utils.encode64(svg)); + }; + // called when we've selected a different element var selectedChanged = function(window,elems) { // if elems[1] is present, then we have more than one element @@ -240,6 +248,7 @@ function svg_edit_setup() { // bind the selected event to our function that handles updates to the UI svgCanvas.bind("selected", selectedChanged); svgCanvas.bind("changed", elementChanged); + svgCanvas.bind("saved", saveHandler); var str = '
' $.each(palette, function(i,item){ diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index c11d23bc..e6f4c685 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -1782,7 +1782,7 @@ function SvgCanvas(c) var str = "\n"; // no need for doctype, see http://jwatt.org/svg/authoring/#doctype-declaration str += svgToString(svgroot, 0); - this.saveHandler(str); + call("saved", str); }; this.getSvgString = function() { @@ -2261,14 +2261,6 @@ function SvgCanvas(c) $(container).mousedown(mouseDown); $(container).mousemove(mouseMove); - // TODO: Unfortunately Mozilla does not handle internal references to gradients - // inside a data: URL document. This means that any elements filled/stroked - // with a gradient will appear black in Firefox, etc. See bug 308590 - // https://bugzilla.mozilla.org/show_bug.cgi?id=308590 - this.saveHandler = function(svg) { - window.open("data:image/svg+xml;base64," + Utils.encode64(svg)); - }; - this.deleteSelectedElements = function() { var batchCmd = new BatchCommand("Delete Elements"); var len = selectedElements.length;