summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2020-06-16 17:54:51 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2020-06-16 17:54:51 +0200
commitb6de2971a723d42b4ba46d7d6bc25127027a8967 (patch)
treebf4e8164f5a99085068fcf521fc8f6c6d2d1ad88 /src
parent2cf928d0af9674c7a4d20eed4c10494608157312 (diff)
Improve title and description editing.
Diffstat (limited to 'src')
-rw-r--r--src/ws/munia.css12
-rw-r--r--src/ws/view.js23
2 files changed, 11 insertions, 24 deletions
diff --git a/src/ws/munia.css b/src/ws/munia.css
index db030d6..4afc374 100644
--- a/src/ws/munia.css
+++ b/src/ws/munia.css
@@ -110,15 +110,11 @@ body
.node .edit
{
- border-color: red;
+ border: solid 1px red;
pointer-events: all;
- width: 90%
-/*
- border: inherit;
- padding: inherit;
- margin: inherit;
- background: inherit;
-*/
+ width: calc(100% - 0.5em);
+ margin: auto;
+ border-radius: 3px;
}
.node .button
diff --git a/src/ws/view.js b/src/ws/view.js
index 4be20aa..8ed5184 100644
--- a/src/ws/view.js
+++ b/src/ws/view.js
@@ -253,13 +253,6 @@ function node_submit_KeyUpHandler(target, e)
}
}
-//
-// Butt ugly.. but hey! it works...
-//
-var updateid;
-var lineedit;
-var lineeditparent;
-
function onKeyUpHandlerDesc(e)
{
var node = findNodeFromString(e.target.id);
@@ -271,7 +264,7 @@ function onKeyUpHandlerDesc(e)
var lineedit = e.target;
var updateid = idFromStr(lineedit.id);
- if(e.which == 13)
+ if(e.which == 13 && e.ctrlKey)
{ // enter
node.data_element.removeChild(lineedit);
update(updateid, "description", lineedit.value);
@@ -305,15 +298,15 @@ function editDescription(e)
return; // no node
}
- var lineedit = document.createElement("input");
- lineedit.setAttribute("class", "edit");
+ var lineedit = document.createElement("textarea");
+ lineedit.className = "edit";
+ lineedit.rows = 16;
lineedit.setAttribute("onkeyup", "onKeyUpHandlerDesc(event)");
lineedit.setAttribute("onblur", "onLostFocusHandlerDesc(event)");
- lineedit.placeholder = "Node Description";
+ lineedit.placeholder = "Node Description (Ctrl+enter to save, esc to discard)";
lineedit.value = node.getDescription();
lineedit.id = idstr;
node.data_element.appendChild(lineedit);
- //lineeditparent = e.target;
lineedit.focus();
}
@@ -354,7 +347,6 @@ function onLostFocusHandler(e)
function editTitle(e)
{
- console.log("!");
e.stopPropagation();
const idstr = e.target.parentElement.parentElement.id;
var node = findNodeFromString(idstr);
@@ -367,11 +359,10 @@ function editTitle(e)
lineedit.setAttribute("class", "edit");
lineedit.setAttribute("onkeyup", "onKeyUpHandler(event)");
lineedit.setAttribute("onblur", "onLostFocusHandler(event)");
- lineedit.placeholder = "Node Title";
+ lineedit.placeholder = "Node Title (Enter to save, esc to discard)";
lineedit.value = node.getTitle();
lineedit.id = idstr;
- node.data_element.appendChild(lineedit);
- //lineeditparent = e.target;
+ node.data_element.insertBefore(lineedit, node.description_element);
lineedit.focus();
}