From f30870347bfc9045d6643b6f92cae3da9e456ab8 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 14 Jun 2020 21:11:54 +0200 Subject: Edit description with double-click. Improve collapse/expand and add-child buttons. --- src/ws/node.js | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'src/ws/node.js') diff --git a/src/ws/node.js b/src/ws/node.js index 062f892..76ad7e3 100644 --- a/src/ws/node.js +++ b/src/ws/node.js @@ -167,53 +167,50 @@ Node.prototype.create = function() this.element.appendChild(this.children_element); - this.id_element = document.createElement("span"); + this.id_element = document.createElement("div"); this.id_element.setAttribute("class", "id"); var id_txt = document.createTextNode(this.id); this.id_element.appendChild(id_txt); this.data_element.appendChild(this.id_element); - this.title_element = document.createElement("span"); + this.title_element = document.createElement("div"); this.title_element.setAttribute("class", "title"); + this.title_element.setAttribute("ondblclick", "editTitle(event)"); this.data_element.appendChild(this.title_element); -// this.setAttribute("title", ""); var add_child_button = document.createElement("div"); add_child_button.name = "add_button"; add_child_button.setAttribute("onclick", "addChild(event)"); add_child_button.setAttribute("nodeid", this.id); add_child_button.setAttribute("class", "button"); - var txt_plus = document.createTextNode("+"); - add_child_button.appendChild(txt_plus); + add_child_button.innerHTML = "➕"; this.data_element.appendChild(add_child_button); - var collapse_button = document.createElement("div"); - collapse_button.name = "add_button"; - collapse_button.setAttribute("onclick", "collapse(event)"); - collapse_button.setAttribute("nodeid", this.id); - collapse_button.setAttribute("class", "button"); - var txt_v = document.createTextNode("v"); - collapse_button.appendChild(txt_v); - this.data_element.appendChild(collapse_button); + this.collapse_button = document.createElement("div"); + this.collapse_button.name = "add_button"; + this.collapse_button.setAttribute("onclick", "collapse(event)"); + this.collapse_button.setAttribute("nodeid", this.id); + this.collapse_button.setAttribute("class", "button"); + this.collapse_button.innerHTML = "▼"; + this.data_element.appendChild(this.collapse_button); this.state_element = document.createElement("div"); this.state_element.name = "state"; this.state_element.setAttribute("onclick", "changeState(event)"); this.state_element.setAttribute("nodeid", this.id); this.state_element.setAttribute("class", "state"); - var txt_state = document.createTextNode("todo"); - this.state_element.appendChild(txt_state); + this.state_element.innerHTML = "todo"; this.data_element.appendChild(this.state_element); this.description_element = document.createElement("div"); this.description_element.setAttribute("class", "description"); + this.description_element.setAttribute("ondblclick", "editDescription(event)"); this.data_element.appendChild(this.description_element); var node = this.element; node.name = "node"; node.setAttribute("class", "node"); - node.setAttribute("ondblclick", "editTitle(event)"); node.setAttribute("ondrop", "drop(event)"); node.setAttribute("ondragenter", "dragenter(event)"); node.setAttribute("ondragover", "dragover(event)"); @@ -230,13 +227,13 @@ Node.prototype.create = function() var collapsed = getCookie(node.id+"_collapsed") == "true"; if(collapsed) { - //this.children_element.style.maxHeight = "16px"; this.element.classList.add('collapsed'); + this.collapse_button.innerHTML = "▼"; } else { - //this.children_element.style.maxHeight = "inherit"; this.element.classList.remove('collapsed'); + this.collapse_button.innerHTML = "▲"; } } }; @@ -356,3 +353,12 @@ Node.prototype.getTitle = function() { return this.attributes["title"]; }; + +Node.prototype.getDescription = function() +{ + if(this.attributes["description"]) + { + return this.attributes["description"]; + } + return ""; +}; -- cgit v1.2.3