More fixes for zoom: handle old content that does not have a viewBox

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@617 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Jeff Schiller 2009-09-09 18:15:28 +00:00
parent 9e925d1e1f
commit fe4cac17e6
1 changed files with 12 additions and 3 deletions

View File

@ -2443,9 +2443,18 @@ function BatchCommand(text) {
svgzoom = svgroot.appendChild(svgdoc.importNode(newDoc.documentElement, true));
svgzoom.setAttribute('id', 'svgzoom');
// determine proper size
var w, h;
if (svgzoom.getAttribute("viewBox")) {
var vb = svgzoom.getAttribute("viewBox").split(' ');
var w = vb[2];
var h = vb[3];
w = vb[2];
h = vb[3];
}
// handle old content that doesn't have a viewBox
else {
w = svgzoom.getAttribute("width");
h = svgzoom.getAttribute("height");
svgzoom.setAttribute("viewBox", ["0", "0", w, h].join(" "));
}
// just to be safe, remove any width/height from text so that they are 100%/100%
svgzoom.removeAttribute('width');
svgzoom.removeAttribute('height');