js或php代码,求分析
varDragObj=(function($){var_drag=false;varoevent=newFunction('e','if(!e)e=window.even...
var DragObj=(function($){
var _drag=false;
var oevent=new Function('e','if (!e) e = window.event;return e');
var templeft,temptop;
this.move=function(obj,option){
var x,y;
if(!option)option={};
obj.mousedown(function(e){
_drag=true;
if(option['onMouseDown']) option['onMouseDown'](e);
obj.css({position:"absolute"});
if(option['onwindow']){
var temp1=obj.offset().left;var temp2=obj.offset().top;
}
else{
var temp1=obj.position().left;var temp2=obj.position().top;
}
templeft = temp1;
temptop = temp2;
x=oevent(e).clientX;y=oevent(e).clientY;
$(document).mousemove(function(e){
if(!_drag)return false;
obj.css({left:(temp1+oevent(e).clientX-x)+"px",
top:(temp2+oevent(e).clientY-y)+"px",cursor:'move'});
if(option['onMouseMove']) option['onMouseMove'](e);
});
$(document).mouseup(function(e){_drag=false;if(option['onMouseUp']) option['onMouseUp'](e);});
});
obj.css({zIndex:1000,cursor:'move'});
};
this.cancel=function(obj){
obj.css({position:'inherit',left:templeft,top:temptop});
$(document).unbind('mousemove').unbind('mouseup');
};
this.enable=function(){
_drag=true;
};
this.disable=function(){
_drag=false;
};
this.isdraging=function(){
return _drag;
};
return this;
})(jQuery) 展开
var _drag=false;
var oevent=new Function('e','if (!e) e = window.event;return e');
var templeft,temptop;
this.move=function(obj,option){
var x,y;
if(!option)option={};
obj.mousedown(function(e){
_drag=true;
if(option['onMouseDown']) option['onMouseDown'](e);
obj.css({position:"absolute"});
if(option['onwindow']){
var temp1=obj.offset().left;var temp2=obj.offset().top;
}
else{
var temp1=obj.position().left;var temp2=obj.position().top;
}
templeft = temp1;
temptop = temp2;
x=oevent(e).clientX;y=oevent(e).clientY;
$(document).mousemove(function(e){
if(!_drag)return false;
obj.css({left:(temp1+oevent(e).clientX-x)+"px",
top:(temp2+oevent(e).clientY-y)+"px",cursor:'move'});
if(option['onMouseMove']) option['onMouseMove'](e);
});
$(document).mouseup(function(e){_drag=false;if(option['onMouseUp']) option['onMouseUp'](e);});
});
obj.css({zIndex:1000,cursor:'move'});
};
this.cancel=function(obj){
obj.css({position:'inherit',left:templeft,top:temptop});
$(document).unbind('mousemove').unbind('mouseup');
};
this.enable=function(){
_drag=true;
};
this.disable=function(){
_drag=false;
};
this.isdraging=function(){
return _drag;
};
return this;
})(jQuery) 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询