wordpress plugin, RT#75279
[freeside.git] / fs_selfservice / FS-SelfService / cgi / overlibmws_draggable.js
1 /*\r
2  overlibmws_draggable.js plug-in module - Copyright Foteos Macrides 2002-2008. All rights reserved.\r
3    For support of the DRAGGABLE feature.\r
4    Initial: August 24, 2002 - Last Revised: January 26, 2008\r
5  See the Change History and Command Reference for overlibmws via:\r
6 \r
7         http://www.macridesweb.com/oltest/\r
8 \r
9  Published under an open source license: http://www.macridesweb.com/oltest/license.html\r
10 */\r
11 \r
12 OLloaded=0;\r
13 var OLdraggableCmds='draggable,dragcap,dragid';\r
14 OLregCmds(OLdraggableCmds);\r
15 \r
16 // DEFAULT CONFIGURATION\r
17 if(OLud('draggable'))var ol_draggable=0;\r
18 if(OLud('dragcap'))var ol_dragcap=0;\r
19 if(OLud('dragid'))var ol_dragid='';\r
20 // END CONFIGURATION\r
21 \r
22 var o3_draggable=0,o3_dragcap=0,o3_dragid='',o3_dragging=0,OLdrg=null,OLmMv,\r
23 OLcX,OLcY,OLcbX,OLcbY;function OLloadDraggable(){OLload(OLdraggableCmds);}\r
24 function OLparseDraggable(pf,i,ar){var t=OLtoggle,k=i;if(k<ar.length){\r
25 if(Math.abs(ar[k])==DRAGGABLE){t(ar[k],pf+'draggable');return k;}\r
26 if(Math.abs(ar[k])==DRAGCAP){t(ar[k],pf+'dragcap');return k;}\r
27 if(ar[k]==DRAGID){OLparQuo(ar[++k],pf+'dragid');return k;}}return -1;\r
28 }\r
29 \r
30 function OLcheckDrag(){\r
31 if(o3_draggable){if(o3_sticky&&(o3_frame==self))OLinitDrag();else o3_draggable=0;}\r
32 }\r
33 function OLinitDrag(){\r
34 OLmMv=OLdw.onmousemove;o3_dragging=0;\r
35 if(OLns4){document.captureEvents(Event.MOUSEDOWN|Event.CLICK);\r
36 document.onmousedown=OLgrabEl;document.onclick=function(e){return routeEvent(e);}}\r
37 else{var dvido=(o3_dragid)?OLgetRef(o3_dragid):null,capid=(OLovertwoPI&&over==over2?\r
38 'overCap2':'overCap');if(dvido)dvido.onscroll=function(){OLdw.onmousemove=OLmMv;\r
39 OLinitDrag();};OLdrg=(o3_cap&&o3_dragcap)?OLgetRef(capid):over;\r
40 if(!OLdrg||!OLdrg.style)OLdrg=over;OLdrg.onmousedown=OLgrabEl;OLsetDrgCur(1);}\r
41 }\r
42 function OLsetDrgCur(d){if(!OLns4&&OLdrg)OLdrg.style.cursor=(d?'move':'auto');}\r
43 \r
44 function OLgrabEl(e){\r
45 var e=(e||event);\r
46 var cKy=(OLns4?e.modifiers&Event.ALT_MASK:(e.altKey||(OLop7&&e.ctrlKey)));o3_dragging=1;\r
47 if(cKy){OLsetDrgCur(0);document.onmouseup=function(){OLsetDrgCur(1);o3_dragging=0;}\r
48 return(OLns4?routeEvent(e):true);}\r
49 OLx=(e.pageX||e.clientX+OLfd().scrollLeft);OLy=(e.pageY||e.clientY+OLfd().scrollTop);\r
50 if(OLie4)over.onselectstart=function(){return false;}\r
51 if(OLns4){OLcX=OLx;OLcY=OLy;document.captureEvents(Event.MOUSEUP)}else{\r
52 OLcX=OLx-(OLns4?over.left:parseInt(over.style.left));\r
53 OLcY=OLy-(OLns4?over.top:parseInt(over.style.top));\r
54 if((OLshadowPI)&&bkdrop&&o3_shadow){OLcbX=OLx-(parseInt(bkdrop.style.left));\r
55 OLcbY=OLy-(parseInt(bkdrop.style.top));}}OLdw.onmousemove=OLmoveEl;\r
56 document.onmouseup=function(){\r
57 if(OLie4)over.onselectstart=null;o3_dragging=0;OLdw.onmousemove=OLmMv;}\r
58 return(OLns4?routeEvent(e):false);\r
59 }\r
60 \r
61 function OLmoveEl(e){\r
62 var e=(e||event);\r
63 OLx=(e.pageX||e.clientX+OLfd().scrollLeft);OLy=(e.pageY||e.clientY+OLfd().scrollTop);\r
64 if(o3_dragging){if(OLns4){over.moveBy(OLx-OLcX,OLy-OLcY);\r
65 if(OLshadowPI&&bkdrop&&o3_shadow)bkdrop.moveBy(OLx-OLcX,OLy-OLcY);}\r
66 else{OLrepositionTo(over,OLx-OLcX,OLy-OLcY);\r
67 if((OLiframePI)&&OLie55&&OLifsP1)OLrepositionTo(OLifsP1,OLx-OLcX,OLy-OLcY);\r
68 if((OLshadowPI)&&bkdrop&&o3_shadow){OLrepositionTo(bkdrop,OLx-OLcbX,OLy-OLcbY);\r
69 if((OLiframePI)&&OLie55&&OLifsSh)OLrepositionTo(OLifsSh,OLx-OLcbX,OLy-OLcbY);}}\r
70 if(OLhidePI)OLhideUtil(0,1,1,0,0,0);}if(OLns4){OLcX=OLx;OLcY=OLy;}\r
71 return false;\r
72 }\r
73 \r
74 function OLclearDrag(){\r
75 if(OLns4){document.releaseEvents(Event.MOUSEDOWN|Event.MOUSEUP|Event.CLICK);\r
76 document.onmousedown=document.onclick=null;}else{\r
77 if(OLdrg)OLdrg.onmousedown=null;over.onmousedown=null;OLsetDrgCur(0);}\r
78 document.onmouseup=null;o3_dragging=0;\r
79 }\r
80 \r
81 OLregRunTimeFunc(OLloadDraggable);\r
82 OLregCmdLineFunc(OLparseDraggable);\r
83 \r
84 OLdraggablePI=1;\r
85 OLloaded=1;\r