From cd00087f2a4eed221324611446d8c520123d22e0 Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Sun, 30 Jan 2011 16:45:29 +0000 Subject: [PATCH] Fix Bug 767: Fire changed events when changing stacking order of elements (modified patch from Da.Waterworth) git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1952 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index f4df9775..0aa688a3 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -9231,7 +9231,12 @@ this.moveToTopSelectedElement = function() { var oldParent = t.parentNode; var oldNextSibling = t.nextSibling; t = t.parentNode.appendChild(t); - addCommandToHistory(new MoveElementCommand(t, oldNextSibling, oldParent, "top")); + // If the element actually moved position, add the command and fire the changed + // event handler. + if (oldNextSibling != t.nextSibling) { + addCommandToHistory(new MoveElementCommand(t, oldNextSibling, oldParent, "top")); + call("changed", [t]); + } } }; @@ -9254,7 +9259,12 @@ this.moveToBottomSelectedElement = function() { firstChild = firstChild.nextSibling; } t = t.parentNode.insertBefore(t, firstChild); - addCommandToHistory(new MoveElementCommand(t, oldNextSibling, oldParent, "bottom")); + // If the element actually moved position, add the command and fire the changed + // event handler. + if (oldNextSibling != t.nextSibling) { + addCommandToHistory(new MoveElementCommand(t, oldNextSibling, oldParent, "bottom")); + call("changed", [t]); + } } }; @@ -9290,8 +9300,13 @@ this.moveUpDownSelected = function(dir) { var oldParent = t.parentNode; var oldNextSibling = t.nextSibling; $(closest)[dir == 'Down'?'before':'after'](t); - addCommandToHistory(new MoveElementCommand(t, oldNextSibling, oldParent, "Move " + dir)); -} + // If the element actually moved position, add the command and fire the changed + // event handler. + if (oldNextSibling != t.nextSibling) { + addCommandToHistory(new MoveElementCommand(t, oldNextSibling, oldParent, "Move " + dir)); + call("changed", [t]); + } +}; // Function: moveSelectedElements // Moves selected elements on the X/Y axis