Fix bug: If SVG source was changed, selectorParentGroup was thrown away meaning you could no longer create a poly

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@387 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Jeff Schiller 2009-08-16 02:48:00 +00:00
parent a69ea2ed1d
commit 299cf0215c
2 changed files with 23 additions and 13 deletions

View File

@ -16,7 +16,7 @@ function svg_edit_setup() {
$('#tool_select').addClass('tool_button_current');
$('#styleoverrides').text('*{cursor:move;pointer-events:all} svg{cursor:default}');
svgCanvas.setMode('select');
}
};
// used to make the flyouts stay on the screen longer the very first time
var flyoutspeed = 1250;
@ -45,7 +45,7 @@ function svg_edit_setup() {
} // if (elem != null)
updateContextPanel(true);
}
};
// called when any element has changed
var elementChanged = function(window,elems) {
@ -66,10 +66,10 @@ function svg_edit_setup() {
// we tell it to skip focusing the text control if the
// text element was previously in focus
updateContextPanel(false);
}
};
// updates the toolbar (colors, opacity, etc) based on the selected element
function updateToolbar() {
var updateToolbar = function() {
if (selectedElement != null) {
// get opacity values
var fillOpacity = parseFloat(selectedElement.getAttribute("fill-opacity"));
@ -143,10 +143,10 @@ function svg_edit_setup() {
}
updateToolButtonState();
}
};
// updates the context panel tools based on the selected element
function updateContextPanel(shouldHighlightText) {
var updateContextPanel = function(shouldHighlightText) {
var elem = selectedElement;
$('#selected_panel').hide();
$('#multiselected_panel').hide();
@ -232,7 +232,7 @@ function svg_edit_setup() {
else {
$('#tool_redo').addClass( 'tool_button_disabled');
}
}
};
$('#text').focus( function(){ textBeingEntered = true; } );
$('#text').blur( function(){ textBeingEntered = false; } );
@ -261,7 +261,7 @@ function svg_edit_setup() {
}
var changeRotationAngle = function(ctl) {
// TODO: change rotation angle
svgCanvas.setRotationAngle(ctl.value);
}
$('#stroke_style').change(function(){
@ -672,9 +672,9 @@ function svg_edit_setup() {
function(p) {
$('#color_picker').hide();
});
}
};
function updateToolButtonState() {
var updateToolButtonState = function() {
var bNoFill = (svgCanvas.getFillColor() == 'none');
var bNoStroke = (svgCanvas.getStrokeColor() == 'none');
var buttonsNeedingStroke = [ '#tool_path', '#tool_line' ];
@ -710,7 +710,7 @@ function svg_edit_setup() {
$(button).removeClass('tool_button_disabled').addClass('tool_button');
}
}
}
};
// set up gradients to be used for the buttons
var svgdocbox = new DOMParser().parseFromString(
@ -777,7 +777,7 @@ function svg_edit_setup() {
$('#rect_radius').SpinButton({ min: 0, max: 1000, step: 1, callback: changeRectRadius });
$('#stroke_width').SpinButton({ min: 1, max: 99, step: 1, callback: changeStrokeWidth });
$('#angle').SpinButton({ min: -359, max: 359, step: 1, callback: changeRotationAngle });
$('#angle').SpinButton({ min: -359, max: 359, step: 5, callback: changeRotationAngle });
return svgCanvas;
};

View File

@ -1770,7 +1770,7 @@ function SvgCanvas(c)
// this function returns false if the set was unsuccessful, true otherwise
// TODO: should this function keep throwing the exception?
// FIXME: after parsing in the new file, how do we synchronize getId()?
// TODO: after parsing in the new text, do we need to synchronize getId()?
this.setSvgString = function(xmlString) {
try {
// convert string into XML document
@ -1781,6 +1781,9 @@ function SvgCanvas(c)
var batchCmd = new BatchCommand("Change Source");
// save our old selectorParentGroup
selectorManager.selectorParentGroup = svgroot.removeChild(selectorManager.selectorParentGroup);
// remove old root
var oldroot = container.removeChild(svgroot);
batchCmd.addSubCommand(new RemoveElementCommand(oldroot, container));
@ -1789,6 +1792,9 @@ function SvgCanvas(c)
svgroot = container.appendChild(svgdoc.importNode(newDoc.documentElement, true));
batchCmd.addSubCommand(new InsertElementCommand(svgroot));
// add back in parentSelectorGroup
svgroot.appendChild(selectorManager.selectorParentGroup);
addCommandToHistory(batchCmd);
call("changed", [svgroot]);
} catch(e) {
@ -2040,6 +2046,10 @@ function SvgCanvas(c)
current_stroke_opacity = val;
this.changeSelectedAttribute("stroke-opacity", val);
};
this.setRotationAngle = function(val) {
console.log(val);
};
this.each = function(cb) {
$(svgroot).children().each(cb);