From fe4cac17e6ee90508b569a132050a361e24128f9 Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Wed, 9 Sep 2009 18:15:28 +0000 Subject: [PATCH] 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 --- editor/svgcanvas.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index d8b6fb7f..5b438047 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -2443,9 +2443,18 @@ function BatchCommand(text) { svgzoom = svgroot.appendChild(svgdoc.importNode(newDoc.documentElement, true)); svgzoom.setAttribute('id', 'svgzoom'); // determine proper size - var vb = svgzoom.getAttribute("viewBox").split(' '); - var w = vb[2]; - var h = vb[3]; + var w, h; + if (svgzoom.getAttribute("viewBox")) { + var vb = svgzoom.getAttribute("viewBox").split(' '); + 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');