/* Copyright (c) 2008-2020, www.redips.net All rights reserved. Code licensed under the BSD License: http://www.redips.net/license/ http://www.redips.net/javascript/drag-and-drop-table-content/ Version 5.3.1 Dec 1, 2020. */ var REDIPS=REDIPS||{}; REDIPS.drag=function(){var t=null,T=/\bredips-drag\b/i,B=0,P=0,ua=null,va=null,U=[],C=null,W=0,X=0,Z=0,aa=0,ba=0,ca=0,ka,g=[],la,wa,A,da=[],w=[],H=null,M=null,ea=0,fa=0,Sa=0,Ta=0,oa=!1,Ea=!1,ma=!1,xa=[],ya,O,l=null,F=null,K=null,q=null,I=null,V=null,y=null,L=null,ha=null,k=!1,z=!1,D="cell",pa={div:{},divClass:{},cname:"redips-only",other:"deny"},Fa={action:"deny",cname:"redips-mark",exception:{},exceptionClass:{}},p={},Ua={keyDiv:!1,keyRow:!1,sendBack:!1,drop:!1};var Va=function(){return!1};var na= function(a){var b,c;g.length=0;var d=void 0===a?H.getElementsByTagName("table"):document.querySelectorAll(a);for(b=a=0;aa.rows.length-1&&(b=a.rows.length-1);var n=a.rows[b];var u=b;var x=n.parentNode;b=c.getElementsByTagName("tr")[0];c.remove();!1!==REDIPS.drag.event.rowDroppedBefore(m, h)&&(!d&&-1u?x.insertBefore(b,n):x.insertBefore(b,n.nextSibling):"after"===REDIPS.drag.rowDropMode?x.insertBefore(b,n.nextSibling):x.insertBefore(b,n):(x.appendChild(b),n=a.rows[0]), n&&n.redips&&n.redips.emptyRow?a.deleteRow(n.rowIndex):"overwrite"===REDIPS.drag.rowDropMode?e(n):"switch"!==REDIPS.drag.rowDropMode||A||(r.insertBefore(n,f),void 0!==f.redips&&delete f.redips.emptyRow),!d&&A||e(f),delete b.redips.emptyRow,d||REDIPS.drag.event.rowDropped(b,m,h)),0b.redips.offset[1]||cb.redips.offset[2]))k.remove(),G(k,!1),--da[z.id],REDIPS.drag.event.notCloned();else if(-1B-t[1]&&(k.style.left=B-(t[1]+t[3])+"px");d>P-t[2]&&(k.style.top=P-(t[0]+t[2])+"px")}wa=!0;"cell"===D&&(7t[3]&&ct[0]&&dM[3]&&dM[0]&&0===ba&&0===ca&&(w.containTable||cw[1]||dw[2])&&(sa(),Ma());if(REDIPS.drag.scroll.enable)for(W= b-(B/2>c?c-t[3]:B-c-t[1]),0b&&(W=b),e=Y()[0],W*=cW&&0>=e||0=ua-B||0!==ba++||(REDIPS.event.remove(window,"scroll",J),Na(window))):W=0,X=b-(P/2>d?d-t[0]:P-d-t[2]),0b&&(X=b),e=Y()[1],X*=d

X&&0>=e||0=va-P||0!==ca++||(REDIPS.event.remove(window,"scroll",J),Oa(window))):X=0,f=0;fe.offset[3]&&de.offset[0]){Z=b-(e.midstX>c?c-t[3]-e.offset[3]:e.offset[1]-c-t[1]);0b&&(Z=b),Z*=cd?d-t[0]-e.offset[0]:e.offset[2]-d-t[2]);0b&&(aa=b),aa*=dg[l].sca.offset[0]?b[0]:g[l].sca.offset[0],b[1]=b[1]g[l].sca.offset[3]?b[3]:g[l].sca.offset[3]),b[3]q||0>y?c():q!==a&&(w[0]=h[q][0],w[2]=w[0]+g[l].rows[q].cells[y].offsetHeight,(fw[2])&&c()); b=g[l].rows[q].cells[y];w.containTable=0M[3]&&cM[0]&&Ma());"object"===typeof a&&(C=a);C===window?(a=Y()[0],b=ua-B,c=W):(a=C.scrollLeft,b=C.scrollWidth-C.clientWidth,c=Z);0c&&0M[3]&&cM[0]&&Ma());"object"===typeof a&&(C=a);C===window?(a=Y()[1],b=va-P,c=X):(a=C.scrollTop,b=C.scrollHeight-C.clientHeight,c=aa);0c&&0=d&&(c=c.replace("redips-clone",""),2===e?(ta(!1,a),REDIPS.drag.event.clonedEnd2()):REDIPS.drag.event.clonedEnd1());a.className=qa(c)}};var Wa=function(a){var b=/\bredips-nodrag\b/i;if(a.srcElement){var c=a.srcElement.nodeName;a=a.srcElement.className}else c=a.target.nodeName,a=a.target.className;switch(c){case "A":case "INPUT":case "SELECT":case "OPTION":case "TEXTAREA":c= !0;break;default:c=b.test(a)}return c};var ta=function(a,b){var c,d=[],e=/\bredips-noautoscroll\b/i;var f=REDIPS.drag.style.opacityDisabled;if(!0===a||"init"===a){var h=REDIPS.drag.style.borderEnabled;var m="move";var r=!0}else h=REDIPS.drag.style.borderDisabled,m="auto",r=!1;void 0===b?d=H.getElementsByTagName("div"):"string"===typeof b?d=document.querySelectorAll(b):"object"!==typeof b||"DIV"===b.nodeName&&-1!==b.className.indexOf("redips-drag")?d[0]=b:d=b.getElementsByTagName("div");for(c=b=0;b< d.length;b++)if(T.test(d[b].className))"init"===a||void 0===d[b].redips?(d[b].redips={},d[b].redips.container=H):!0===a&&"number"===typeof f?(d[b].style.opacity="",d[b].style.filter=""):!1===a&&"number"===typeof f&&(d[b].style.opacity=f/100,d[b].style.filter="alpha(opacity="+f+")"),G(d[b],r),d[b].style.borderStyle=h,d[b].style.cursor=m,d[b].redips.enabled=r;else if("init"===a){var n=Q(d[b],"overflow");if("visible"!==n){REDIPS.event.add(d[b],"scroll",J);n=Q(d[b],"position");var u=N(d[b],n,!1);n=!e.test(d[b].className); U[c]={div:d[b],offset:u,midstX:(u[1]+u[3])/2,midstY:(u[0]+u[2])/2,autoscroll:n};u=d[b].getElementsByTagName("table");for(n=0;na[S]?(a[S]=b,a[ja]--):a[S]>b&&(a[S]=0,a[ja]++),v=x[a[0]+"-"+a[1]],void 0!==v&&(c=v),void 0!==n&&(d=n),void 0!==v&&void 0!==d||void 0!==c&&void 0!==n?(v=-1===c.className.indexOf(REDIPS.drag.mark.cname)? 0:1,n=-1===d.className.indexOf(REDIPS.drag.mark.cname)?0:1,f&&0===v&&1===n&&m(c),1===v?0===n&&(e=d):(0===v&&1===n&&(d=e),h(c,d))):f&&void 0!==c&&void 0===d&&(v=-1===c.className.indexOf(REDIPS.drag.mark.cname)?0:1,0===v&&m(c))}};var nb=function(a){var b=[],c={},d,e,f,h;var m=a.rows;for(d=0;dc&&(c=b)}return c};var hb=function(a,b){var c=(b.k1-b.k2*a)*(b.k1-b.k2*a);a+=REDIPS.drag.animation.step*(4-3*c)*b.direction;var d=b.m*a+b.b;"horizontal"=== b.type?(b.obj.style.left=a+"px",b.obj.style.top=d+"px"):(b.obj.style.left=d+"px",b.obj.style.top=a+"px");ab.last&&0>b.direction?setTimeout(function(){hb(a,b)},REDIPS.drag.animation.pause*c):(ab(b.obj),b.obj.redips&&(b.obj.redips.animated=!1),"cell"===b.mode?(!0===b.overwrite&&Ca(b.targetCell),b.targetCell.appendChild(b.obj),b.obj.redips&&!1!==b.obj.redips.enabled&&G(b.obj)):$a(Qa(b.target[0]),b.target[1],b.obj),"function"===typeof b.callback&&b.callback(b.obj))};var Ra=function(a){var b, c;var d=b=c=-1;if(void 0===a)d=lg[c].rows.length-1&&(d=g[c].rows.length-1);b.targetCell=g[c].rows[d].cells[a];"cell"===b.mode?(c=N(b.targetCell),d=c[1]-c[3],a=c[2]-c[0],e=c[3]+(d-e)/2,f=c[0]+(a-f)/2):(c=N(g[c].rows[d]),e=c[3],f=c[0]);c=e-h;a=f-m;b.obj.style.position="fixed";Math.abs(c)>Math.abs(a)?(b.type="horizontal",b.m=a/c,b.b=m-b.m*h,b.k1=(h+e)/(h-e),b.k2=2/(h-e),h>e&&(b.direction=-1),c=h,b.last=e):(b.type="vertical",b.m=c/a,b.b=h-b.m* m,b.k1=(m+f)/(m-f),b.k2=2/(m-f),m>f&&(b.direction=-1),c=m,b.last=f);b.obj.redips&&(b.obj.redips.animated=!0);hb(c,b);return[b.obj,b.objOld]}},shiftCells:Ja,deleteObject:eb,getPosition:Ra,rowOpacity:Ga,rowEmpty:function(a,b,c){a=document.getElementById(a).rows[b];void 0===c&&(c=REDIPS.drag.style.rowEmptyColor);void 0===a.redips&&(a.redips={});a.redips.emptyRow=!0;Ga(a,"empty",c)},getScrollPosition:Y,getStyle:Q,findParent:E,findCell:cb,event:{changed:function(){},clicked:function(){},cloned:function(){}, clonedDropped:function(){},clonedEnd1:function(){},clonedEnd2:function(){},dblClicked:function(){},deleted:function(){},dropped:function(){},droppedBefore:function(){},finish:function(){},moved:function(){},notCloned:function(){},notMoved:function(){},shiftOverflow:function(){},relocateBefore:function(){},relocateAfter:function(){},relocateEnd:function(){},rowChanged:function(){},rowClicked:function(){},rowCloned:function(){},rowDeleted:function(){},rowDropped:function(){},rowDroppedBefore:function(){}, rowDroppedSource:function(){},rowMoved:function(){},rowNotCloned:function(){},rowNotMoved:function(){},rowUndeleted:function(){},switched:function(){},undeleted:function(){}},error:{ajax:function(){},loadContent:function(){}}}}(); REDIPS.event||(REDIPS.event=function(){return{add:function(t,T,B){t.addEventListener?t.addEventListener(T,B,!1):t.attachEvent?t.attachEvent("on"+T,B):t["on"+T]=B},remove:function(t,T,B){t.removeEventListener?t.removeEventListener(T,B,!1):t.detachEvent?t.detachEvent("on"+T,B):t["on"+T]=null}}}());