summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ws/node.js38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/ws/node.js b/src/ws/node.js
index 67d9372..424aa99 100644
--- a/src/ws/node.js
+++ b/src/ws/node.js
@@ -121,14 +121,7 @@ Node.prototype.addChild = function(node, insertBeforeId)
this.children_element.appendChild(node.element);
}
- if(this.childNodes.length > 0)
- {
- this.children_indicator_element.style.display = "inherit";
- }
- else
- {
- this.children_indicator_element.style.display = "none";
- }
+ this.updateAnnotations();
};
Node.prototype.removeChild = function(node)
@@ -140,14 +133,7 @@ Node.prototype.removeChild = function(node)
node.parent = null;
this.children_element.removeChild(node.element);
- if(this.childNodes.length > 0)
- {
- this.children_indicator_element.style.display = "inherit";
- }
- else
- {
- this.children_indicator_element.style.display = "none";
- }
+ this.updateAnnotations();
};
Node.prototype.create = function()
@@ -177,8 +163,6 @@ Node.prototype.create = function()
this.children_indicator_element = document.createElement("div");
this.children_indicator_element.className = "children_indicator";
- this.children_indicator_element.innerHTML = "⤷";
- this.children_indicator_element.style.display = "none";
annotation.appendChild(this.children_indicator_element);
this.data_element.appendChild(annotation);
@@ -249,6 +233,23 @@ Node.prototype.create = function()
}
};
+Node.prototype.updateAnnotations = function()
+{
+ var ann = "";
+
+ if(this.childNodes.length > 0)
+ {
+ ann += "⤷";
+ }
+
+ if(this.description_element.innerHTML != "")
+ {
+ ann += "…";
+ }
+
+ this.children_indicator_element.innerHTML = ann;
+};
+
//! Recursively set draggable property from node until root node.
Node.prototype.setDraggable = function(value)
{
@@ -340,6 +341,7 @@ Node.prototype.setAttribute = function(name, value)
this.description_element.innerHTML = marked(value);
makeClickthrough(this.description_element);
+ this.updateAnnotations();
}
if(name == "dragged")