diff options
author | Jonas Suhr Christensen <jsc@umbraculum.org> | 2012-03-11 12:04:28 +0100 |
---|---|---|
committer | Jonas Suhr Christensen <jsc@umbraculum.org> | 2012-03-11 12:04:28 +0100 |
commit | 83310e21ccedaf049a6765c1fd541edf25642274 (patch) | |
tree | 70aa01757784a689682012f3c0a3812e1a5d1b83 | |
parent | e0b372c0ba5748e378919e55900220112575b583 (diff) |
No possible to drag to body.
-rw-r--r-- | proto.js | 29 |
1 files changed, 26 insertions, 3 deletions
@@ -96,6 +96,11 @@ var socket_lm; var color = "#000000"; var dragged = ""; +document.body.setAttribute("ondrop", "dropInBody(event)"); +document.body.setAttribute("ondragenter", "return false"); +document.body.setAttribute("ondragover", "return false"); + + if (BrowserDetect.browser == "Firefox") { socket_lm = new MozWebSocket(get_appropriate_ws_url(), "lws-task-protocol"); } else { @@ -155,13 +160,18 @@ try { } else if(cmd == "move") { var id = msg[1]; - var parent_id = msg[2]; + var parent_id = msg[2]; // var left = msg[2]; // var top = msg[3]; var task = document.getElementById("task_" + id); - var parent_task = document.getElementById("task_" + parent_id); + if(parent_id != -1) { + var parent_task = document.getElementById("task_" + parent_id); + parent_task.appendChild(task); + } + else { + document.body.appendChild(task); + } // task.parentNode.removeChild(task); - parent_task.appendChild(task); // document.body.removeChild(task); // parent_task.appendChild(task); // task.style.left = left + "px"; @@ -307,3 +317,16 @@ function drop(target, e) { // target.appendChild(task); } +function dropInBody(e) { + e.preventDefault(); + e.stopPropagation(); + + var id = e.dataTransfer.getData('Text'); + var task = document.getElementById(id); +// task.parentNode.removeChild(task); +// alert("move " + id.substring(5, id.length) + " " + target.id.substring(5,target.id.length) + ";"); + socket_lm.send("move " + id.substring(5, id.length) + " -1;"); + +// target.appendChild(task); +} + |