Fixes to foreignObject Extension

(From Alex)
This commit is contained in:
Jacques Distler 2010-02-17 14:48:49 -06:00
parent ea581a50ae
commit b302bf36c5

View file

@ -21,7 +21,9 @@ $(function() {
htmlns = "http://www.w3.org/1999/xhtml", htmlns = "http://www.w3.org/1999/xhtml",
mathns = "http://www.w3.org/1998/Math/MathML", mathns = "http://www.w3.org/1998/Math/MathML",
editingforeign = false, editingforeign = false,
svgdoc = S.svgroot.parentNode.ownerDocument; svgdoc = S.svgroot.parentNode.ownerDocument,
started,
newFO;
var properlySourceSizeTextArea = function(){ var properlySourceSizeTextArea = function(){
@ -200,7 +202,8 @@ $(function() {
if(svgCanvas.getMode() == "foreign") { if(svgCanvas.getMode() == "foreign") {
var newText = S.addSvgElementFromJson({ started = true;
newFO = S.addSvgElementFromJson({
"element": "foreignObject", "element": "foreignObject",
"attr": { "attr": {
"x": opts.start_x, "x": opts.start_x,
@ -225,7 +228,7 @@ $(function() {
m.appendChild(mi); m.appendChild(mi);
m.appendChild(mo); m.appendChild(mo);
m.appendChild(mi2); m.appendChild(mi2);
newText.appendChild(m); newFO.appendChild(m);
return { return {
started: true started: true
} }
@ -233,15 +236,14 @@ $(function() {
}, },
mouseUp: function(opts) { mouseUp: function(opts) {
var e = opts.event; var e = opts.event;
if(svgCanvas.getMode() == "foreign" && started) {
if(svgCanvas.getMode() == "foreign") { var attrs = $(newFO).attr(["width", "height"]);
var attrs = $(e.target).attr(["width", "height"]);
keep = (attrs.width != 0 || attrs.height != 0); keep = (attrs.width != 0 || attrs.height != 0);
svgCanvas.addToSelection([newFO], true);
svgCanvas.addToSelection([e.target], true);
return { return {
keep: keep, keep: keep,
element: e.target element: newFO
} }
} }