start: function(e, el, back) {
e = Event.get(e);
el.oldCssText = el.style.cssText;
var objXY = Dhtml.getObjectXY(el);
var startXY = Dhtml.getMouseXY(e);
var deltaXY = {};
deltaXY.x = startXY.x - objXY.x;
deltaXY.y = startXY.y - objXY.y;
Event.add(document, 'mousemove', move, true);
Event.add(document, 'mouseup', up, true);
try {
e.stopPropagation();
e.preventDefault();
} catch(ex) {
e.preventDefault = true;
}
function move(e) {
dragable = null;
var mouseXY = Dhtml.getMouseXY(e);
if (mouseXY.x < startXY.x - 5 ||
mouseXY.x > startXY.x + 5 ||
mouseXY.y < startXY.y - 5 ||
mouseXY.y > startXY.y + 5) {
dragable = el;
el.style.position = 'absolute';
el.style.opacity = '0.5';
el.style.filter = "alpha(opacity=50)";
el.style.left = (mouseXY.x - deltaXY.x) + "px";
el.style.top = (mouseXY.y - deltaXY.y) + 15 + "px";
try {
e.stopPropagation();
e.preventDefault();
} catch(ex) {
e.preventDefault = true;
Event.add(document, 'selectstart', function() {return false;});
Event.add(document, 'drag', function() {return false;});
}
}
}
function up(e) {
Event.remove(document, 'mousemove', move, true);
Event.remove(document, 'mouseup', up, true);
var top = el.style.top;
var left = el.style.left;
el.style.cssText = el.oldCssText;
el.oldCssText = null;
if (!back) {
el.style.top = top;
el.style.left = left;
}
try {
e.stopPropagation();
e.preventDefault();
} catch(ex) {
e.preventDefault = true;
Event.remove(document, 'selectstart', function() {return false;});
Event.remove(document, 'drag', function() {return false;});
}
}
}
}
0 comments:
Post a Comment