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-75d572ba1dddmaster
parent
a69ea2ed1d
commit
299cf0215c
|
@ -16,7 +16,7 @@ function svg_edit_setup() {
|
||||||
$('#tool_select').addClass('tool_button_current');
|
$('#tool_select').addClass('tool_button_current');
|
||||||
$('#styleoverrides').text('*{cursor:move;pointer-events:all} svg{cursor:default}');
|
$('#styleoverrides').text('*{cursor:move;pointer-events:all} svg{cursor:default}');
|
||||||
svgCanvas.setMode('select');
|
svgCanvas.setMode('select');
|
||||||
}
|
};
|
||||||
|
|
||||||
// used to make the flyouts stay on the screen longer the very first time
|
// used to make the flyouts stay on the screen longer the very first time
|
||||||
var flyoutspeed = 1250;
|
var flyoutspeed = 1250;
|
||||||
|
@ -45,7 +45,7 @@ function svg_edit_setup() {
|
||||||
} // if (elem != null)
|
} // if (elem != null)
|
||||||
|
|
||||||
updateContextPanel(true);
|
updateContextPanel(true);
|
||||||
}
|
};
|
||||||
|
|
||||||
// called when any element has changed
|
// called when any element has changed
|
||||||
var elementChanged = function(window,elems) {
|
var elementChanged = function(window,elems) {
|
||||||
|
@ -66,10 +66,10 @@ function svg_edit_setup() {
|
||||||
// we tell it to skip focusing the text control if the
|
// we tell it to skip focusing the text control if the
|
||||||
// text element was previously in focus
|
// text element was previously in focus
|
||||||
updateContextPanel(false);
|
updateContextPanel(false);
|
||||||
}
|
};
|
||||||
|
|
||||||
// updates the toolbar (colors, opacity, etc) based on the selected element
|
// updates the toolbar (colors, opacity, etc) based on the selected element
|
||||||
function updateToolbar() {
|
var updateToolbar = function() {
|
||||||
if (selectedElement != null) {
|
if (selectedElement != null) {
|
||||||
// get opacity values
|
// get opacity values
|
||||||
var fillOpacity = parseFloat(selectedElement.getAttribute("fill-opacity"));
|
var fillOpacity = parseFloat(selectedElement.getAttribute("fill-opacity"));
|
||||||
|
@ -143,10 +143,10 @@ function svg_edit_setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateToolButtonState();
|
updateToolButtonState();
|
||||||
}
|
};
|
||||||
|
|
||||||
// updates the context panel tools based on the selected element
|
// updates the context panel tools based on the selected element
|
||||||
function updateContextPanel(shouldHighlightText) {
|
var updateContextPanel = function(shouldHighlightText) {
|
||||||
var elem = selectedElement;
|
var elem = selectedElement;
|
||||||
$('#selected_panel').hide();
|
$('#selected_panel').hide();
|
||||||
$('#multiselected_panel').hide();
|
$('#multiselected_panel').hide();
|
||||||
|
@ -232,7 +232,7 @@ function svg_edit_setup() {
|
||||||
else {
|
else {
|
||||||
$('#tool_redo').addClass( 'tool_button_disabled');
|
$('#tool_redo').addClass( 'tool_button_disabled');
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
$('#text').focus( function(){ textBeingEntered = true; } );
|
$('#text').focus( function(){ textBeingEntered = true; } );
|
||||||
$('#text').blur( function(){ textBeingEntered = false; } );
|
$('#text').blur( function(){ textBeingEntered = false; } );
|
||||||
|
@ -261,7 +261,7 @@ function svg_edit_setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var changeRotationAngle = function(ctl) {
|
var changeRotationAngle = function(ctl) {
|
||||||
// TODO: change rotation angle
|
svgCanvas.setRotationAngle(ctl.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#stroke_style').change(function(){
|
$('#stroke_style').change(function(){
|
||||||
|
@ -672,9 +672,9 @@ function svg_edit_setup() {
|
||||||
function(p) {
|
function(p) {
|
||||||
$('#color_picker').hide();
|
$('#color_picker').hide();
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
function updateToolButtonState() {
|
var updateToolButtonState = function() {
|
||||||
var bNoFill = (svgCanvas.getFillColor() == 'none');
|
var bNoFill = (svgCanvas.getFillColor() == 'none');
|
||||||
var bNoStroke = (svgCanvas.getStrokeColor() == 'none');
|
var bNoStroke = (svgCanvas.getStrokeColor() == 'none');
|
||||||
var buttonsNeedingStroke = [ '#tool_path', '#tool_line' ];
|
var buttonsNeedingStroke = [ '#tool_path', '#tool_line' ];
|
||||||
|
@ -710,7 +710,7 @@ function svg_edit_setup() {
|
||||||
$(button).removeClass('tool_button_disabled').addClass('tool_button');
|
$(button).removeClass('tool_button_disabled').addClass('tool_button');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// set up gradients to be used for the buttons
|
// set up gradients to be used for the buttons
|
||||||
var svgdocbox = new DOMParser().parseFromString(
|
var svgdocbox = new DOMParser().parseFromString(
|
||||||
|
@ -777,7 +777,7 @@ function svg_edit_setup() {
|
||||||
|
|
||||||
$('#rect_radius').SpinButton({ min: 0, max: 1000, step: 1, callback: changeRectRadius });
|
$('#rect_radius').SpinButton({ min: 0, max: 1000, step: 1, callback: changeRectRadius });
|
||||||
$('#stroke_width').SpinButton({ min: 1, max: 99, step: 1, callback: changeStrokeWidth });
|
$('#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;
|
return svgCanvas;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1770,7 +1770,7 @@ function SvgCanvas(c)
|
||||||
|
|
||||||
// this function returns false if the set was unsuccessful, true otherwise
|
// this function returns false if the set was unsuccessful, true otherwise
|
||||||
// TODO: should this function keep throwing the exception?
|
// 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) {
|
this.setSvgString = function(xmlString) {
|
||||||
try {
|
try {
|
||||||
// convert string into XML document
|
// convert string into XML document
|
||||||
|
@ -1781,6 +1781,9 @@ function SvgCanvas(c)
|
||||||
|
|
||||||
var batchCmd = new BatchCommand("Change Source");
|
var batchCmd = new BatchCommand("Change Source");
|
||||||
|
|
||||||
|
// save our old selectorParentGroup
|
||||||
|
selectorManager.selectorParentGroup = svgroot.removeChild(selectorManager.selectorParentGroup);
|
||||||
|
|
||||||
// remove old root
|
// remove old root
|
||||||
var oldroot = container.removeChild(svgroot);
|
var oldroot = container.removeChild(svgroot);
|
||||||
batchCmd.addSubCommand(new RemoveElementCommand(oldroot, container));
|
batchCmd.addSubCommand(new RemoveElementCommand(oldroot, container));
|
||||||
|
@ -1789,6 +1792,9 @@ function SvgCanvas(c)
|
||||||
svgroot = container.appendChild(svgdoc.importNode(newDoc.documentElement, true));
|
svgroot = container.appendChild(svgdoc.importNode(newDoc.documentElement, true));
|
||||||
batchCmd.addSubCommand(new InsertElementCommand(svgroot));
|
batchCmd.addSubCommand(new InsertElementCommand(svgroot));
|
||||||
|
|
||||||
|
// add back in parentSelectorGroup
|
||||||
|
svgroot.appendChild(selectorManager.selectorParentGroup);
|
||||||
|
|
||||||
addCommandToHistory(batchCmd);
|
addCommandToHistory(batchCmd);
|
||||||
call("changed", [svgroot]);
|
call("changed", [svgroot]);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
@ -2040,6 +2046,10 @@ function SvgCanvas(c)
|
||||||
current_stroke_opacity = val;
|
current_stroke_opacity = val;
|
||||||
this.changeSelectedAttribute("stroke-opacity", val);
|
this.changeSelectedAttribute("stroke-opacity", val);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.setRotationAngle = function(val) {
|
||||||
|
console.log(val);
|
||||||
|
};
|
||||||
|
|
||||||
this.each = function(cb) {
|
this.each = function(cb) {
|
||||||
$(svgroot).children().each(cb);
|
$(svgroot).children().each(cb);
|
||||||
|
|
Loading…
Reference in New Issue