jquery.iedrag_wev8.js
1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
(function($){
$.fn.iedrag = function(option){
/*参数*/
var para = jQuery.extend({
handle: '.title'
}, option);
/*执行*/
$(this).each(function(){
var $this = $(this);
var $handle=$(this).find(para.handle);
$handle.css("cursor","move");
var posX=0;
var posY=0;
$handle[0].onmousedown=function(){
var srcItemHead=event.srcElement;
if(event.button!=1) return;
if(srcItemHead.tagName=="IMG") return;
if(srcItemHead.className=="operate") return;
$this.css({ position:"absolute"});
posX=event.clientX;
posY=event.clientY;
event.srcElement.dragDrop();
}
$handle[0].ondrag=function(){
var srcItemHead=event.srcElement;
/*if($this.css("left")=="auto"){
var right=parseInt($this.css("right"))-parseInt((event.clientX-posX));
var bottom=parseInt($this.css("bottom"))-parseInt((event.clientY-posY));
$this.css({right:right,bottom:bottom});
} else { */
var left=parseInt($this.css("left"))+parseInt((event.clientX-posX));
var top=parseInt($this.css("top"))+parseInt((event.clientY-posY));
if(top<0) top=0;
if(left<0) left=0;
$this.css({left:left,top:top});
//}
posX=event.clientX;
posY=event.clientY;
//Debug.log('posY:'+posY)
//if(posY<0) posY=0;
}
$handle[0].ondragend=function(){
}
});
};
})(jQuery);