From df524d2fbc586a58a8c866e6fd1cdc7b9b72d3b2 Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Thu, 18 Jun 2009 04:20:03 +0000 Subject: [PATCH] Fix Issue 21: Opera/WebKit sometimes messed up the bounding box calculation. Also prevented WebKit from deleting the canvas. git-svn-id: http://svg-edit.googlecode.com/svn/trunk@147 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 362edcf3..3658ff61 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -192,10 +192,10 @@ function SvgCanvas(c) var recalculateSelectedOutline = function() { if (selected != null && selectedOutline != null) { var bbox = selected.getBBox(); - var sw = selected.getAttribute("stroke-width"); + var sw = parseInt(selected.getAttribute("stroke-width")); var offset = 1; - if (sw != null && sw != "") { - offset += parseInt(sw)/2; + if (!isNaN(sw)) { + offset += sw/2; } if (selected.tagName == "text") { offset += 2; @@ -217,9 +217,11 @@ function SvgCanvas(c) start_x = x; start_y = y; var t = evt.target; - if (t != svgroot) { - selectElement(t); + // WebKit returns
when the canvas is clicked, Firefox/Opera return + if (t.nodeName.toLowerCase() == "div" || t.nodeName.toLowerCase() == "svg") { + t = null; } + selectElement(t); break; case "fhellipse": case "fhrect": @@ -790,9 +792,6 @@ function SvgCanvas(c) t.parentNode.removeChild(t); call("deleted",t); } - else { - alert("Error! Nothing selected!"); - } } this.moveToTopSelectedElement = function() { @@ -800,9 +799,6 @@ function SvgCanvas(c) var t = selected; t.parentNode.appendChild(t); } - else { - alert("Error! Nothing selected!"); - } } this.moveToBottomSelectedElement = function() { @@ -810,9 +806,6 @@ function SvgCanvas(c) var t = selected; t.parentNode.insertBefore(t, t.parentNode.firstChild); } - else { - alert("Error! Nothing selected!"); - } } }