smartxml: Support for Node.object.describesParent property
[fnpeditor.git] / src / editor / modules / documentCanvas / canvas / genericElement.js
index 4bdc524..44615f5 100644 (file)
@@ -103,17 +103,19 @@ $.extend(generic, {
             referenceAction = 'after';
         }
       
-        if(event.type === 'nodeMoved') {
-            actionArg = utils.getElementForNode(event.meta.node, event.meta.parent);
-        } else {
+        if(event.meta.move) {
+            /* Let's check if this node had its own canvas element and it's accessible. */
+            actionArg = utils.getElementForElementRootNode(event.meta.node);
+            if(actionArg && actionArg.sameNode(referenceElement)) {
+                referenceElement = this.children()[nodeIndex];
+            }
+        }
+        if(!actionArg) {
             actionArg = event.meta.node;
         }
 
         referenceElement[referenceAction](actionArg);
     },
-    onNodeMoved: function(event) {
-        return this.onNodeAdded.call(this, event);
-    },
     onNodeDetached: function(event) {
         if(event.meta.node.sameNode(this)) {
             this.detach();