From 83310e21ccedaf049a6765c1fd541edf25642274 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Sun, 11 Mar 2012 12:04:28 +0100 Subject: No possible to drag to body. --- proto.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/proto.js b/proto.js index f0aa571..2c29cde 100644 --- a/proto.js +++ b/proto.js @@ -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); +} + -- cgit v1.2.3