| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- var Drag={
- "obj":null,
- "init":function(handle, dragBody, e){
- if (e == null) {
- handle.onmousedown=Drag.start;
- }
-
- handle.root = dragBody;
- if(isNaN(parseInt(handle.root.style.left)))handle.root.style.left="0px";
- if(isNaN(parseInt(handle.root.style.top)))handle.root.style.top="0px";
- handle.root.onDragStart=new Function();
- handle.root.onDragEnd=new Function();
- handle.root.onDrag=new Function();
- if (e !=null) {
- var handle=Drag.obj=handle;
- e=Drag.fixe(e);
- var top=parseInt(handle.root.style.top);
- var left=parseInt(handle.root.style.left);
- handle.root.onDragStart(left,top,e.pageX,e.pageY);
- handle.lastMouseX=e.pageX;
- handle.lastMouseY=e.pageY;
- document.onmousemove=Drag.drag;
- document.onmouseup=Drag.end;
- }
- },
- "start":function(e){
- var handle=Drag.obj=this;
- e=Drag.fixEvent(e);
- var top=parseInt(handle.root.style.top);
- var left=parseInt(handle.root.style.left);
- handle.root.onDragStart(left,top,e.pageX,e.pageY);
- handle.lastMouseX=e.pageX;
- handle.lastMouseY=e.pageY;
- handle.offsetX = e.offsetX;
- handle.offsetY = e.offsetY;
-
- var spanAll=$(handle.root.parentNode).find("span[class='icons icon-checked']");
- for(var i=0;i<spanAll.length;i++){
- var itemDiv=spanAll[i].parentNode;
- var top=parseInt(itemDiv.style.top);
- var left=parseInt(itemDiv.style.left);
- itemDiv.onDragStart(left,top,e.pageX,e.pageY);
-
- var h3=$(itemDiv).find("h3")[0];
- h3.lastMouseX=e.pageX;
- h3.lastMouseY=e.pageY;
- h3.offsetX = e.offsetX;
- h3.offsetY = e.offsetY;
-
- }
- document.onmousemove=Drag.drag;
- document.onmouseup=Drag.end;
- return false;
- },
- "drag":function(e){
- e=Drag.fixEvent(e);
- var handle=Drag.obj;
- var mouseY=e.pageY;
- var mouseX=e.pageX;
- handle.root.style.left=mouseX+(mouseX-handle.lastMouseX)-handle.offsetX +"px";
- handle.root.style.top=mouseY+(mouseY-handle.lastMouseY)-16+"px";
- //console.info("mouseY:"+(mouseX)+"lastMouseY:"+handle.lastMouseY);
- var top=parseInt(handle.root.style.top);
- var left=parseInt(handle.root.style.left);
- var currentLeft,currentTop;
- currentLeft=left+mouseX-handle.lastMouseX;
- currentTop=top+mouseY-handle.lastMouseY;
- handle.lastMouseX=mouseX;
- handle.lastMouseY=mouseY;
- handle.root.onDrag(currentLeft,currentTop+handle.root.column.scrollTop,e.pageX,e.pageY);
-
- var spanAll=$(handle.root.parentNode).find("span[class='icons icon-checked']");
- for(var i=0;i<spanAll.length;i++){
- var itemDiv=spanAll[i].parentNode;
- var h3=$(itemDiv).find("h3")[0];
-
- itemDiv.style.left=mouseX+(mouseX-h3.lastMouseX)-h3.offsetX +"px";
- itemDiv.style.top=mouseY+(mouseY-h3.lastMouseY)-16+"px";
-
- var top=parseInt(itemDiv.style.top);
- var left=parseInt(itemDiv.style.left);
- var currentLeft,currentTop;
- currentLeft=left+mouseX-h3.lastMouseX;
- currentTop=top+mouseY-h3.lastMouseY;
-
- h3.lastMouseX=mouseX;
- h3.lastMouseY=mouseY;
-
- itemDiv.onDrag(currentLeft,currentTop+itemDiv.column.scrollTop,e.pageX,e.pageY);
- }
-
- return false;
- },
- "end":function(e){
-
- var divlist = document.getElementById("second").getElementsByTagName("div");
-
- for(var i=0;i<divlist.length;i++){
- var classname = $(divlist[i]).attr("class");
- var tdname = $(divlist[i]).attr("tdname");
- //console.info("class:"+classname+";n:"+tdname);
- if((classname=="column"||$(divlist[i]).hasClass("column"))&&tdname=="1"){
-
- var childs = $(divlist[i]).find("div");
- //var childs = divlist[i].childNodes;
- console.info("length:"+childs.length);
- if(childs.length-1<1){
- divlist[i].style.height = 50+"px";
- }else{
- divlist[i].style.height="auto";
- }
- }
- }
- e=Drag.fixEvent(e);
- var mouseY=e.pageY;
- var mouseX=e.pageX;
- document.onmousemove=null;
- document.onmouseup=null;
-
- var spanAll=$(Drag.obj.root.parentNode).find("span[class='icons icon-checked']");
- for(var i=0;i<spanAll.length;i++){
- var itemDiv=spanAll[i].parentNode;
- itemDiv.onDragEnd(parseInt(Drag.obj.root.style.left),parseInt(Drag.obj.root.style.top),mouseX,mouseY);
- }
-
- Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style.left),parseInt(Drag.obj.root.style.top),mouseX,mouseY);
- Drag.obj=null;
- },
- "fixEvent":function(e){
- if(typeof e=="undefined")e=window.event;
- return e;
- }
- };
|