2 overlibmws_draggable.js plug-in module - Copyright Foteos Macrides 2002=2005
\r
3 For support of the DRAGGABLE feature.
\r
4 Initial: August 24, 2002 - Last Revised: January 12, 2005
\r
5 See the Change History and Command Reference for overlibmws via:
\r
7 http://www.macridesweb.com/oltest/
\r
9 Published under an open source license: http://www.macridesweb.com/oltest/license.html
\r
13 OLregCmds('draggable');
\r
15 // DEFAULT CONFIGURATION
\r
16 if(OLud('draggable'))var ol_draggable=0;
\r
17 // END CONFIGURATION
\r
19 var o3_draggable=0,o3_dragging=0,OLmMv,OLcX,OLcY,OLcbX,OLcbY;
\r
20 function OLloadDraggable(){OLload('draggable');}
\r
21 function OLparseDraggable(pf,i,ar){
\r
23 if(k<ar.length){if(Math.abs(ar[k])==DRAGGABLE){OLtoggle(ar[k],pf+'draggable');return k;}}
\r
27 function OLcheckDrag(){
\r
28 if(o3_draggable){if(o3_sticky&&(o3_frame==self))initDrag();else o3_draggable=0;}
\r
30 function initDrag(){
\r
31 OLmMv=OLdw.onmousemove;o3_dragging=0;
\r
32 if(OLns4){document.captureEvents(Event.MOUSEDOWN|Event.CLICK);
\r
33 document.onmousedown=OLgrabEl;;document.onclick=function(e){return routeEvent(e);}}
\r
34 else{over.onmousedown=OLgrabEl;OLsetDrgCur(1);}
\r
36 function OLsetDrgCur(d){if(!OLns4)over.style.cursor=(d?'move':'auto');}
\r
38 function OLgrabEl(e){
\r
40 var cKy=(OLns4?e.modifiers&Event.ALT_MASK:(!OLop7?e.altKey:e.ctrlKey));o3_dragging=1;
\r
41 if(cKy){OLsetDrgCur(0);document.onmouseup=function(){OLsetDrgCur(1);o3_dragging=0;}
\r
42 return(OLns4?routeEvent(e):true);}
\r
43 OLx=(e.pageX||e.clientX+OLfd().scrollLeft);OLy=(e.pageY||e.clientY+OLfd().scrollTop);
\r
44 if(OLie4)over.onselectstart=function(){return false;}
\r
45 if(OLns4){OLcX=OLx;OLcY=OLy;document.captureEvents(Event.MOUSEUP)}else{
\r
46 OLcX=OLx-(OLns4?over.left:parseInt(over.style.left));
\r
47 OLcY=OLy-(OLns4?over.top:parseInt(over.style.top));
\r
48 if((OLshadowPI)&&bkdrop&&o3_shadow){OLcbX=OLx-(parseInt(bkdrop.style.left));
\r
49 OLcbY=OLy-(parseInt(bkdrop.style.top));}}OLdw.onmousemove=OLmoveEl;
\r
50 document.onmouseup=function(){
\r
51 if(OLie4)over.onselectstart=null;o3_dragging=0;OLdw.onmousemove=OLmMv;}
\r
52 return(OLns4?routeEvent(e):false);
\r
55 function OLmoveEl(e){
\r
57 OLx=(e.pageX||e.clientX+OLfd().scrollLeft);OLy=(e.pageY||e.clientY+OLfd().scrollTop);
\r
58 if(o3_dragging){if(OLns4){over.moveBy(OLx-OLcX,OLy-OLcY);
\r
59 if(OLshadowPI&&bkdrop&&o3_shadow)bkdrop.moveBy(OLx-OLcX,OLy-OLcY);}
\r
60 else{OLrepositionTo(over,OLx-OLcX,OLy-OLcY);
\r
61 if((OLiframePI)&&OLie55&&OLifsP1)OLrepositionTo(OLifsP1,OLx-OLcX,OLy-OLcY);
\r
62 if((OLshadowPI)&&bkdrop&&o3_shadow){OLrepositionTo(bkdrop,OLx-OLcbX,OLy-OLcbY);
\r
63 if((OLiframePI)&&OLie55&&OLifsSh)OLrepositionTo(OLifsSh,OLx-OLcbX,OLy-OLcbY);}}
\r
64 if(OLhidePI)OLhideUtil(0,1,1,0,0,0);}if(OLns4){OLcX=OLx;OLcY=OLy;}
\r
68 function OLclearDrag(){
\r
69 if(OLns4){document.releaseEvents(Event.MOUSEDOWN|Event.MOUSEUP|Event.CLICK);
\r
70 document.onmousedown=document.onclick=null;}else{over.onmousedown=null;OLsetDrgCur(0);}
\r
71 document.onmouseup=null;o3_dragging=0;
\r
74 OLregRunTimeFunc(OLloadDraggable);
\r
75 OLregCmdLineFunc(OLparseDraggable);
\r