From 9818ab31e050f9389e4ebf76ed3aea4c07a1e893 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 18 May 2012 14:52:20 +0200 Subject: Simple but messy hide/show functionality on child nodes. --- proto.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/proto.js b/proto.js index 5c7a1d5..b8873fe 100644 --- a/proto.js +++ b/proto.js @@ -183,6 +183,7 @@ try { task.name = "task"; task.setAttribute("class", "task"); task.setAttribute("ondblclick", "editTitle(this, event)"); + task.setAttribute("onclick", "showHideChildren(this, event)"); task.setAttribute("ondrop", "drop(this, event)"); task.setAttribute("ondragover", "return false"); task.setAttribute("draggable", true); @@ -254,6 +255,23 @@ function drop(target, e) { socket_task.send("move " + idFromStr(id) + " " + idFromStr(target.id) + ";"); } +function showHideChildren(target, e) +{ + e.stopPropagation(); + updateid = idFromStr(target.id); + if(target.style.backgroundColor != "red") { + target.style.backgroundColor = "red"; + for(var i = 1; i < target.childNodes.length; i++) { + target.childNodes[i].style.display = "none"; + } + } else { + target.style.backgroundColor = "grey"; + for(var i = 1; i < target.childNodes.length; i++) { + target.childNodes[i].style.display = "block"; + } + } +} + // // Butt ugly.. but hey! it works... // @@ -285,8 +303,8 @@ function onLostFocusHandler(target, e) function editTitle(target, e) { e.stopPropagation(); - updateid = idFromStr(target.id) - if(updateid < 10) return; + updateid = idFromStr(target.id); + if(updateid < 10) return; var inp = document.createElement("input"); var txtdiv = document.getElementById(target.id + "_txt"); divtxt = txtdiv; @@ -300,4 +318,4 @@ function editTitle(target, e) lineedit = inp; txtdiv.appendChild(inp); inp.focus(); -} \ No newline at end of file +} -- cgit v1.2.3