Commit 6be1b3f3 authored by Ujvari Gergely's avatar Ujvari Gergely

Fixes #230

parent 8d6710e4
......@@ -21,7 +21,10 @@ class Annotator.Plugin.Threading extends Annotator.Plugin
# Attach the thread to its parent, if any.
if annotation.references?.length
prev = annotation.references[annotation.references.length-1]
@annotator.threading.getContainer(prev).addChild thread
if annotation.created?
@annotator.threading.getContainer(prev).addChild thread
else
@annotator.threading.getContainer(prev).addChildToPos thread, 0
# Expose the thread to the annotation
Object.defineProperty annotation, 'thread',
......
......@@ -73,6 +73,12 @@
return top;
}
function addChildToPos(child, pos) {
if(child.parent) child.parent.removeChild(child);
this.children.splice(pos,0,child);
child.parent = this;
}
function addChild(child) {
if(child.parent) child.parent.removeChild(child);
this.children.push(child);
......@@ -104,6 +110,7 @@
getSpecificChild: getSpecificChild,
threadParent: threadParent,
addChild: addChild,
addChildToPos: addChildToPos,
removeChild: removeChild,
hasDescendant: hasDescendant
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment