Fix svgToString() for new zoom DOM structure

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@615 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Jeff Schiller
2009-09-09 16:43:09 +00:00
parent 81c3689a2b
commit 7de608001e

View File

@@ -2448,21 +2448,27 @@ function BatchCommand(text) {
var batchCmd = new BatchCommand("Change Source"); var batchCmd = new BatchCommand("Change Source");
// save our old selectorParentGroup // save our old selectorParentGroup
selectorManager.selectorParentGroup = svgroot.removeChild(selectorManager.selectorParentGroup); // not needed anymore, we can keep svgroot forever (and just replace svgzoom)
// TODO: reset zoom level on svgroot
// selectorManager.selectorParentGroup = svgroot.removeChild(selectorManager.selectorParentGroup);
// remove old root // remove old svg document
var oldroot = container.removeChild(svgroot); var oldzoom = svgroot.removeChild(svgzoom);
batchCmd.addSubCommand(new RemoveElementCommand(oldroot, container)); batchCmd.addSubCommand(new RemoveElementCommand(oldzoom, svgroot));
// set new root // set new svg document
svgroot = container.appendChild(svgdoc.importNode(newDoc.documentElement, true)); svgzoom = svgroot.appendChild(svgdoc.importNode(newDoc.documentElement, true));
batchCmd.addSubCommand(new InsertElementCommand(svgroot)); svgzoom.setAttribute('id', 'svgzoom');
// TODO: determine size?
svgzoom.setAttribute('viewBox', '0 0 640 480');
batchCmd.addSubCommand(new InsertElementCommand(svgzoom));
// add back in parentSelectorGroup // add back in parentSelectorGroup
svgroot.appendChild(selectorManager.selectorParentGroup); // not needed anymore
// svgroot.appendChild(selectorManager.selectorParentGroup);
addCommandToHistory(batchCmd); addCommandToHistory(batchCmd);
call("changed", [svgroot]); call("changed", [svgzoom]);
} catch(e) { } catch(e) {
console.log(e); console.log(e);
return false; return false;