Fixed Issue 724: text tool is broken in chrome, added new pushGroupPropertiesfunction
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1812 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
7e6b6706cf
commit
5aabcff60c
|
@ -2808,7 +2808,7 @@ var getBBox = this.getBBox = function(elem) {
|
|||
// Parameters:
|
||||
// elem - The (text) DOM element to clone
|
||||
var ffClone = function(elem) {
|
||||
if(isGecko) return elem;
|
||||
if(!isGecko) return elem;
|
||||
var clone = elem.cloneNode(true)
|
||||
elem.parentNode.insertBefore(clone, elem);
|
||||
elem.parentNode.removeChild(elem);
|
||||
|
@ -5575,8 +5575,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
|
|||
// this (similar to editing rotated paths)
|
||||
|
||||
// Ungroup and regroup
|
||||
canvas.ungroupSelectedElement();
|
||||
canvas.groupSelectedElements();
|
||||
pushGroupProperties(mouse_target);
|
||||
mouse_target = selectedElements[0];
|
||||
clearSelection(true);
|
||||
}
|
||||
|
@ -8518,8 +8517,9 @@ var convertToGroup = this.convertToGroup = function(elem) {
|
|||
|
||||
// Temporary hack to get rid of matrix
|
||||
// TODO: See what ungroupSelectedElement does to absorb matrix
|
||||
canvas.ungroupSelectedElement();
|
||||
canvas.groupSelectedElements();
|
||||
// canvas.ungroupSelectedElement();
|
||||
// canvas.groupSelectedElements();
|
||||
batchCmd.addSubCommand(pushGroupProperties(g, true));
|
||||
//
|
||||
addCommandToHistory(batchCmd);
|
||||
|
||||
|
@ -10838,35 +10838,21 @@ this.groupSelectedElements = function() {
|
|||
selectOnly([g], true);
|
||||
};
|
||||
|
||||
// Function: ungroupSelectedElement
|
||||
// Unwraps all the elements in a selected group (g) element. This requires
|
||||
// significant recalculations to apply group's transforms, etc to its children
|
||||
this.ungroupSelectedElement = function() {
|
||||
var g = selectedElements[0];
|
||||
if($(g).data('gsvg') || $(g).data('symbol')) {
|
||||
// Is svg, so actually convert to group
|
||||
|
||||
convertToGroup(g);
|
||||
return;
|
||||
} else if(g.tagName === 'use') {
|
||||
// Somehow doesn't have data set, so retrieve
|
||||
var symbol = getElem(getHref(g).substr(1));
|
||||
$(g).data('symbol', symbol);
|
||||
convertToGroup(g);
|
||||
return;
|
||||
}
|
||||
if (g.tagName == "g") {
|
||||
// Function: pushGroupProperties
|
||||
// Pushes all appropriate parent group properties down to its children, then
|
||||
// removes them from the group
|
||||
var pushGroupProperties = this.pushGroupProperties = function(g, undoable) {
|
||||
|
||||
var batchCmd = new BatchCommand("Ungroup Elements");
|
||||
var parent = g.parentNode;
|
||||
var anchor = g.nextSibling;
|
||||
var children = new Array(g.childNodes.length);
|
||||
var children = g.childNodes;
|
||||
var len = children.length;
|
||||
var xform = g.getAttribute("transform");
|
||||
|
||||
// get consolidated matrix
|
||||
var glist = getTransformList(g);
|
||||
var m = transformListToTransform(glist).matrix;
|
||||
|
||||
var batchCmd = new BatchCommand("Push group properties");
|
||||
|
||||
// TODO: get all fill/stroke properties from the group that we are about to destroy
|
||||
// "fill", "fill-opacity", "fill-rule", "stroke", "stroke-dasharray", "stroke-dashoffset",
|
||||
// "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity",
|
||||
|
@ -10880,20 +10866,8 @@ this.ungroupSelectedElement = function() {
|
|||
var gattrs = $(g).attr(['filter', 'opacity']);
|
||||
var gfilter, gblur;
|
||||
|
||||
while (g.firstChild) {
|
||||
var elem = g.firstChild;
|
||||
var oldNextSibling = elem.nextSibling;
|
||||
var oldParent = elem.parentNode;
|
||||
|
||||
// Remove child title elements
|
||||
if(elem.tagName == 'title') {
|
||||
batchCmd.addSubCommand(new RemoveElementCommand(elem, oldParent));
|
||||
oldParent.removeChild(elem);
|
||||
continue;
|
||||
}
|
||||
|
||||
children[i++] = elem = parent.insertBefore(elem, anchor);
|
||||
batchCmd.addSubCommand(new MoveElementCommand(elem, oldNextSibling, oldParent));
|
||||
for(var i = 0; i < len; i++) {
|
||||
var elem = children[i];
|
||||
|
||||
if(gattrs.opacity !== null && gattrs.opacity !== 1) {
|
||||
var c_opac = elem.getAttribute('opacity') || 1;
|
||||
|
@ -11039,6 +11013,57 @@ this.ungroupSelectedElement = function() {
|
|||
batchCmd.addSubCommand(new ChangeElementCommand(g, changes));
|
||||
}
|
||||
|
||||
if (undoable && !batchCmd.isEmpty()) {
|
||||
return batchCmd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Function: ungroupSelectedElement
|
||||
// Unwraps all the elements in a selected group (g) element. This requires
|
||||
// significant recalculations to apply group's transforms, etc to its children
|
||||
this.ungroupSelectedElement = function() {
|
||||
var g = selectedElements[0];
|
||||
if($(g).data('gsvg') || $(g).data('symbol')) {
|
||||
// Is svg, so actually convert to group
|
||||
|
||||
convertToGroup(g);
|
||||
return;
|
||||
} else if(g.tagName === 'use') {
|
||||
// Somehow doesn't have data set, so retrieve
|
||||
var symbol = getElem(getHref(g).substr(1));
|
||||
$(g).data('symbol', symbol);
|
||||
convertToGroup(g);
|
||||
return;
|
||||
}
|
||||
if (g.tagName === "g") {
|
||||
|
||||
var batchCmd = new BatchCommand("Ungroup Elements");
|
||||
var cmd = pushGroupProperties(g, true);
|
||||
if(cmd) batchCmd.addSubCommand(cmd);
|
||||
|
||||
var parent = g.parentNode;
|
||||
var anchor = g.nextSibling;
|
||||
var children = new Array(g.childNodes.length);
|
||||
|
||||
var i = 0;
|
||||
|
||||
while (g.firstChild) {
|
||||
var elem = g.firstChild;
|
||||
var oldNextSibling = elem.nextSibling;
|
||||
var oldParent = elem.parentNode;
|
||||
|
||||
// Remove child title elements
|
||||
if(elem.tagName === 'title') {
|
||||
batchCmd.addSubCommand(new RemoveElementCommand(elem, oldParent));
|
||||
oldParent.removeChild(elem);
|
||||
continue;
|
||||
}
|
||||
|
||||
children[i++] = elem = parent.insertBefore(elem, anchor);
|
||||
batchCmd.addSubCommand(new MoveElementCommand(elem, oldNextSibling, oldParent));
|
||||
}
|
||||
|
||||
// remove the group from the selection
|
||||
clearSelection();
|
||||
|
||||
|
|
Loading…
Reference in New Issue