//FireFox 去除容器内拖拽图片问题
if (ev.preventDefault) {
ev.preventDefault();
ev.stopPropagation();
}
document.onmousemove = function(e) {
if (dragObj.moveable) {
var ev = e || window.event || Common.getEvent();
//IE 去除容器内拖拽图片问题
if (document.all) //IE
{
ev.returnValue = false;
}
var movePos = Common.getMousePos(ev);
dragDiv.style.left = Math.max(Math.min(movePos.x - dragObj.tmpX, dragObj.dragArea.maxRight), dragObj.dragArea.maxLeft) + "px";
dragDiv.style.top = Math.max(Math.min(movePos.y - dragObj.tmpY, dragObj.dragArea.maxBottom), dragObj.dragArea.maxTop) + "px";
var targetDiv = null;
for (var k = 0; k < dragObj.dragArray.length; k++) {
if (dragDiv == dragObj.dragArray[i]) {
continue;
}
if (movePos.x > dragObj.dragArray[k].PosLeft && movePos.x < dragObj.dragArray[k].PosLeft + dragObj.dragArray[k].PosWidth
&& movePos.y > dragObj.dragArray[k].PosTop && movePos.y < dragObj.dragArray[k].PosTop + dragObj.dragArray[k].PosHeight
) {
targetDiv = document.getElementById(dragObj.dragArray[k].DragId);
if (movePos.y < dragObj.dragArray[k].PosTop + dragObj.dragArray[k].PosHeight / 2) {
//往上移
dashedElement.style.width = targetDiv.offsetWidth - 2 * parseInt(dashedElement.style.borderWidth) + "px";
targetDiv.parentNode.insertBefore(dashedElement, targetDiv);
}
else {
//往下移
dashedElement.style.width = targetDiv.offsetWidth - 2 * parseInt(dashedElement.style.borderWidth) + "px";
if (targetDiv.nextSibling) {
targetDiv.parentNode.insertBefore(dashedElement, targetDiv.nextSibling);
}
else {
targetDiv.parentNode.appendChild(dashedElement);
}
}
}
}
for (j = 0; j < dragTbl.rows[0].cells.length; j++) {
var startLeft = Common.getElementPos(dragTbl.rows[0].cells[j]).x;
if (movePos.x > startLeft && movePos.x < startLeft + dragTbl.rows[0].cells[j].offsetWidth) {
///列无DIV
if (dragTbl.rows[0].cells[j].getElementsByTagName("div").length == 0) {
dashedElement.style.width = dragTbl.rows[0].cells[j].offsetWidth - 2 * parseInt(dashedElement.style.borderWidth) + "px";
dragTbl.rows[0].cells[j].appendChild(dashedElement);
}
else {
var posFirstChild = Common.getElementPos(Common.firstChild(dragTbl.rows[0].cells[j], "DIV"));
var posLastChild = Common.getElementPos(Common.lastChild(dragTbl.rows[0].cells[j], "DIV"));
//处理特殊情况:在最上/下面MOVE时不碰到现有DIV的情况下,又回到起始拖拽的列最上/下方
var tmpUp, tmpDown;
if (tmpObj.colId == j) {
tmpUp = tmpObj.firstChildUp;
tmpDown = tmpObj.lastChildDown;
}
else {
tmpUp = posFirstChild.y;
tmpDown = posLastChild.y + Common.lastChild(dragTbl.rows[0].cells[j], "DIV").offsetHeight;
}