G_DragDrop.js 6.3 KB

123456
  1. // Licensed Materials - Property of IBM
  2. // IBM Cognos Products: hal
  3. // (C) Copyright IBM Corp. 2003, 2017.
  4. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  5. var G_DragDrop={};G_DragDrop.K_iDragSize=G_BrowserInfo.M_bIsTouchDevice?20: 3;G_DragDrop.eEffectNone=0;G_DragDrop.eEffectCopy=1;G_DragDrop.eEffectMove=2;G_DragDrop.eEffectCopyOrMove=3;G_DragDrop.eEffectLink=4;G_DragDrop.eStateEnter=1;G_DragDrop.eStateOver=2;G_DragDrop.eStateLeave=3;G_DragDrop.eLocationNone=0;G_DragDrop.eLocationBefore=1;G_DragDrop.eLocationInside=2;G_DragDrop.eLocationAfter=4;G_DragDrop.eLocationBeforeOrAfter=5;G_DragDrop.eLocationReplace=8;G_DragDrop.F_ExceedsDragSize=function(_hN32,_hO32){return((Math.abs(_hN32)>this.K_iDragSize)||(Math.abs(_hO32)>this.K_iDragSize));};G_DragDrop.F_Start=function(_hJ41, _hL11, _hO92, _hO3, _h0J, _hFN, _hXX, _hYX, _hZX){this._hD4=_hO3?_hO3:this.eEffectCopy;this._hSV=this.eEffectNone;this._hGB2=_hO92;if(_hL11.F_OnDragStart(this._hGB2, this._hD4, _h0J)){var _hMP1={};if(G_BrowserInfo.M_bIsTouchDevice){_hMP1[G_BrowserInfo.M_bIsPointerEnabled?"onpointermove":"ontouchmove"]=this._hYA1.bind(this);_hMP1[G_BrowserInfo.M_bIsPointerEnabled?"onpointerup":"ontouchend"]=this._hYH1.bind(this);_hMP1[G_BrowserInfo.M_bIsPointerEnabled?"onpointercancel":"ontouchcancel"]=this._hYH1.bind(this);}else{_hMP1[G_BrowserInfo.M_bIsPointerEnabled?"onpointermove":"onmousemove"]=this._hTE1.bind(this);_hMP1[G_BrowserInfo.M_bIsPointerEnabled?"onpointerover":"onmouseover"]=this._hO91.bind(this);_hMP1[G_BrowserInfo.M_bIsPointerEnabled?"onpointerout":"onmouseout"]=this._hRG1.bind(this);_hMP1[G_BrowserInfo.M_bIsPointerEnabled?"onpointerup":"onmouseup"]=this._h3O1.bind(this);}if(!G_BrowserInfo.M_bIsTouchDevice||G_BrowserInfo.M_bIsPointerEnabled){_hMP1["onkeydown"]=this._h4O1.bind(this);_hMP1["onkeyup"]=this._hP32.bind(this);}_hMP1["onStopCapture"]=this._hSY.bind(this); this._hM11=true;G_CaptureManager.F_StartCapture(_hMP1);this._hN11=false;this._hVJ=!isNaN(_h0J)?_h0J:U_DOM.K_iLeftMouseButton;this._hZ71=_hJ41;this._hO11=_hL11;var doc=document;this._h0M1=(_hFN===null)&&(_hXX===null)&&(_hYX===null)&&(_hZX===null);if(!this._h0M1){this._h9Q=doc.getElementById(_hFN?_hFN:"idCursorNoDrop");this._hP11=doc.getElementById(_hXX?_hXX:"idCursorCopy");this._hQ11=doc.getElementById(_hYX?_hYX:"idCursorMove");this._hR11=doc.getElementById(_hZX?_hZX:"idCursorLink");}return true;}this._hGB2=null;return false;};G_DragDrop.F_IsInDragAndDrop=function(){return Boolean(this._hM11);};G_DragDrop.F_Stop=function(){if(!this._hM11){return;}G_CaptureManager.F_StopCapture();};G_DragDrop._hDS1=function(_h202){this._hSV=_h202;if(this._h0M1){return;}var _hES1;switch(_h202){case this.eEffectCopy:_hES1=this._hP11;break;case this.eEffectMove:_hES1=this._hQ11;break;case this.eEffectLink:_hES1=this._hR11;break;case this.eEffectNone:_hES1=this._h9Q;break;}if(this._hFS1!=_hES1){if(this._hFS1){_hES1.style.left=this._hFS1.style.left;_hES1.style.top=this._hFS1.style.top;this._hFS1.style.visibility="hidden";}_hES1.style.visibility="visible";this._hFS1=_hES1;}};G_DragDrop._hSY=function(){if(!this._hN11){this._hN11=true;this._hO11.F_OnDragCancel(this._hGB2);if(this._hZ71){this._hZ71.F_OnDragComplete(this.eEffectNone);}}this._hZ71=null;this._hO11=null;this._hGB2=null;this._hM11=false;if(this._hFS1){this._hFS1.style.visibility="hidden";this._hFS1=null;}this._h9Q=null;this._hP11=null;this._hQ11=null;this._hR11=null;};G_DragDrop._h1M1=function(e,_hR52){if(G_BrowserInfo.M_bIsFirefox){if((this._h2M1==e.clientX)&&(this._h3M1==e.clientY)){if(this._hUE1!=G_DragDrop.eEffectNone){return this._hUE1;}}else{this._h2M1=e.clientX;this._h3M1=e.clientY;}}if(this._hZ71&&this._hZ71.F_OnDragOver){this._hZ71.F_OnDragOver(e, _hR52);}var _hE4=this._hO11.F_OnDragOver(e, this._hGB2, this._hD4, _hR52, this._hVJ);var _h202=this.eEffectNone;if(_hE4){if(_hE4 & this.eEffectMove){if(e.ctrlKey&&(_hE4 & this.eEffectCopy)){_h202=this.eEffectCopy;}else{_h202=this.eEffectMove;}}else if(_hE4 & this.eEffectCopy){_h202=this.eEffectCopy;}else if(_hE4 & this.eEffectLink){_h202=this.eEffectLink;}}this._hDS1(_h202);this._hUE1=_h202;if(this._hFS1){var _hB92=e.clientX;var _hJC2=e.clientY;var _hSE2=e.target.ownerDocument?e.target.ownerDocument:((e.target.nodeName=="#document")?e.target:null);var _hGS1=_hSE2?_hSE2.defaultView:null;var _hGE2=_hGS1?_hGS1.frameElement:null;if(_hGE2&&_hGE2.ownerDocument==document){var _hVO1=U_DOM.F_GetRelativeOffset(_hGE2, document.body);_hB92+= _hVO1.left;_hJC2+= _hVO1.top;}this._hFS1.style.left=_hB92+"px";this._hFS1.style.top=_hJC2+"px";}};G_DragDrop._hYA1=function(e){if(G_BrowserInfo.M_bIsPointerEnabled){if((this._h2M1==e.clientX)&&(this._h3M1==e.clientY)){e.preventDefault();return;}this._h2M1=e.clientX;this._h3M1=e.clientY;}else if(e.touches.length!=1){this.F_Stop();return;}e.preventDefault();this._h1M1(e, this.eStateOver);};G_DragDrop._hYH1=function(e){e.preventDefault();var _h202=this._hO11.F_OnDragDrop(e, this._hGB2, this._hSV, this._hVJ);if(this._hZ71){this._hZ71.F_OnDragComplete(_h202);}this._hN11=true;this.F_Stop();};G_DragDrop._hTE1=function(e){if(!e.M_bIsElementFromPointEvent){this._h1M1(e, this.eStateOver);}};G_DragDrop._hO91=function(e){this._h1M1(e, this.eStateEnter);};G_DragDrop._hRG1=function(e){this._h1M1(e, this.eStateLeave);};G_DragDrop._h3O1=function(e){if(e.button==this._hVJ){var _h202=this._hO11.F_OnDragDrop(e, this._hGB2, this._hSV, this._hVJ);if(this._hZ71){this._hZ71.F_OnDragComplete(_h202);}this._hN11=true;this.F_Stop();}else{this.F_Stop();}};G_DragDrop._h4O1=function(e){if(e.keyCode==U_DOM.K_iKeyEscape){U_DOM.F_CancelEvent(e);this.F_Stop();}else if(e.ctrlKey&&(this._hSV==this.eEffectMove)&&(this._hD4 & this.eEffectCopy)){this._hDS1(this.eEffectCopy);}U_DOM.F_CancelKeyboardEvent(e);};G_DragDrop._hP32=function(e){if(!e.ctrlKey&&(this._hSV==this.eEffectCopy)&&(this._hD4 & this.eEffectMove)){this._hDS1(this.eEffectMove);}};G_DragDrop.F_GetCursorsHtml=function(){return('<img id="idCursorNoDrop" class="clsCursor" src="' + G_HAL.M_sPath + 'hal/images/cursor_nodrop.gif" alt=""/>' +'<img id="idCursorCopy" class="clsCursor" src="' + G_HAL.M_sPath + 'hal/images/cursor_copy.gif" alt=""/>' +'<img id="idCursorMove" class="clsCursor" src="' + G_HAL.M_sPath + 'hal/images/cursor_move.gif" alt=""/>' +'<img id="idCursorLink" class="clsCursor" src="' + G_HAL.M_sPath + 'hal/images/cursor_link.gif" alt=""/>' +'<img id="idCursorCustomFaded" class="clsCursorFaded" alt=""/>' );};