diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2012-05-18 14:39:37 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2012-05-18 14:39:37 +0200 |
commit | 7b669ca2dd286de7875fd208b6e6047c8bfd4a1e (patch) | |
tree | 0a7fbedbb6aa2c85a469eae56e597eb4d5b752fe | |
parent | a0875731dc7b8bded86d6816925bdfdeff87805c (diff) |
Close title editor when leaving focus if title was not yet changed.
-rw-r--r-- | proto.js | 29 |
1 files changed, 14 insertions, 15 deletions
@@ -67,20 +67,6 @@ function idFromStr(str) return str.substring(str.search('t') + 1, str.length); } -function getElementsByClass(searchClass, domNode, tagName) { - if (domNode == null) domNode = document; - if (tagName == null) tagName = '*'; - var el = new Array(); - var tags = domNode.getElementsByTagName(tagName); - var tcl = " "+searchClass+" "; - for(i=0,j=0; i<tags.length; i++) { - var test = " " + tags[i].className + " "; - if (test.indexOf(tcl) != -1) - el[j++] = tags[i]; - } - return el; -} - function get_appropriate_ws_url() { var pcol; @@ -119,6 +105,7 @@ try { socket_task.onopen = function() { document.getElementById("wstask_status").style.backgroundColor = "#40ff40"; document.getElementById("wstask_status").textContent = "TaskProto websocket connection opened "; + socket_task.send("observe 0;"); } socket_task.onmessage = function got_packet(msg) { @@ -200,12 +187,13 @@ try { task.setAttribute("ondragover", "return false"); task.setAttribute("draggable", true); task.setAttribute("ondragstart", "drag(this, event)"); + task.setAttribute("title", id); task.id = createId(observeid, id); var txtdiv = document.createElement("div"); txtdiv.id = createId(observeid, id) + "_txt"; - var txt = document.createTextNode(createId(observeid, id)); + var txt = document.createTextNode(""); txtdiv.appendChild(txt); task.appendChild(txtdiv); @@ -286,6 +274,14 @@ function onKeyUpHandler(target, e) } } +function onLostFocusHandler(target, e) +{ + if(target.value == oldtitle) { + divtxt.removeChild(target); + oldtxt.nodeValue = oldtitle; + } +} + function editTitle(target, e) { e.stopPropagation(); @@ -298,6 +294,9 @@ function editTitle(target, e) oldtitle = oldtxt.nodeValue; oldtxt.nodeValue = ""; inp.setAttribute("onkeyup", "onKeyUpHandler(this, event)"); + inp.setAttribute("onblur", "onLostFocusHandler(this, event)"); + inp.setAttribute("style", "border: inherit; padding: inherit; margin: inherit; background: inherit;"); + inp.value = oldtitle; lineedit = inp; txtdiv.appendChild(inp); inp.focus(); |