summaryrefslogtreecommitdiff
path: root/src/ws/view.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/ws/view.js')
-rw-r--r--src/ws/view.js77
1 files changed, 69 insertions, 8 deletions
diff --git a/src/ws/view.js b/src/ws/view.js
index aa4d9de..1586389 100644
--- a/src/ws/view.js
+++ b/src/ws/view.js
@@ -83,7 +83,7 @@ function deleteNode(id)
function getElementAfter(e)
{
- if(!e.target.classList.contains("children"))
+ if(!e.target.classList || !e.target.classList.contains("children"))
{
return null;
}
@@ -121,7 +121,7 @@ var last_over = null;
function dragenter(e)
{
// Only highlight children areas
- if(!e.target.classList.contains("children"))
+ if(!e.target.classList || !e.target.classList.contains("children"))
{
return;
}
@@ -155,7 +155,7 @@ function dragover(e)
function dragleave(e)
{
// Only highlight children areas
- if(!e.target.classList.contains("children"))
+ if(!e.target.classList || !e.target.classList.contains("children"))
{
return;
}
@@ -172,7 +172,7 @@ function dragEnd(e)
update(idFromStr(id), "dragged", "false");
// // Only highlight children areas
-// if(!e.target.classList.contains("children"))
+// if(!e.target.classList || !e.target.classList.contains("children"))
// {
// return;
// }
@@ -199,7 +199,7 @@ function drop(e)
e.stopPropagation();
// Only allow drops in children areas
- if(!e.target.classList.contains("children"))
+ if(!e.target.classList || !e.target.classList.contains("children"))
{
return;
}
@@ -257,6 +257,64 @@ function node_submit_KeyUpHandler(target, e)
var updateid;
var lineedit;
var lineeditparent;
+
+function onKeyUpHandlerDesc(e)
+{
+ var node = findNodeFromString(e.target.id);
+ if(node == null)
+ {
+ return; // no node
+ }
+
+ var lineedit = e.target;
+ var updateid = idFromStr(lineedit.id);
+
+ if(e.which == 13)
+ { // enter
+ node.data_element.removeChild(lineedit);
+ update(updateid, "description", lineedit.value);
+ }
+ if(e.which == 27)
+ { // escape
+ node.data_element.removeChild(lineedit);
+ }
+}
+
+function onLostFocusHandlerDesc(e)
+{
+ var node = findNodeFromString(e.target.id);
+ if(node == null)
+ {
+ return; // no node
+ }
+
+ var lineedit = e.target;
+
+ node.data_element.removeChild(lineedit);
+}
+
+function editDescription(e)
+{
+ e.stopPropagation();
+ const idstr = e.target.parentElement.parentElement.id;
+ var node = findNodeFromString(idstr);
+ if(node == null)
+ {
+ return; // no node
+ }
+
+ var lineedit = document.createElement("input");
+ lineedit.setAttribute("class", "edit");
+ lineedit.setAttribute("onkeyup", "onKeyUpHandlerDesc(event)");
+ lineedit.setAttribute("onblur", "onLostFocusHandlerDesc(event)");
+ lineedit.placeholder = "Node Description";
+ lineedit.value = node.getDescription();
+ lineedit.id = idstr;
+ node.data_element.appendChild(lineedit);
+ //lineeditparent = e.target;
+ lineedit.focus();
+}
+
function onKeyUpHandler(e)
{
var node = findNodeFromString(e.target.id);
@@ -271,7 +329,6 @@ function onKeyUpHandler(e)
if(e.which == 13)
{ // enter
node.data_element.removeChild(lineedit);
- //node.data_element.nodeValue = 'updating...';
update(updateid, "title", lineedit.value);
}
if(e.which == 27)
@@ -296,7 +353,8 @@ function onLostFocusHandler(e)
function editTitle(e)
{
e.stopPropagation();
- var node = findNodeFromString(e.target.id);
+ const idstr = e.target.parentElement.parentElement.id;
+ var node = findNodeFromString(idstr);
if(node == null)
{
return; // no node
@@ -306,8 +364,9 @@ function editTitle(e)
lineedit.setAttribute("class", "edit");
lineedit.setAttribute("onkeyup", "onKeyUpHandler(event)");
lineedit.setAttribute("onblur", "onLostFocusHandler(event)");
+ lineedit.placeholder = "Node Title";
lineedit.value = node.getTitle();
- lineedit.id = e.target.id;
+ lineedit.id = idstr;
node.data_element.appendChild(lineedit);
//lineeditparent = e.target;
lineedit.focus();
@@ -338,10 +397,12 @@ function collapse(e)
if(collapsed)
{
node.element.classList.add('collapsed');
+ node.collapse_button.innerHTML = "▼";
}
else
{
node.element.classList.remove('collapsed');
+ node.collapse_button.innerHTML = "▲";
}
}