Fixed more IE9 bugs, re-enabled animation in IE

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1720 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2010-09-16 12:56:09 +00:00
parent 3e159f2180
commit 411dbc49a1
2 changed files with 78 additions and 51 deletions

View File

@ -12,7 +12,7 @@
(function() { (function() {
// TODO: Find out what causes bugs in jQuery animate for IE9 // TODO: Find out what causes bugs in jQuery animate for IE9
if($.browser.msie) $.fx.off = true; // if($.browser.msie) $.fx.off = true;
if(!window.svgEditor) window.svgEditor = function($) { if(!window.svgEditor) window.svgEditor = function($) {
var svgCanvas; var svgCanvas;

View File

@ -457,13 +457,6 @@ var canvas = this,
// Array with width/height of canvas // Array with width/height of canvas
dimensions = curConfig.dimensions; dimensions = curConfig.dimensions;
if($.browser.msie) {
var svgroot = document.createElementNS(svgns, 'svg');
svgroot.id = 'svgroot';
svgroot.setAttribute('width', dimensions[0]);
svgroot.setAttribute('height', dimensions[1]);
} else {
// Create Root SVG element. This is a container for the document being edited, not the document itself. // Create Root SVG element. This is a container for the document being edited, not the document itself.
var svgroot = svgdoc.importNode(Utils.text2xml('<svg id="svgroot" xmlns="' + svgns + '" xlinkns="' + xlinkns + '" ' + var svgroot = svgdoc.importNode(Utils.text2xml('<svg id="svgroot" xmlns="' + svgns + '" xlinkns="' + xlinkns + '" ' +
'width="' + dimensions[0] + '" height="' + dimensions[1] + '" x="' + dimensions[0] + '" y="' + dimensions[1] + '" overflow="visible">' + 'width="' + dimensions[0] + '" height="' + dimensions[1] + '" x="' + dimensions[0] + '" y="' + dimensions[1] + '" overflow="visible">' +
@ -478,7 +471,6 @@ var canvas = this,
'</filter>'+ '</filter>'+
'</defs>'+ '</defs>'+
'</svg>').documentElement, true); '</svg>').documentElement, true);
}
container.appendChild(svgroot); container.appendChild(svgroot);
@ -1231,9 +1223,11 @@ var SelectorManager;
// get the bbox based on its children. // get the bbox based on its children.
var stroked_bbox = getStrokedBBox(selected.childNodes); var stroked_bbox = getStrokedBBox(selected.childNodes);
if(stroked_bbox) { if(stroked_bbox) {
var bb = {};
$.each(bbox, function(key, val) { $.each(bbox, function(key, val) {
bbox[key] = stroked_bbox[key]; bb[key] = stroked_bbox[key];
}); });
bbox = bb;
} }
} }
@ -3508,7 +3502,11 @@ var recalculateDimensions = this.recalculateDimensions = function(selected) {
if (childTlist) { if (childTlist) {
var newxlate = svgroot.createSVGTransform(); var newxlate = svgroot.createSVGTransform();
newxlate.setTranslate(tx,ty); newxlate.setTranslate(tx,ty);
if(childTlist.numberOfItems) {
childTlist.insertItemBefore(newxlate, 0); childTlist.insertItemBefore(newxlate, 0);
} else {
childTlist.appendItem(newxlate);
}
batchCmd.addSubCommand( recalculateDimensions(child) ); batchCmd.addSubCommand( recalculateDimensions(child) );
// If any <use> have this group as a parent and are // If any <use> have this group as a parent and are
// referencing this child, then impose a reverse translate on it // referencing this child, then impose a reverse translate on it
@ -3568,7 +3566,11 @@ var recalculateDimensions = this.recalculateDimensions = function(selected) {
if (gangle) { if (gangle) {
var newRot = svgroot.createSVGTransform(); var newRot = svgroot.createSVGTransform();
newRot.setRotate(gangle,newcenter.x,newcenter.y); newRot.setRotate(gangle,newcenter.x,newcenter.y);
if(tlist.numberOfItems) {
tlist.insertItemBefore(newRot, 0); tlist.insertItemBefore(newRot, 0);
} else {
tlist.appendItem(newRot);
}
} }
if (tlist.numberOfItems == 0) { if (tlist.numberOfItems == 0) {
selected.removeAttribute("transform"); selected.removeAttribute("transform");
@ -3586,7 +3588,11 @@ var recalculateDimensions = this.recalculateDimensions = function(selected) {
var newRot = svgroot.createSVGTransform(); var newRot = svgroot.createSVGTransform();
newRot.setRotate(gangle,newcenter.x,newcenter.y); newRot.setRotate(gangle,newcenter.x,newcenter.y);
if(tlist.numberOfItems) {
tlist.insertItemBefore(newRot, 0); tlist.insertItemBefore(newRot, 0);
} else {
tlist.appendItem(newRot);
}
} }
} }
// if it was a resize // if it was a resize
@ -3617,7 +3623,12 @@ var recalculateDimensions = this.recalculateDimensions = function(selected) {
var childTlist = getTransformList(child); var childTlist = getTransformList(child);
var newxlate = svgroot.createSVGTransform(); var newxlate = svgroot.createSVGTransform();
newxlate.setTranslate(tx,ty); newxlate.setTranslate(tx,ty);
if(childTlist.numberOfItems) {
childTlist.insertItemBefore(newxlate, 0); childTlist.insertItemBefore(newxlate, 0);
} else {
childTlist.appendItem(newxlate);
}
batchCmd.addSubCommand( recalculateDimensions(child) ); batchCmd.addSubCommand( recalculateDimensions(child) );
start_transform = old_start_transform; start_transform = old_start_transform;
} }
@ -3625,7 +3636,11 @@ var recalculateDimensions = this.recalculateDimensions = function(selected) {
} }
if (gangle) { if (gangle) {
if(tlist.numberOfItems) {
tlist.insertItemBefore(rnew, 0); tlist.insertItemBefore(rnew, 0);
} else {
tlist.appendItem(rnew);
}
} }
} }
} }
@ -3773,7 +3788,11 @@ var recalculateDimensions = this.recalculateDimensions = function(selected) {
if (angle) { if (angle) {
var newRot = svgroot.createSVGTransform(); var newRot = svgroot.createSVGTransform();
newRot.setRotate(angle,newcenter.x,newcenter.y); newRot.setRotate(angle,newcenter.x,newcenter.y);
if(tlist.numberOfItems) {
tlist.insertItemBefore(newRot, 0); tlist.insertItemBefore(newRot, 0);
} else {
tlist.appendItem(newRot);
}
} }
if (tlist.numberOfItems == 0) { if (tlist.numberOfItems == 0) {
selected.removeAttribute("transform"); selected.removeAttribute("transform");
@ -3797,7 +3816,11 @@ var recalculateDimensions = this.recalculateDimensions = function(selected) {
} }
var newRot = svgroot.createSVGTransform(); var newRot = svgroot.createSVGTransform();
newRot.setRotate(angle, newcenter.x, newcenter.y); newRot.setRotate(angle, newcenter.x, newcenter.y);
if(tlist.numberOfItems) {
tlist.insertItemBefore(newRot, 0); tlist.insertItemBefore(newRot, 0);
} else {
tlist.appendItem(newRot);
}
} }
} }
// [Rold][M][T][S][-T] became [Rold][M] // [Rold][M][T][S][-T] became [Rold][M]
@ -3817,7 +3840,11 @@ var recalculateDimensions = this.recalculateDimensions = function(selected) {
remapElement(selected,changes,extrat); remapElement(selected,changes,extrat);
if (angle) { if (angle) {
tlist.insertItemBefore(rnew,0); if(tlist.numberOfItems) {
tlist.insertItemBefore(rnew, 0);
} else {
tlist.appendItem(rnew);
}
} }
} }
} // a non-group } // a non-group
@ -4382,7 +4409,11 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
for (var i = 0; i < selectedElements.length; ++i) { for (var i = 0; i < selectedElements.length; ++i) {
if(selectedElements[i] == null) continue; if(selectedElements[i] == null) continue;
var slist = getTransformList(selectedElements[i]); var slist = getTransformList(selectedElements[i]);
if(slist.numberOfItems) {
slist.insertItemBefore(svgroot.createSVGTransform(), 0); slist.insertItemBefore(svgroot.createSVGTransform(), 0);
} else {
slist.appendItem(svgroot.createSVGTransform());
}
} }
} }
} }
@ -4429,9 +4460,11 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
// Getting the BBox from the selection box, since we know we // Getting the BBox from the selection box, since we know we
// want to orient around it // want to orient around it
init_bbox = getBBox($('#selectedBox0')[0]); init_bbox = getBBox($('#selectedBox0')[0]);
var bb = {};
$.each(init_bbox, function(key, val) { $.each(init_bbox, function(key, val) {
init_bbox[key] = val/current_zoom; bb[key] = val/current_zoom;
}); });
init_bbox = bb;
// append three dummy transforms to the tlist so that // append three dummy transforms to the tlist so that
// we can translate,scale,translate in mousemove // we can translate,scale,translate in mousemove
@ -4820,21 +4853,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
tlist.replaceItem(scale, N-2); tlist.replaceItem(scale, N-2);
tlist.replaceItem(translateOrigin, N-1); tlist.replaceItem(translateOrigin, N-1);
} }
var selectedBBox = selectedBBoxes[0];
if(selectedBBox) {
// reset selected bbox top-left position
selectedBBox.x = left;
selectedBBox.y = top;
// if this is a translate, adjust the box position
if (tx) {
selectedBBox.x += dx;
}
if (ty) {
selectedBBox.y += dy;
}
}
selectorManager.requestSelector(selected).resize(); selectorManager.requestSelector(selected).resize();
break; break;
case "zoom": case "zoom":
@ -10581,13 +10600,21 @@ this.ungroupSelectedElement = function() {
} }
if (sangle) { if (sangle) {
if(chtlist.numberOfItems) {
chtlist.insertItemBefore(r2, 0); chtlist.insertItemBefore(r2, 0);
} else {
chtlist.appendItem(r2);
}
} }
if (trm.e || trm.f) { if (trm.e || trm.f) {
var tr = svgroot.createSVGTransform(); var tr = svgroot.createSVGTransform();
tr.setTranslate(trm.e, trm.f); tr.setTranslate(trm.e, trm.f);
if(chtlist.numberOfItems) {
chtlist.insertItemBefore(tr, 0); chtlist.insertItemBefore(tr, 0);
} else {
chtlist.appendItem(tr);
}
} }
} }
else { // more complicated than just a rotate else { // more complicated than just a rotate