-/** Because scriptaculous DnD sucks..
- Written by Mathew McBride <matt@mcbridematt.dhs.org> / <matt@comalies>
-*/
+/**
+ * Because scriptaculous DnD sucks..
+ * Written by Mathew McBride <matt@mcbridematt.dhs.org> / <matt@comalies>
+ *
+ * Copyright 2009 The Citadel Team
+ * Licensed under the GPL V3
+ */
var draggedElement = null;
var currentDropTargets = null;
var dropTarget = null;
var dragAndDropElement = null;
-
+var oldSelectHandler = null;
function mouseDownHandler(event) {
var target = event.target;
var actualTarget = target;
if (target.nodeName.toLowerCase() == "td") {
actualTarget = target.parentNode;
}
- if (!actualTarget.dropEnabled) {
+ if (!actualTarget.dropEnabled && actualTarget.getAttribute("citadel:dropenabled") == null) {
return;
}
turnOffTextSelect();
function mouseMoveHandler(event) {
if (draggedElement != null) {
if (dragAndDropElement == null) {
- dragAndDropElement = draggedElement.ctdlDnDElement();
- dragAndDropElement.setAttribute("class", "draganddrop");
+ var dragAndDropElementFunction = (draggedElement.ctdlDnDElement) ? draggedElement.ctdlDndElement : eval(draggedElement.getAttribute("citadel:dndelement"));
+ dragAndDropElement = dragAndDropElementFunction.call();
+ dragAndDropElement.className = "draganddrop";
document.body.appendChild(dragAndDropElement);
}
var clientX = event.clientX+5;
}
}
function setupDragDrop() {
-if (document.addEventListener != undefined) {
- $(document.body).observe('mousedown', mouseDownHandler);
+ $(document.body).observe('mousedown', mouseDownHandler);
$(document.body).observe('mouseup',mouseUpHandler);
$(document.body).observe('mousemove',mouseMoveHandler);
$(document.body).observe('mouseover', mouseMoveOver);
- $(document.body).observe('mouseout', mouseMoveOut);
- }
+ $(document.body).observe('mouseout', mouseMoveOut);
}
function turnOffTextSelect() {
document.onmousedown = new Function("return false");
-document.onmouseup = new Function("return true");
+ document.onmouseup = new Function("return true");
+ oldSelectHandler = document.onselectstart;
+ document.onselectstart = function() { return false; };
}
function turnOnTextSelect() {
document.onmousedown = null;
document.onmouseup = null;
+ document.onselectstart = oldSelectHandler;
}