Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Version 5.0.8

- fixed bug (THEAD in table caused error when drag-n-drop table rows)
- thanks to James Ostrowick
  • Loading branch information...
commit 52449f5b85bb600d2f304861ec7a7e189df4b6c0 1 parent 705b739
Darko Bunic authored June 28, 2013
3  changes.txt
... ...
@@ -1,5 +1,8 @@
1 1
 Changes for REDIPS.drag library
2 2
 
  3
+5.0.8
  4
+- fixed bug (THEAD in table caused error when drag-n-drop table rows) - thanks to James Ostrowick
  5
+
3 6
 5.0.7
4 7
 - code optimization (reduced number call of getScrollPosition() in boxOffset() method)
5 8
 
2  index.html
@@ -36,7 +36,7 @@
36 36
 	<body>
37 37
 		<center>
38 38
 			<h2><a href="http://www.redips.net/javascript/drag-and-drop-table-content/" title="www.redips.net">REDIPS_drag</a> / <a href="http://www.redips.net/javascript/redips-drag-documentation/" title="REDIPS.drag documentation">Documentation</a> / <a href="http://www.redips.net/javascript/redips-drag-documentation-appendix-a/" title="REDIPS.drag documentation - Appendix A">Appendix A</a></h2>
39  
-			<h3>Drag and drop table content/rows with JavaScript - Version 5.0.7 (<a href="changes.txt">changes</a>)</h3>
  39
+			<h3>Drag and drop table content/rows with JavaScript - Version 5.0.8 (<a href="changes.txt">changes</a>)</h3>
40 40
 		</center>
41 41
 		<!-- tables inside this DIV could have draggable content -->
42 42
 		<div id="drag">
2  readme.md
Source Rendered
... ...
@@ -1,4 +1,4 @@
1  
-REDIPS.drag 5.0.7
  1
+REDIPS.drag 5.0.8
2 2
 ============
3 3
 
4 4
 ## What's REDIPS.drag?
120  redips-drag-min.js
@@ -2,69 +2,69 @@
2 2
 Copyright (c) 2008-2011, www.redips.net All rights reserved.
3 3
 Code licensed under the BSD License: http://www.redips.net/license/
4 4
 http://www.redips.net/javascript/drag-and-drop-table-content/
5  
-Version 5.0.7
6  
-May 29, 2013.
  5
+Version 5.0.8
  6
+Jun 28, 2013.
7 7
 */
8 8
 var REDIPS=REDIPS||{};
9  
-REDIPS.drag=function(){var q,B,K,Ba,Ma,Na,ca,da,ia,Ca,Da,V,ja,Ea,R,ka,Z,Fa,C,u,L,la,ma,na,Ga,oa,Ha,E,x,Ia,ea,fa,pa,Oa,Pa,Ja,qa,ra,sa,ga,Ka,Qa,ta,Ra,n=null,G=0,H=0,ua=null,va=null,M=[],s=null,N=0,O=0,P=0,Q=0,S=0,T=0,$,f=[],aa,wa,p,I=[],m=[],y=null,D=null,W=0,X=0,Sa=0,Ta=0,ha=!1,La=!1,ba=!1,xa=[],ya,h=null,t=null,z=null,j=null,v=null,J=null,k=null,A=null,U=null,i=!1,o=!1,r="cell",za={div:[],cname:"only",other:"deny"},Ua={action:"deny",cname:"mark",exception:[]},l={},Va={keyDiv:!1,keyRow:!1,sendBack:!1,
10  
-drop:!1};K=function(){return!1};q=function(a){var b,c,d,e,g;f.length=0;e=void 0===a?y.getElementsByTagName("table"):document.querySelectorAll(a);for(b=a=0;a<e.length;a++)if(!("redips_clone"===e[a].parentNode.id||-1<e[a].className.indexOf("nolayout"))){c=e[a].parentNode;d=0;do"TD"===c.nodeName&&d++,c=c.parentNode;while(c&&c!==y);f[b]=e[a];f[b].redips||(f[b].redips={});f[b].redips.container=y;f[b].redips.nestedLevel=d;f[b].redips.idx=b;xa[b]=0;d=f[b].getElementsByTagName("td");c=0;for(g=!1;c<d.length;c++)if(1<
11  
-d[c].rowSpan){g=!0;break}f[b].redips.rowspan=g;b++}a=0;for(e=aa=1;a<f.length;a++)if(0===f[a].redips.nestedLevel){f[a].redips.nestedGroup=e;f[a].redips.sort=100*aa;c=f[a].getElementsByTagName("table");for(b=0;b<c.length;b++)-1<c[b].className.indexOf("nolayout")||(c[b].redips.nestedGroup=e,c[b].redips.sort=100*aa+c[b].redips.nestedLevel);e++;aa++}};Ba=function(a){var b=a||window.event,c,d;if(!0===this.redips.animated)return!0;b.cancelBubble=!0;b.stopPropagation&&b.stopPropagation();La=b.shiftKey;a=
12  
-b.which?b.which:b.button;if(Ha(b)||!b.touches&&1!==a)return!0;if(window.getSelection)window.getSelection().removeAllRanges();else if(document.selection&&"Text"===document.selection.type)try{document.selection.empty()}catch(e){}b.touches?(a=W=b.touches[0].clientX,d=X=b.touches[0].clientY):(a=W=b.clientX,d=X=b.clientY);Sa=a;Ta=d;ha=!1;REDIPS.drag.objOld=o=i||this;REDIPS.drag.obj=i=this;ba=-1<i.className.indexOf("clone")?!0:!1;REDIPS.drag.tableSort&&Na(i);y!==i.redips.container&&(y=i.redips.container,
13  
-q());-1===i.className.indexOf("row")?REDIPS.drag.mode=r="cell":(REDIPS.drag.mode=r="row",REDIPS.drag.obj=i=ga(i));u();!ba&&"cell"===r&&(i.style.zIndex=999);h=j=k=null;R();z=t=h;J=v=j;U=A=k;REDIPS.drag.td.source=l.source=x("TD",i);REDIPS.drag.td.current=l.current=l.source;REDIPS.drag.td.previous=l.previous=l.source;"cell"===r?REDIPS.drag.event.clicked(l.current):REDIPS.drag.event.rowClicked(l.current);if(null===h||null===j||null===k)if(R(),z=t=h,J=v=j,U=A=k,null===h||null===j||null===k)return!0;wa=
14  
-p=!1;REDIPS.event.add(document,"mousemove",da);REDIPS.event.add(document,"touchmove",da);REDIPS.event.add(document,"mouseup",ca);REDIPS.event.add(document,"touchend",ca);i.setCapture&&i.setCapture();null!==h&&(null!==j&&null!==k)&&($=Fa(h,j,k));c=E(f[z],"position");"fixed"!==c&&(c=E(f[z].parentNode,"position"));c=C(i,c);n=[d-c[0],c[1]-a,c[2]-d,a-c[3]];y.onselectstart=function(a){b=a||window.event;if(!Ha(b)){b.shiftKey&&document.selection.clear();return false}};return!1};Ma=function(){REDIPS.drag.event.dblClicked()};
15  
-Na=function(a){var b;b=x("TABLE",a).redips.nestedGroup;for(a=0;a<f.length;a++)f[a].redips.nestedGroup===b&&(f[a].redips.sort=100*aa+f[a].redips.nestedLevel);f.sort(function(a,b){return b.redips.sort-a.redips.sort});aa++};ga=function(a,b){var c,d,e,g,f,w;if("DIV"===a.nodeName)return g=a,a=x("TR",a),void 0===a.redips&&(a.redips={}),a.redips.div=g,a;d=a;void 0===d.redips&&(d.redips={});a=x("TABLE",a);ba&&p&&(g=d.redips.div,g.className=ta(g.className.replace("clone","")));c=a.cloneNode(!0);ba&&p&&(g.className+=
16  
-" clone");e=c.rows.length-1;g="animated"===b?0===e?!0:!1:!0;for(f=e;0<=f;f--)if(f!==d.rowIndex){if(!0===g&&void 0===b){e=c.rows[f];for(w=0;w<e.cells.length;w++)if(-1<e.cells[w].className.indexOf("rowhandler")){g=!1;break}}c.deleteRow(f)}p||(d.redips.emptyRow=g);c.redips={};c.redips.container=a.redips.container;c.redips.sourceRow=d;Qa(d,c.rows[0]);Ga(d,c.rows[0]);document.getElementById("redips_clone").appendChild(c);d=C(d,"fixed");c.style.position="fixed";c.style.top=d[0]+"px";c.style.left=d[3]+"px";
17  
-c.style.width=d[1]-d[3]+"px";return c};Ka=function(a,b,c){var d=!1,e,g,Aa,w,j,F,Y,k;k=function(a){var b;void 0===a.redips||!a.redips.emptyRow?(b=x("TABLE",a),b.deleteRow(a.rowIndex)):sa(a,"empty",REDIPS.drag.style.rowEmptyColor)};void 0===c?c=i:d=!0;e=c.redips.sourceRow;g=e.rowIndex;Aa=x("TABLE",e);w=Aa.rows[0].parentNode;j=f[a];F=j.rows[b];Y=j.rows[0].parentNode;a=c.getElementsByTagName("tr")[0];c.parentNode.removeChild(c);!1!==REDIPS.drag.event.rowDroppedBefore(Aa,g)&&(!d&&-1<l.target.className.indexOf(REDIPS.drag.trash.className)?
18  
-p?REDIPS.drag.event.rowDeleted():REDIPS.drag.trash.questionRow?confirm(REDIPS.drag.trash.questionRow)?(k(e),REDIPS.drag.event.rowDeleted()):(delete o.redips.emptyRow,REDIPS.drag.event.rowUndeleted()):(k(e),REDIPS.drag.event.rowDeleted()):(b<j.rows.length?h===z?g>b?Y.insertBefore(a,F):Y.insertBefore(a,F.nextSibling):"after"===REDIPS.drag.rowDropMode?Y.insertBefore(a,F.nextSibling):Y.insertBefore(a,F):(Y.appendChild(a),F=j.rows[0]),F&&F.redips&&F.redips.emptyRow?Y.deleteRow(F.rowIndex):"overwrite"===
19  
-REDIPS.drag.rowDropMode?k(F):"switch"===REDIPS.drag.rowDropMode&&!p&&(w.insertBefore(F,e),void 0!==e.redips&&delete e.redips.emptyRow),(d||!p)&&k(e),delete a.redips.emptyRow,d||REDIPS.drag.event.rowDropped(a,Aa,g)),0<a.getElementsByTagName("table").length&&q())};Qa=function(a,b){var c,d,e,g=[],f=[];g[0]=a.getElementsByTagName("input");g[1]=a.getElementsByTagName("textarea");g[2]=a.getElementsByTagName("select");f[0]=b.getElementsByTagName("input");f[1]=b.getElementsByTagName("textarea");f[2]=b.getElementsByTagName("select");
20  
-for(c=0;c<g.length;c++)for(d=0;d<g[c].length;d++)switch(e=g[c][d].type,e){case "text":case "textarea":case "password":f[c][d].value=g[c][d].value;break;case "radio":case "checkbox":f[c][d].checked=g[c][d].checked;break;case "select-one":f[c][d].selectedIndex=g[c][d].selectedIndex;break;case "select-multiple":for(e=0;e<g[c][d].options.length;e++)f[c][d].options[e].selected=g[c][d].options[e].selected}};ca=function(a){var b=a||window.event,c,d,e,a=b.clientX;e=b.clientY;S=T=0;i.releaseCapture&&i.releaseCapture();
21  
-REDIPS.event.remove(document,"mousemove",da);REDIPS.event.remove(document,"touchmove",da);REDIPS.event.remove(document,"mouseup",ca);REDIPS.event.remove(document,"touchend",ca);y.onselectstart=null;Da(i);ua=document.documentElement.scrollWidth;va=document.documentElement.scrollHeight;S=T=0;if(p&&"cell"===r&&(null===h||null===j||null===k))i.parentNode.removeChild(i),I[o.id]-=1,REDIPS.drag.event.notCloned();else if(null===h||null===j||null===k)REDIPS.drag.event.notMoved();else{h<f.length?(b=f[h],REDIPS.drag.td.target=
22  
-l.target=b.rows[j].cells[k],Z(h,j,k,$),c=h,d=j):null===t||null===v||null===A?(b=f[z],REDIPS.drag.td.target=l.target=b.rows[J].cells[U],Z(z,J,U,$),c=z,d=J):(b=f[t],REDIPS.drag.td.target=l.target=b.rows[v].cells[A],Z(t,v,A,$),c=t,d=v);if("row"===r)if(wa)if(z===c&&J===d){b=i.getElementsByTagName("tr")[0];o.style.backgroundColor=b.style.backgroundColor;for(a=0;a<b.cells.length;a++)o.cells[a].style.backgroundColor=b.cells[a].style.backgroundColor;i.parentNode.removeChild(i);delete o.redips.emptyRow;p?
23  
-REDIPS.drag.event.rowNotCloned():REDIPS.drag.event.rowDroppedSource(l.target)}else Ka(c,d);else REDIPS.drag.event.rowNotMoved();else if(!p&&!ha)REDIPS.drag.event.notMoved();else if(p&&z===h&&J===j&&U===k)i.parentNode.removeChild(i),I[o.id]-=1,REDIPS.drag.event.notCloned();else if(p&&!1===REDIPS.drag.clone.drop&&(a<b.redips.offset[3]||a>b.redips.offset[1]||e<b.redips.offset[0]||e>b.redips.offset[2]))i.parentNode.removeChild(i),I[o.id]-=1,REDIPS.drag.event.notCloned();else if(-1<l.target.className.indexOf(REDIPS.drag.trash.className))i.parentNode.removeChild(i),
24  
-REDIPS.drag.trash.question?setTimeout(function(){if(confirm(REDIPS.drag.trash.question))Ca();else{if(!p){f[z].rows[J].cells[U].appendChild(i);u()}REDIPS.drag.event.undeleted()}},20):Ca();else if("switch"===REDIPS.drag.dropMode)if(a=REDIPS.drag.event.droppedBefore(l.target),!1===a)ia(!1);else{i.parentNode.removeChild(i);b=l.target.getElementsByTagName("div");c=b.length;for(a=0;a<c;a++)void 0!==b[0]&&(REDIPS.drag.objOld=o=b[0],l.source.appendChild(o),V(o));ia();c&&REDIPS.drag.event.switched()}else"overwrite"===
25  
-REDIPS.drag.dropMode?(a=REDIPS.drag.event.droppedBefore(l.target),!1!==a&&fa(l.target)):a=REDIPS.drag.event.droppedBefore(l.target),ia(a);"cell"===r&&0<i.getElementsByTagName("table").length&&q();u();REDIPS.drag.event.finish()}t=v=A=null};ia=function(a){var b=null,c;if(!1!==a){if(!0===Va.sendBack){a=l.target.getElementsByTagName("DIV");for(c=0;c<a.length;c++)if(i!==a[c]&&0===i.id.indexOf(a[c].id)){b=a[c];break}if(b){oa(b,1);i.parentNode.removeChild(i);return}}"shift"===REDIPS.drag.dropMode&&(Ra(l.target)||
26  
-"always"===REDIPS.drag.shift.after)&&pa(l.source,l.target);"top"===REDIPS.drag.multipleDrop&&l.target.hasChildNodes()?l.target.insertBefore(i,l.target.firstChild):l.target.appendChild(i);V(i);REDIPS.drag.event.dropped(l.target);p&&(REDIPS.drag.event.clonedDropped(l.target),oa(o,-1))}else p&&i.parentNode&&i.parentNode.removeChild(i)};V=function(a,b){!1===b?(a.onmousedown=null,a.ontouchstart=null,a.ondblclick=null):(a.onmousedown=Ba,a.ontouchstart=Ba,a.ondblclick=Ma)};Da=function(a){a.style.top="";
27  
-a.style.left="";a.style.position="";a.style.zIndex=""};Ca=function(){var a;p&&oa(o,-1);if("shift"===REDIPS.drag.dropMode&&("delete"===REDIPS.drag.shift.after||"always"===REDIPS.drag.shift.after)){switch(REDIPS.drag.shift.mode){case "vertical2":a="lastInColumn";break;case "horizontal2":a="lastInRow";break;default:a="last"}pa(l.source,Ia(a,l.source)[2])}REDIPS.drag.event.deleted(p)};da=function(a){var a=a||window.event,b=REDIPS.drag.scroll.bound,c,d,e,g;a.touches?(d=W=a.touches[0].clientX,e=X=a.touches[0].clientY):
28  
-(d=W=a.clientX,e=X=a.clientY);c=Math.abs(Sa-d);g=Math.abs(Ta-e);if(!wa){if("cell"===r&&(ba||!0===REDIPS.drag.clone.keyDiv&&La))REDIPS.drag.objOld=o=i,REDIPS.drag.obj=i=na(i,!0),p=!0,REDIPS.drag.event.cloned();else{if("row"===r){if(ba||!0===REDIPS.drag.clone.keyRow&&La)p=!0;REDIPS.drag.objOld=o=i;REDIPS.drag.obj=i=ga(i);i.style.zIndex=999}i.setCapture&&i.setCapture();i.style.position="fixed";u();R();"row"===r&&(p?REDIPS.drag.event.rowCloned():REDIPS.drag.event.rowMoved())}ka();d>G-n[1]&&(i.style.left=
29  
-G-(n[1]+n[3])+"px");e>H-n[2]&&(i.style.top=H-(n[0]+n[2])+"px")}wa=!0;if("cell"===r&&(7<c||7<g)&&!ha)ha=!0,ka(),REDIPS.drag.event.moved(p);d>n[3]&&d<G-n[1]&&(i.style.left=d-n[3]+"px");e>n[0]&&e<H-n[2]&&(i.style.top=e-n[0]+"px");if(d<D[1]&&d>D[3]&&e<D[2]&&e>D[0]&&0===S&&0===T&&(m.containTable||d<m[3]||d>m[1]||e<m[0]||e>m[2]))R(),ja();if(REDIPS.drag.scroll.enable){N=b-(G/2>d?d-n[3]:G-d-n[1]);if(0<N){if(N>b&&(N=b),c=L()[0],N*=d<G/2?-1:1,!(0>N&&0>=c||0<N&&c>=ua-G)&&0===S++)REDIPS.event.remove(window,"scroll",
30  
-u),la(window)}else N=0;O=b-(H/2>e?e-n[0]:H-e-n[2]);if(0<O){if(O>b&&(O=b),c=L()[1],O*=e<H/2?-1:1,!(0>O&&0>=c||0<O&&c>=va-H)&&0===T++)REDIPS.event.remove(window,"scroll",u),ma(window)}else O=0;for(g=0;g<M.length;g++)if(c=M[g],c.autoscroll&&d<c.offset[1]&&d>c.offset[3]&&e<c.offset[2]&&e>c.offset[0]){P=b-(c.midstX>d?d-n[3]-c.offset[3]:c.offset[1]-d-n[1]);0<P?(P>b&&(P=b),P*=d<c.midstX?-1:1,0===S++&&(REDIPS.event.remove(c.div,"scroll",u),la(c.div))):P=0;Q=b-(c.midstY>e?e-n[0]-c.offset[0]:c.offset[2]-e-
31  
-n[2]);0<Q?(Q>b&&(Q=b),Q*=e<c.midstY?-1:1,0===T++&&(REDIPS.event.remove(c.div,"scroll",u),ma(c.div))):Q=0;break}else P=Q=0}a.cancelBubble=!0;a.stopPropagation&&a.stopPropagation()};ja=function(){if(h<f.length&&(h!==t||j!==v||k!==A))null!==t&&(null!==v&&null!==A)&&(Z(t,v,A,$),REDIPS.drag.td.previous=l.previous=f[t].rows[v].cells[A],REDIPS.drag.td.current=l.current=f[h].rows[j].cells[k],"switching"===REDIPS.drag.dropMode&&"cell"===r&&(ea(l.current,l.previous),u(),R()),"cell"===r?REDIPS.drag.event.changed(l.current):
32  
-"row"===r&&(h!==t||j!==v)&&REDIPS.drag.event.rowChanged(l.current)),ka()};Ea=function(){if("number"===typeof window.innerWidth)G=window.innerWidth,H=window.innerHeight;else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight))G=document.documentElement.clientWidth,H=document.documentElement.clientHeight;else if(document.body&&(document.body.clientWidth||document.body.clientHeight))G=document.body.clientWidth,H=document.body.clientHeight;ua=document.documentElement.scrollWidth;
33  
-va=document.documentElement.scrollHeight;u()};R=function(){var a,b,c,d,e,g;c=[];a=function(){null!==t&&(null!==v&&null!==A)&&(h=t,j=v,k=A)};b=W;g=X;for(h=0;h<f.length;h++)if(!1!==f[h].redips.enabled&&(c[0]=f[h].redips.offset[0],c[1]=f[h].redips.offset[1],c[2]=f[h].redips.offset[2],c[3]=f[h].redips.offset[3],void 0!==f[h].sca&&(c[0]=c[0]>f[h].sca.offset[0]?c[0]:f[h].sca.offset[0],c[1]=c[1]<f[h].sca.offset[1]?c[1]:f[h].sca.offset[1],c[2]=c[2]<f[h].sca.offset[2]?c[2]:f[h].sca.offset[2],c[3]=c[3]>f[h].sca.offset[3]?
34  
-c[3]:f[h].sca.offset[3]),c[3]<b&&b<c[1]&&c[0]<g&&g<c[2])){c=f[h].redips.row_offset;for(j=0;j<c.length-1;j++)if(void 0!==c[j]){m[0]=c[j][0];if(void 0!==c[j+1])m[2]=c[j+1][0];else for(d=j+2;d<c.length;d++)if(void 0!==c[d]){m[2]=c[d][0];break}if(g<=m[2])break}d=j;j===c.length-1&&(m[0]=c[j][0],m[2]=f[h].redips.offset[2]);do for(k=e=f[h].rows[j].cells.length-1;0<=k&&!(m[3]=c[j][3]+f[h].rows[j].cells[k].offsetLeft,m[1]=m[3]+f[h].rows[j].cells[k].offsetWidth,m[3]<=b&&b<=m[1]);k--);while(f[h].redips.rowspan&&
35  
--1===k&&0<j--);0>j||0>k?a():j!==d&&(m[0]=c[j][0],m[2]=m[0]+f[h].rows[j].cells[k].offsetHeight,(g<m[0]||g>m[2])&&a());b=f[h].rows[j].cells[k];m.containTable=0<b.childNodes.length&&0<b.getElementsByTagName("table").length?!0:!1;if(-1===b.className.indexOf(REDIPS.drag.trash.className))if(g=-1<b.className.indexOf(REDIPS.drag.only.cname)?!0:!1,!0===g){if(-1===b.className.indexOf(za.div[i.id])){a();break}}else if(void 0!==za.div[i.id]&&"deny"===za.other){a();break}else if(g=-1<b.className.indexOf(REDIPS.drag.mark.cname)?
36  
-!0:!1,(!0===g&&"deny"===REDIPS.drag.mark.action||!1===g&&"allow"===REDIPS.drag.mark.action)&&-1===b.className.indexOf(Ua.exception[i.id])){a();break}g=-1<b.className.indexOf("single")?!0:!1;if("cell"===r){if(("single"===REDIPS.drag.dropMode||g)&&0<b.childNodes.length){if(1===b.childNodes.length&&3===b.firstChild.nodeType)break;g=!0;for(d=b.childNodes.length-1;0<=d;d--)if(b.childNodes[d].className&&-1<b.childNodes[d].className.indexOf("drag")){g=!1;break}if(!g&&(null!==t&&null!==v&&null!==A)&&(z!==
37  
-h||J!==j||U!==k)){a();break}}if(-1<b.className.indexOf("rowhandler")){a();break}if(b.parentNode.redips&&b.parentNode.redips.emptyRow){a();break}}break}};ka=function(){h<f.length&&(null!==h&&null!==j&&null!==k)&&($=Fa(h,j,k),Z(h,j,k),t=h,v=j,A=k)};Z=function(a,b,c,d){if("cell"===r&&ha)c=f[a].rows[b].cells[c].style,c.backgroundColor=void 0===d?REDIPS.drag.hover.colorTd:d.color[0].toString(),void 0!==REDIPS.drag.hover.borderTd&&(void 0===d?c.border=REDIPS.drag.hover.borderTd:(c.borderTopWidth=d.top[0][0],
  9
+REDIPS.drag=function(){var q,B,J,za,La,Ma,ba,ca,ha,Aa,Ba,U,ia,Ca,Q,ja,X,Da,C,u,K,ka,la,ma,Ea,na,Fa,E,x,Ga,da,ea,oa,Na,Oa,Ha,pa,qa,ra,fa,Ia,Pa,sa,Qa,o=null,F=0,G=0,ta=null,ua=null,L=[],s=null,M=0,N=0,O=0,P=0,R=0,S=0,Y,f=[],Z,va,p,H=[],n=[],y=null,D=null,V=0,W=0,Ra=0,Sa=0,ga=!1,Ja=!1,$=!1,wa=[],xa,j=null,t=null,z=null,h=null,v=null,I=null,k=null,A=null,T=null,i=!1,m=!1,r="cell",ya={div:[],cname:"only",other:"deny"},Ta={action:"deny",cname:"mark",exception:[]},l={},Ua={keyDiv:!1,keyRow:!1,sendBack:!1,
  10
+drop:!1};J=function(){return!1};q=function(a){var b,c,d,e,g;f.length=0;e=void 0===a?y.getElementsByTagName("table"):document.querySelectorAll(a);for(b=a=0;a<e.length;a++)if(!("redips_clone"===e[a].parentNode.id||-1<e[a].className.indexOf("nolayout"))){c=e[a].parentNode;d=0;do"TD"===c.nodeName&&d++,c=c.parentNode;while(c&&c!==y);f[b]=e[a];f[b].redips||(f[b].redips={});f[b].redips.container=y;f[b].redips.nestedLevel=d;f[b].redips.idx=b;wa[b]=0;d=f[b].getElementsByTagName("td");c=0;for(g=!1;c<d.length;c++)if(1<
  11
+d[c].rowSpan){g=!0;break}f[b].redips.rowspan=g;b++}a=0;for(e=Z=1;a<f.length;a++)if(0===f[a].redips.nestedLevel){f[a].redips.nestedGroup=e;f[a].redips.sort=100*Z;c=f[a].getElementsByTagName("table");for(b=0;b<c.length;b++)-1<c[b].className.indexOf("nolayout")||(c[b].redips.nestedGroup=e,c[b].redips.sort=100*Z+c[b].redips.nestedLevel);e++;Z++}};za=function(a){var b=a||window.event,c,d;if(!0===this.redips.animated)return!0;b.cancelBubble=!0;b.stopPropagation&&b.stopPropagation();Ja=b.shiftKey;a=b.which?
  12
+b.which:b.button;if(Fa(b)||!b.touches&&1!==a)return!0;if(window.getSelection)window.getSelection().removeAllRanges();else if(document.selection&&"Text"===document.selection.type)try{document.selection.empty()}catch(e){}b.touches?(a=V=b.touches[0].clientX,d=W=b.touches[0].clientY):(a=V=b.clientX,d=W=b.clientY);Ra=a;Sa=d;ga=!1;REDIPS.drag.objOld=m=i||this;REDIPS.drag.obj=i=this;$=-1<i.className.indexOf("clone")?!0:!1;REDIPS.drag.tableSort&&Ma(i);y!==i.redips.container&&(y=i.redips.container,q());-1===
  13
+i.className.indexOf("row")?REDIPS.drag.mode=r="cell":(REDIPS.drag.mode=r="row",REDIPS.drag.obj=i=fa(i));u();!$&&"cell"===r&&(i.style.zIndex=999);j=h=k=null;Q();z=t=j;I=v=h;T=A=k;REDIPS.drag.td.source=l.source=x("TD",i);REDIPS.drag.td.current=l.current=l.source;REDIPS.drag.td.previous=l.previous=l.source;"cell"===r?REDIPS.drag.event.clicked(l.current):REDIPS.drag.event.rowClicked(l.current);if(null===j||null===h||null===k)if(Q(),z=t=j,I=v=h,T=A=k,null===j||null===h||null===k)return!0;va=p=!1;REDIPS.event.add(document,
  14
+"mousemove",ca);REDIPS.event.add(document,"touchmove",ca);REDIPS.event.add(document,"mouseup",ba);REDIPS.event.add(document,"touchend",ba);i.setCapture&&i.setCapture();null!==j&&(null!==h&&null!==k)&&(Y=Da(j,h,k));c=E(f[z],"position");"fixed"!==c&&(c=E(f[z].parentNode,"position"));c=C(i,c);o=[d-c[0],c[1]-a,c[2]-d,a-c[3]];y.onselectstart=function(a){b=a||window.event;if(!Fa(b)){b.shiftKey&&document.selection.clear();return false}};return!1};La=function(){REDIPS.drag.event.dblClicked()};Ma=function(a){var b;
  15
+b=x("TABLE",a).redips.nestedGroup;for(a=0;a<f.length;a++)f[a].redips.nestedGroup===b&&(f[a].redips.sort=100*Z+f[a].redips.nestedLevel);f.sort(function(a,b){return b.redips.sort-a.redips.sort});Z++};fa=function(a,b){var c,d,e,g,f,w;if("DIV"===a.nodeName)return g=a,a=x("TR",a),void 0===a.redips&&(a.redips={}),a.redips.div=g,a;d=a;void 0===d.redips&&(d.redips={});a=x("TABLE",a);$&&p&&(g=d.redips.div,g.className=sa(g.className.replace("clone","")));c=a.cloneNode(!0);$&&p&&(g.className+=" clone");e=c.rows.length-
  16
+1;g="animated"===b?0===e?!0:!1:!0;for(f=e;0<=f;f--)if(f!==d.rowIndex){if(!0===g&&void 0===b){e=c.rows[f];for(w=0;w<e.cells.length;w++)if(-1<e.cells[w].className.indexOf("rowhandler")){g=!1;break}}c.deleteRow(f)}p||(d.redips.emptyRow=g);c.redips={};c.redips.container=a.redips.container;c.redips.sourceRow=d;Pa(d,c.rows[0]);Ea(d,c.rows[0]);document.getElementById("redips_clone").appendChild(c);d=C(d,"fixed");c.style.position="fixed";c.style.top=d[0]+"px";c.style.left=d[3]+"px";c.style.width=d[1]-d[3]+
  17
+"px";return c};Ia=function(a,b,c){var d=!1,e,g,Ka,w,h,k,aa,n;n=function(a){var b;void 0===a.redips||!a.redips.emptyRow?(b=x("TABLE",a),b.deleteRow(a.rowIndex)):ra(a,"empty",REDIPS.drag.style.rowEmptyColor)};void 0===c?c=i:d=!0;e=c.redips.sourceRow;g=e.rowIndex;Ka=x("TABLE",e);w=e.parentNode;a=f[a];b>a.rows.length-1&&(b=a.rows.length-1);h=a.rows[b];k=b;aa=h.parentNode;b=c.getElementsByTagName("tr")[0];c.parentNode.removeChild(c);!1!==REDIPS.drag.event.rowDroppedBefore(Ka,g)&&(!d&&-1<l.target.className.indexOf(REDIPS.drag.trash.className)?
  18
+p?REDIPS.drag.event.rowDeleted():REDIPS.drag.trash.questionRow?confirm(REDIPS.drag.trash.questionRow)?(n(e),REDIPS.drag.event.rowDeleted()):(delete m.redips.emptyRow,REDIPS.drag.event.rowUndeleted()):(n(e),REDIPS.drag.event.rowDeleted()):(k<a.rows.length?j===z?g>k?aa.insertBefore(b,h):aa.insertBefore(b,h.nextSibling):"after"===REDIPS.drag.rowDropMode?aa.insertBefore(b,h.nextSibling):aa.insertBefore(b,h):(aa.appendChild(b),h=a.rows[0]),h&&h.redips&&h.redips.emptyRow?a.deleteRow(h.rowIndex):"overwrite"===
  19
+REDIPS.drag.rowDropMode?n(h):"switch"===REDIPS.drag.rowDropMode&&!p&&(w.insertBefore(h,e),void 0!==e.redips&&delete e.redips.emptyRow),(d||!p)&&n(e),delete b.redips.emptyRow,d||REDIPS.drag.event.rowDropped(b,Ka,g)),0<b.getElementsByTagName("table").length&&q())};Pa=function(a,b){var c,d,e,g=[],f=[];g[0]=a.getElementsByTagName("input");g[1]=a.getElementsByTagName("textarea");g[2]=a.getElementsByTagName("select");f[0]=b.getElementsByTagName("input");f[1]=b.getElementsByTagName("textarea");f[2]=b.getElementsByTagName("select");
  20
+for(c=0;c<g.length;c++)for(d=0;d<g[c].length;d++)switch(e=g[c][d].type,e){case "text":case "textarea":case "password":f[c][d].value=g[c][d].value;break;case "radio":case "checkbox":f[c][d].checked=g[c][d].checked;break;case "select-one":f[c][d].selectedIndex=g[c][d].selectedIndex;break;case "select-multiple":for(e=0;e<g[c][d].options.length;e++)f[c][d].options[e].selected=g[c][d].options[e].selected}};ba=function(a){var b=a||window.event,c,d,e,a=b.clientX;e=b.clientY;R=S=0;i.releaseCapture&&i.releaseCapture();
  21
+REDIPS.event.remove(document,"mousemove",ca);REDIPS.event.remove(document,"touchmove",ca);REDIPS.event.remove(document,"mouseup",ba);REDIPS.event.remove(document,"touchend",ba);y.onselectstart=null;Ba(i);ta=document.documentElement.scrollWidth;ua=document.documentElement.scrollHeight;R=S=0;if(p&&"cell"===r&&(null===j||null===h||null===k))i.parentNode.removeChild(i),H[m.id]-=1,REDIPS.drag.event.notCloned();else if(null===j||null===h||null===k)REDIPS.drag.event.notMoved();else{j<f.length?(b=f[j],REDIPS.drag.td.target=
  22
+l.target=b.rows[h].cells[k],X(j,h,k,Y),c=j,d=h):null===t||null===v||null===A?(b=f[z],REDIPS.drag.td.target=l.target=b.rows[I].cells[T],X(z,I,T,Y),c=z,d=I):(b=f[t],REDIPS.drag.td.target=l.target=b.rows[v].cells[A],X(t,v,A,Y),c=t,d=v);if("row"===r)if(va)if(z===c&&I===d){b=i.getElementsByTagName("tr")[0];m.style.backgroundColor=b.style.backgroundColor;for(a=0;a<b.cells.length;a++)m.cells[a].style.backgroundColor=b.cells[a].style.backgroundColor;i.parentNode.removeChild(i);delete m.redips.emptyRow;p?
  23
+REDIPS.drag.event.rowNotCloned():REDIPS.drag.event.rowDroppedSource(l.target)}else Ia(c,d);else REDIPS.drag.event.rowNotMoved();else if(!p&&!ga)REDIPS.drag.event.notMoved();else if(p&&z===j&&I===h&&T===k)i.parentNode.removeChild(i),H[m.id]-=1,REDIPS.drag.event.notCloned();else if(p&&!1===REDIPS.drag.clone.drop&&(a<b.redips.offset[3]||a>b.redips.offset[1]||e<b.redips.offset[0]||e>b.redips.offset[2]))i.parentNode.removeChild(i),H[m.id]-=1,REDIPS.drag.event.notCloned();else if(-1<l.target.className.indexOf(REDIPS.drag.trash.className))i.parentNode.removeChild(i),
  24
+REDIPS.drag.trash.question?setTimeout(function(){if(confirm(REDIPS.drag.trash.question))Aa();else{if(!p){f[z].rows[I].cells[T].appendChild(i);u()}REDIPS.drag.event.undeleted()}},20):Aa();else if("switch"===REDIPS.drag.dropMode)if(a=REDIPS.drag.event.droppedBefore(l.target),!1===a)ha(!1);else{i.parentNode.removeChild(i);b=l.target.getElementsByTagName("div");c=b.length;for(a=0;a<c;a++)void 0!==b[0]&&(REDIPS.drag.objOld=m=b[0],l.source.appendChild(m),U(m));ha();c&&REDIPS.drag.event.switched()}else"overwrite"===
  25
+REDIPS.drag.dropMode?(a=REDIPS.drag.event.droppedBefore(l.target),!1!==a&&ea(l.target)):a=REDIPS.drag.event.droppedBefore(l.target),ha(a);"cell"===r&&0<i.getElementsByTagName("table").length&&q();u();REDIPS.drag.event.finish()}t=v=A=null};ha=function(a){var b=null,c;if(!1!==a){if(!0===Ua.sendBack){a=l.target.getElementsByTagName("DIV");for(c=0;c<a.length;c++)if(i!==a[c]&&0===i.id.indexOf(a[c].id)){b=a[c];break}if(b){na(b,1);i.parentNode.removeChild(i);return}}"shift"===REDIPS.drag.dropMode&&(Qa(l.target)||
  26
+"always"===REDIPS.drag.shift.after)&&oa(l.source,l.target);"top"===REDIPS.drag.multipleDrop&&l.target.hasChildNodes()?l.target.insertBefore(i,l.target.firstChild):l.target.appendChild(i);U(i);REDIPS.drag.event.dropped(l.target);p&&(REDIPS.drag.event.clonedDropped(l.target),na(m,-1))}else p&&i.parentNode&&i.parentNode.removeChild(i)};U=function(a,b){!1===b?(a.onmousedown=null,a.ontouchstart=null,a.ondblclick=null):(a.onmousedown=za,a.ontouchstart=za,a.ondblclick=La)};Ba=function(a){a.style.top="";
  27
+a.style.left="";a.style.position="";a.style.zIndex=""};Aa=function(){var a;p&&na(m,-1);if("shift"===REDIPS.drag.dropMode&&("delete"===REDIPS.drag.shift.after||"always"===REDIPS.drag.shift.after)){switch(REDIPS.drag.shift.mode){case "vertical2":a="lastInColumn";break;case "horizontal2":a="lastInRow";break;default:a="last"}oa(l.source,Ga(a,l.source)[2])}REDIPS.drag.event.deleted(p)};ca=function(a){var a=a||window.event,b=REDIPS.drag.scroll.bound,c,d,e,g;a.touches?(d=V=a.touches[0].clientX,e=W=a.touches[0].clientY):
  28
+(d=V=a.clientX,e=W=a.clientY);c=Math.abs(Ra-d);g=Math.abs(Sa-e);if(!va){if("cell"===r&&($||!0===REDIPS.drag.clone.keyDiv&&Ja))REDIPS.drag.objOld=m=i,REDIPS.drag.obj=i=ma(i,!0),p=!0,REDIPS.drag.event.cloned();else{if("row"===r){if($||!0===REDIPS.drag.clone.keyRow&&Ja)p=!0;REDIPS.drag.objOld=m=i;REDIPS.drag.obj=i=fa(i);i.style.zIndex=999}i.setCapture&&i.setCapture();i.style.position="fixed";u();Q();"row"===r&&(p?REDIPS.drag.event.rowCloned():REDIPS.drag.event.rowMoved())}ja();d>F-o[1]&&(i.style.left=
  29
+F-(o[1]+o[3])+"px");e>G-o[2]&&(i.style.top=G-(o[0]+o[2])+"px")}va=!0;if("cell"===r&&(7<c||7<g)&&!ga)ga=!0,ja(),REDIPS.drag.event.moved(p);d>o[3]&&d<F-o[1]&&(i.style.left=d-o[3]+"px");e>o[0]&&e<G-o[2]&&(i.style.top=e-o[0]+"px");if(d<D[1]&&d>D[3]&&e<D[2]&&e>D[0]&&0===R&&0===S&&(n.containTable||d<n[3]||d>n[1]||e<n[0]||e>n[2]))Q(),ia();if(REDIPS.drag.scroll.enable){M=b-(F/2>d?d-o[3]:F-d-o[1]);if(0<M){if(M>b&&(M=b),c=K()[0],M*=d<F/2?-1:1,!(0>M&&0>=c||0<M&&c>=ta-F)&&0===R++)REDIPS.event.remove(window,"scroll",
  30
+u),ka(window)}else M=0;N=b-(G/2>e?e-o[0]:G-e-o[2]);if(0<N){if(N>b&&(N=b),c=K()[1],N*=e<G/2?-1:1,!(0>N&&0>=c||0<N&&c>=ua-G)&&0===S++)REDIPS.event.remove(window,"scroll",u),la(window)}else N=0;for(g=0;g<L.length;g++)if(c=L[g],c.autoscroll&&d<c.offset[1]&&d>c.offset[3]&&e<c.offset[2]&&e>c.offset[0]){O=b-(c.midstX>d?d-o[3]-c.offset[3]:c.offset[1]-d-o[1]);0<O?(O>b&&(O=b),O*=d<c.midstX?-1:1,0===R++&&(REDIPS.event.remove(c.div,"scroll",u),ka(c.div))):O=0;P=b-(c.midstY>e?e-o[0]-c.offset[0]:c.offset[2]-e-
  31
+o[2]);0<P?(P>b&&(P=b),P*=e<c.midstY?-1:1,0===S++&&(REDIPS.event.remove(c.div,"scroll",u),la(c.div))):P=0;break}else O=P=0}a.cancelBubble=!0;a.stopPropagation&&a.stopPropagation()};ia=function(){if(j<f.length&&(j!==t||h!==v||k!==A))null!==t&&(null!==v&&null!==A)&&(X(t,v,A,Y),REDIPS.drag.td.previous=l.previous=f[t].rows[v].cells[A],REDIPS.drag.td.current=l.current=f[j].rows[h].cells[k],"switching"===REDIPS.drag.dropMode&&"cell"===r&&(da(l.current,l.previous),u(),Q()),"cell"===r?REDIPS.drag.event.changed(l.current):
  32
+"row"===r&&(j!==t||h!==v)&&REDIPS.drag.event.rowChanged(l.current)),ja()};Ca=function(){if("number"===typeof window.innerWidth)F=window.innerWidth,G=window.innerHeight;else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight))F=document.documentElement.clientWidth,G=document.documentElement.clientHeight;else if(document.body&&(document.body.clientWidth||document.body.clientHeight))F=document.body.clientWidth,G=document.body.clientHeight;ta=document.documentElement.scrollWidth;
  33
+ua=document.documentElement.scrollHeight;u()};Q=function(){var a,b,c,d,e,g;c=[];a=function(){null!==t&&(null!==v&&null!==A)&&(j=t,h=v,k=A)};b=V;g=W;for(j=0;j<f.length;j++)if(!1!==f[j].redips.enabled&&(c[0]=f[j].redips.offset[0],c[1]=f[j].redips.offset[1],c[2]=f[j].redips.offset[2],c[3]=f[j].redips.offset[3],void 0!==f[j].sca&&(c[0]=c[0]>f[j].sca.offset[0]?c[0]:f[j].sca.offset[0],c[1]=c[1]<f[j].sca.offset[1]?c[1]:f[j].sca.offset[1],c[2]=c[2]<f[j].sca.offset[2]?c[2]:f[j].sca.offset[2],c[3]=c[3]>f[j].sca.offset[3]?
  34
+c[3]:f[j].sca.offset[3]),c[3]<b&&b<c[1]&&c[0]<g&&g<c[2])){c=f[j].redips.row_offset;for(h=0;h<c.length-1;h++)if(void 0!==c[h]){n[0]=c[h][0];if(void 0!==c[h+1])n[2]=c[h+1][0];else for(d=h+2;d<c.length;d++)if(void 0!==c[d]){n[2]=c[d][0];break}if(g<=n[2])break}d=h;h===c.length-1&&(n[0]=c[h][0],n[2]=f[j].redips.offset[2]);do for(k=e=f[j].rows[h].cells.length-1;0<=k&&!(n[3]=c[h][3]+f[j].rows[h].cells[k].offsetLeft,n[1]=n[3]+f[j].rows[h].cells[k].offsetWidth,n[3]<=b&&b<=n[1]);k--);while(f[j].redips.rowspan&&
  35
+-1===k&&0<h--);0>h||0>k?a():h!==d&&(n[0]=c[h][0],n[2]=n[0]+f[j].rows[h].cells[k].offsetHeight,(g<n[0]||g>n[2])&&a());b=f[j].rows[h].cells[k];n.containTable=0<b.childNodes.length&&0<b.getElementsByTagName("table").length?!0:!1;if(-1===b.className.indexOf(REDIPS.drag.trash.className))if(g=-1<b.className.indexOf(REDIPS.drag.only.cname)?!0:!1,!0===g){if(-1===b.className.indexOf(ya.div[i.id])){a();break}}else if(void 0!==ya.div[i.id]&&"deny"===ya.other){a();break}else if(g=-1<b.className.indexOf(REDIPS.drag.mark.cname)?
  36
+!0:!1,(!0===g&&"deny"===REDIPS.drag.mark.action||!1===g&&"allow"===REDIPS.drag.mark.action)&&-1===b.className.indexOf(Ta.exception[i.id])){a();break}g=-1<b.className.indexOf("single")?!0:!1;if("cell"===r){if(("single"===REDIPS.drag.dropMode||g)&&0<b.childNodes.length){if(1===b.childNodes.length&&3===b.firstChild.nodeType)break;g=!0;for(d=b.childNodes.length-1;0<=d;d--)if(b.childNodes[d].className&&-1<b.childNodes[d].className.indexOf("drag")){g=!1;break}if(!g&&(null!==t&&null!==v&&null!==A)&&(z!==
  37
+j||I!==h||T!==k)){a();break}}if(-1<b.className.indexOf("rowhandler")){a();break}if(b.parentNode.redips&&b.parentNode.redips.emptyRow){a();break}}break}};ja=function(){j<f.length&&(null!==j&&null!==h&&null!==k)&&(Y=Da(j,h,k),X(j,h,k),t=j,v=h,A=k)};X=function(a,b,c,d){if("cell"===r&&ga)c=f[a].rows[b].cells[c].style,c.backgroundColor=void 0===d?REDIPS.drag.hover.colorTd:d.color[0].toString(),void 0!==REDIPS.drag.hover.borderTd&&(void 0===d?c.border=REDIPS.drag.hover.borderTd:(c.borderTopWidth=d.top[0][0],
38 38
 c.borderTopStyle=d.top[0][1],c.borderTopColor=d.top[0][2],c.borderRightWidth=d.right[0][0],c.borderRightStyle=d.right[0][1],c.borderRightColor=d.right[0][2],c.borderBottomWidth=d.bottom[0][0],c.borderBottomStyle=d.bottom[0][1],c.borderBottomColor=d.bottom[0][2],c.borderLeftWidth=d.left[0][0],c.borderLeftStyle=d.left[0][1],c.borderLeftColor=d.left[0][2]));else if("row"===r){a=f[a].rows[b];for(b=0;b<a.cells.length;b++)c=a.cells[b].style,c.backgroundColor=void 0===d?REDIPS.drag.hover.colorTr:d.color[b].toString(),
39  
-void 0!==REDIPS.drag.hover.borderTr&&(void 0===d?h===z?j<J?c.borderTop=REDIPS.drag.hover.borderTr:c.borderBottom=REDIPS.drag.hover.borderTr:"before"===REDIPS.drag.rowDropMode?c.borderTop=REDIPS.drag.hover.borderTr:c.borderBottom=REDIPS.drag.hover.borderTr:(c.borderTopWidth=d.top[b][0],c.borderTopStyle=d.top[b][1],c.borderTopColor=d.top[b][2],c.borderBottomWidth=d.bottom[b][0],c.borderBottomStyle=d.bottom[b][1],c.borderBottomColor=d.bottom[b][2]))}};Fa=function(a,b,c){var d={color:[],top:[],right:[],
  39
+void 0!==REDIPS.drag.hover.borderTr&&(void 0===d?j===z?h<I?c.borderTop=REDIPS.drag.hover.borderTr:c.borderBottom=REDIPS.drag.hover.borderTr:"before"===REDIPS.drag.rowDropMode?c.borderTop=REDIPS.drag.hover.borderTr:c.borderBottom=REDIPS.drag.hover.borderTr:(c.borderTopWidth=d.top[b][0],c.borderTopStyle=d.top[b][1],c.borderTopColor=d.top[b][2],c.borderBottomWidth=d.bottom[b][0],c.borderBottomStyle=d.bottom[b][1],c.borderBottomColor=d.bottom[b][2]))}};Da=function(a,b,c){var d={color:[],top:[],right:[],
40 40
 bottom:[],left:[]},e=function(a,b){var c="border"+b+"Style",d="border"+b+"Color";return[E(a,"border"+b+"Width"),E(a,c),E(a,d)]};if("cell"===r)c=f[a].rows[b].cells[c],d.color[0]=c.style.backgroundColor,void 0!==REDIPS.drag.hover.borderTd&&(d.top[0]=e(c,"Top"),d.right[0]=e(c,"Right"),d.bottom[0]=e(c,"Bottom"),d.left[0]=e(c,"Left"));else{a=f[a].rows[b];for(b=0;b<a.cells.length;b++)c=a.cells[b],d.color[b]=c.style.backgroundColor,void 0!==REDIPS.drag.hover.borderTr&&(d.top[b]=e(c,"Top"),d.bottom[b]=e(c,
41  
-"Bottom"))}return d};C=function(a,b,c){var d=0,e=0,g=a;"fixed"!==b&&(d=0-ya[0],e=0-ya[1]);if(void 0===c||!0===c){do d+=a.offsetLeft-a.scrollLeft,e+=a.offsetTop-a.scrollTop,a=a.offsetParent;while(a&&"BODY"!==a.nodeName)}else{do d+=a.offsetLeft,e+=a.offsetTop,a=a.offsetParent;while(a&&"BODY"!==a.nodeName)}return[e,d+g.offsetWidth,e+g.offsetHeight,d]};u=function(){var a,b,c,d;ya=L();for(a=0;a<f.length;a++){c=[];d=E(f[a],"position");"fixed"!==d&&(d=E(f[a].parentNode,"position"));for(b=f[a].rows.length-
42  
-1;0<=b;b--)"none"!==f[a].rows[b].style.display&&(c[b]=C(f[a].rows[b],d));f[a].redips.offset=C(f[a],d);f[a].redips.row_offset=c}D=C(y);for(a=0;a<M.length;a++)d=E(M[a].div,"position"),b=C(M[a].div,d,!1),M[a].offset=b,M[a].midstX=(b[1]+b[3])/2,M[a].midstY=(b[0]+b[2])/2};L=function(){var a,b;"number"===typeof window.pageYOffset?(a=window.pageXOffset,b=window.pageYOffset):document.body&&(document.body.scrollLeft||document.body.scrollTop)?(a=document.body.scrollLeft,b=document.body.scrollTop):document.documentElement&&
43  
-(document.documentElement.scrollLeft||document.documentElement.scrollTop)?(a=document.documentElement.scrollLeft,b=document.documentElement.scrollTop):a=b=0;return[a,b]};la=function(a){var b,c;b=W;c=X;0<S&&(u(),R(),b<D[1]&&(b>D[3]&&c<D[2]&&c>D[0])&&ja());"object"===typeof a&&(s=a);s===window?(a=L()[0],b=ua-G,c=N):(a=s.scrollLeft,b=s.scrollWidth-s.clientWidth,c=P);0<S&&(0>c&&0<a||0<c&&a<b)?(s===window?(window.scrollBy(c,0),L(),a=parseInt(i.style.left,10),isNaN(a)):s.scrollLeft+=c,setTimeout(la,REDIPS.drag.scroll.speed)):
44  
-(REDIPS.event.add(s,"scroll",u),S=0,m=[0,0,0,0])};ma=function(a){var b,c;b=W;c=X;0<T&&(u(),R(),b<D[1]&&(b>D[3]&&c<D[2]&&c>D[0])&&ja());"object"===typeof a&&(s=a);s===window?(a=L()[1],b=va-H,c=O):(a=s.scrollTop,b=s.scrollHeight-s.clientHeight,c=Q);0<T&&(0>c&&0<a||0<c&&a<b)?(s===window?(window.scrollBy(0,c),L(),a=parseInt(i.style.top,10),isNaN(a)):s.scrollTop+=c,setTimeout(ma,REDIPS.drag.scroll.speed)):(REDIPS.event.add(s,"scroll",u),T=0,m=[0,0,0,0])};na=function(a,b){var c=a.cloneNode(!0),d=c.className,
45  
-e,g;!0===b&&(document.getElementById("redips_clone").appendChild(c),c.style.zIndex=999,c.style.position="fixed",e=C(a),g=C(c),c.style.top=e[0]-g[0]+"px",c.style.left=e[3]-g[3]+"px");c.setCapture&&c.setCapture();d=d.replace("clone","");d=d.replace(/climit(\d)_(\d+)/,"");c.className=ta(d);void 0===I[a.id]&&(I[a.id]=0);c.id=a.id+"c"+I[a.id];I[a.id]+=1;Ga(a,c);return c};Ga=function(a,b){var c=[],d;c[0]=function(a,b){a.redips&&(b.redips={},b.redips.enabled=a.redips.enabled,b.redips.container=a.redips.container,
46  
-a.redips.enabled&&V(b))};c[1]=function(a,b){a.redips&&(b.redips={},b.redips.emptyRow=a.redips.emptyRow)};d=function(d){var g,f,w;f=["DIV","TR"];g=a.getElementsByTagName(f[d]);f=b.getElementsByTagName(f[d]);for(w=0;w<f.length;w++)c[d](g[w],f[w])};if("DIV"===a.nodeName)c[0](a,b);else if("TR"===a.nodeName)c[1](a,b);d(0);d(1)};oa=function(a,b){var c,d,e;e=a.className;c=e.match(/climit(\d)_(\d+)/);null!==c&&(d=parseInt(c[1],10),c=parseInt(c[2],10),0===c&&1===b&&(e+=" clone",2===d&&B(!0,a)),c+=b,e=e.replace(/climit\d_\d+/g,
47  
-"climit"+d+"_"+c),0>=c&&(e=e.replace("clone",""),2===d?(B(!1,a),REDIPS.drag.event.clonedEnd2()):REDIPS.drag.event.clonedEnd1()),a.className=ta(e))};Ha=function(a){var b=!1;a.srcElement?(b=a.srcElement.nodeName,a=a.srcElement.className):(b=a.target.nodeName,a=a.target.className);switch(b){case "A":case "INPUT":case "SELECT":case "OPTION":case "TEXTAREA":b=!0;break;default:b=/\bnodrag\b/i.test(a)?!0:!1}return b};B=function(a,b){var c,d,e,g=[],f=[],w,i,h,j,l=/\bdrag\b/i,k=/\bnoautoscroll\b/i;i=REDIPS.drag.style.opacityDisabled;
  41
+"Bottom"))}return d};C=function(a,b,c){var d=0,e=0,g=a;"fixed"!==b&&(d=0-xa[0],e=0-xa[1]);if(void 0===c||!0===c){do d+=a.offsetLeft-a.scrollLeft,e+=a.offsetTop-a.scrollTop,a=a.offsetParent;while(a&&"BODY"!==a.nodeName)}else{do d+=a.offsetLeft,e+=a.offsetTop,a=a.offsetParent;while(a&&"BODY"!==a.nodeName)}return[e,d+g.offsetWidth,e+g.offsetHeight,d]};u=function(){var a,b,c,d;xa=K();for(a=0;a<f.length;a++){c=[];d=E(f[a],"position");"fixed"!==d&&(d=E(f[a].parentNode,"position"));for(b=f[a].rows.length-
  42
+1;0<=b;b--)"none"!==f[a].rows[b].style.display&&(c[b]=C(f[a].rows[b],d));f[a].redips.offset=C(f[a],d);f[a].redips.row_offset=c}D=C(y);for(a=0;a<L.length;a++)d=E(L[a].div,"position"),b=C(L[a].div,d,!1),L[a].offset=b,L[a].midstX=(b[1]+b[3])/2,L[a].midstY=(b[0]+b[2])/2};K=function(){var a,b;"number"===typeof window.pageYOffset?(a=window.pageXOffset,b=window.pageYOffset):document.body&&(document.body.scrollLeft||document.body.scrollTop)?(a=document.body.scrollLeft,b=document.body.scrollTop):document.documentElement&&
  43
+(document.documentElement.scrollLeft||document.documentElement.scrollTop)?(a=document.documentElement.scrollLeft,b=document.documentElement.scrollTop):a=b=0;return[a,b]};ka=function(a){var b,c;b=V;c=W;0<R&&(u(),Q(),b<D[1]&&(b>D[3]&&c<D[2]&&c>D[0])&&ia());"object"===typeof a&&(s=a);s===window?(a=K()[0],b=ta-F,c=M):(a=s.scrollLeft,b=s.scrollWidth-s.clientWidth,c=O);0<R&&(0>c&&0<a||0<c&&a<b)?(s===window?(window.scrollBy(c,0),K(),a=parseInt(i.style.left,10),isNaN(a)):s.scrollLeft+=c,setTimeout(ka,REDIPS.drag.scroll.speed)):
  44
+(REDIPS.event.add(s,"scroll",u),R=0,n=[0,0,0,0])};la=function(a){var b,c;b=V;c=W;0<S&&(u(),Q(),b<D[1]&&(b>D[3]&&c<D[2]&&c>D[0])&&ia());"object"===typeof a&&(s=a);s===window?(a=K()[1],b=ua-G,c=N):(a=s.scrollTop,b=s.scrollHeight-s.clientHeight,c=P);0<S&&(0>c&&0<a||0<c&&a<b)?(s===window?(window.scrollBy(0,c),K(),a=parseInt(i.style.top,10),isNaN(a)):s.scrollTop+=c,setTimeout(la,REDIPS.drag.scroll.speed)):(REDIPS.event.add(s,"scroll",u),S=0,n=[0,0,0,0])};ma=function(a,b){var c=a.cloneNode(!0),d=c.className,
  45
+e,g;!0===b&&(document.getElementById("redips_clone").appendChild(c),c.style.zIndex=999,c.style.position="fixed",e=C(a),g=C(c),c.style.top=e[0]-g[0]+"px",c.style.left=e[3]-g[3]+"px");c.setCapture&&c.setCapture();d=d.replace("clone","");d=d.replace(/climit(\d)_(\d+)/,"");c.className=sa(d);void 0===H[a.id]&&(H[a.id]=0);c.id=a.id+"c"+H[a.id];H[a.id]+=1;Ea(a,c);return c};Ea=function(a,b){var c=[],d;c[0]=function(a,b){a.redips&&(b.redips={},b.redips.enabled=a.redips.enabled,b.redips.container=a.redips.container,
  46
+a.redips.enabled&&U(b))};c[1]=function(a,b){a.redips&&(b.redips={},b.redips.emptyRow=a.redips.emptyRow)};d=function(d){var g,f,w;f=["DIV","TR"];g=a.getElementsByTagName(f[d]);f=b.getElementsByTagName(f[d]);for(w=0;w<f.length;w++)c[d](g[w],f[w])};if("DIV"===a.nodeName)c[0](a,b);else if("TR"===a.nodeName)c[1](a,b);d(0);d(1)};na=function(a,b){var c,d,e;e=a.className;c=e.match(/climit(\d)_(\d+)/);null!==c&&(d=parseInt(c[1],10),c=parseInt(c[2],10),0===c&&1===b&&(e+=" clone",2===d&&B(!0,a)),c+=b,e=e.replace(/climit\d_\d+/g,
  47
+"climit"+d+"_"+c),0>=c&&(e=e.replace("clone",""),2===d?(B(!1,a),REDIPS.drag.event.clonedEnd2()):REDIPS.drag.event.clonedEnd1()),a.className=sa(e))};Fa=function(a){var b=!1;a.srcElement?(b=a.srcElement.nodeName,a=a.srcElement.className):(b=a.target.nodeName,a=a.target.className);switch(b){case "A":case "INPUT":case "SELECT":case "OPTION":case "TEXTAREA":b=!0;break;default:b=/\bnodrag\b/i.test(a)?!0:!1}return b};B=function(a,b){var c,d,e,g=[],f=[],w,i,h,j,l=/\bdrag\b/i,k=/\bnoautoscroll\b/i;i=REDIPS.drag.style.opacityDisabled;
48 48
 !0===a||"init"===a?(w=REDIPS.drag.style.borderEnabled,h="move",j=!0):(w=REDIPS.drag.style.borderDisabled,h="auto",j=!1);void 0===b?g=y.getElementsByTagName("div"):"string"===typeof b?g=document.querySelectorAll(b):"object"===typeof b&&("DIV"!==b.nodeName||-1===b.className.indexOf("drag"))?g=b.getElementsByTagName("div"):g[0]=b;for(d=c=0;c<g.length;c++)if(l.test(g[c].className))"init"===a||void 0===g[c].redips?(g[c].redips={},g[c].redips.container=y):!0===a&&"number"===typeof i?(g[c].style.opacity=
49  
-"",g[c].style.filter=""):!1===a&&"number"===typeof i&&(g[c].style.opacity=i/100,g[c].style.filter="alpha(opacity="+i+")"),V(g[c],j),g[c].style.borderStyle=w,g[c].style.cursor=h,g[c].redips.enabled=j;else if("init"===a&&(e=E(g[c],"overflow"),"visible"!==e)){REDIPS.event.add(g[c],"scroll",u);e=E(g[c],"position");f=C(g[c],e,!1);e=k.test(g[c].className)?!1:!0;M[d]={div:g[c],offset:f,midstX:(f[1]+f[3])/2,midstY:(f[0]+f[2])/2,autoscroll:e};f=g[c].getElementsByTagName("table");for(e=0;e<f.length;e++)f[e].sca=
50  
-M[d];d++}};E=function(a,b){var c;a&&a.currentStyle?c=a.currentStyle[b]:a&&window.getComputedStyle&&(c=document.defaultView.getComputedStyle(a,null)[b]);return c};x=function(a,b,c){b=b.parentNode;for(void 0===c&&(c=0);b&&b.nodeName!==a;)if((b=b.parentNode)&&b.nodeName===a&&0<c)c--,b=b.parentNode;return b};Ia=function(a,b){var c=x("TABLE",b),d,e;switch(a){case "firstInColumn":d=0;e=b.cellIndex;break;case "firstInRow":d=b.parentNode.rowIndex;e=0;break;case "lastInColumn":d=c.rows.length-1;e=b.cellIndex;
51  
-break;case "lastInRow":d=b.parentNode.rowIndex;e=c.rows[d].cells.length-1;break;case "last":d=c.rows.length-1;e=c.rows[d].cells.length-1;break;default:d=e=0}return[d,e,c.rows[d].cells[e]]};ea=function(a,b,c){var d,e,g;d=function(a,b){REDIPS.drag.event.relocateBefore(a,b);var c=REDIPS.drag.getPosition(b);REDIPS.drag.moveObject({obj:a,target:c,callback:function(a){var c=REDIPS.drag.findParent("TABLE",a),d=c.redips.idx;REDIPS.drag.event.relocateAfter(a,b);xa[d]--;0===xa[d]&&(REDIPS.drag.event.relocateEnd(),
52  
-REDIPS.drag.enableTable(!0,c))}})};if(a!==b&&!("object"!==typeof a||"object"!==typeof b))if(g=a.childNodes.length,"animation"===c){if(0<g){c=x("TABLE",b);e=c.redips.idx;REDIPS.drag.enableTable(!1,c);for(c=0;c<g;c++)1===a.childNodes[c].nodeType&&"DIV"===a.childNodes[c].nodeName&&(xa[e]++,d(a.childNodes[c],b))}}else for(d=c=0;c<g;c++)1===a.childNodes[d].nodeType&&"DIV"===a.childNodes[d].nodeName?(e=a.childNodes[d],REDIPS.drag.event.relocateBefore(e,b),b.appendChild(e),e.redips&&!1!==e.redips.enabled&&
53  
-V(e),REDIPS.drag.event.relocateAfter(e)):d++};fa=function(a,b){var c,d=[],e;if("TD"===a.nodeName){c=a.childNodes.length;if("test"===b)return c=l.source===a?void 0:0===a.childNodes.length||1===a.childNodes.length&&3===a.firstChild.nodeType?!0:!1;for(e=0;e<c;e++)d.push(a.childNodes[0]),a.removeChild(a.childNodes[0]);return d}};pa=function(a,b){var c,d,e,g,f,i,h,j,k,o,m,n,p=!1,q,r;q=function(a,b){REDIPS.drag.shift.animation?ea(a,b,"animation"):ea(a,b)};r=function(a){"delete"===REDIPS.drag.shift.overflow?
54  
-fa(a):"source"===REDIPS.drag.shift.overflow?q(a,l.source):"object"===typeof REDIPS.drag.shift.overflow&&q(a,REDIPS.drag.shift.overflow);p=!1;REDIPS.drag.event.shiftOverflow(a)};if(a!==b){f=REDIPS.drag.shift.mode;c=x("TABLE",a);d=x("TABLE",b);i=Oa(d);e=c===d?[a.redips.rowIndex,a.redips.cellIndex]:[-1,-1];g=[b.redips.rowIndex,b.redips.cellIndex];m=d.rows.length;n=Pa(d);switch(f){case "vertical2":c=c===d&&a.redips.cellIndex===b.redips.cellIndex?e:[m,b.redips.cellIndex];break;case "horizontal2":c=c===
55  
-d&&a.parentNode.rowIndex===b.parentNode.rowIndex?e:[b.redips.rowIndex,n];break;default:c=c===d?e:[m,n]}"vertical1"===f||"vertical2"===f?(f=1E3*c[1]+c[0]<1E3*g[1]+g[0]?1:-1,d=m,m=0,n=1):(f=1E3*c[0]+c[1]<1E3*g[0]+g[1]?1:-1,d=n,m=1,n=0);for(c[0]!==e[0]&&c[1]!==e[1]&&(p=!0);c[0]!==g[0]||c[1]!==g[1];)(h=i[c[0]+"-"+c[1]],c[m]+=f,0>c[m]?(c[m]=d,c[n]--):c[m]>d&&(c[m]=0,c[n]++),e=i[c[0]+"-"+c[1]],void 0!==e&&(j=e),void 0!==h&&(k=h),void 0!==e&&void 0!==k||void 0!==j&&void 0!==h)?(e=-1===j.className.indexOf(REDIPS.drag.mark.cname)?
56  
-0:1,h=-1===k.className.indexOf(REDIPS.drag.mark.cname)?0:1,p&&0===e&&1===h&&r(j),1===e?0===h&&(o=k):(0===e&&1===h&&(k=o),q(j,k))):p&&(void 0!==j&&void 0===k)&&(e=-1===j.className.indexOf(REDIPS.drag.mark.cname)?0:1,0===e&&r(j))}};Oa=function(a){var b=[],c,d={},e,g,f,i,h,j,k,l;i=a.rows;for(h=0;h<i.length;h++)for(j=0;j<i[h].cells.length;j++){c=i[h].cells[j];a=c.parentNode.rowIndex;e=c.rowSpan||1;g=c.colSpan||1;b[a]=b[a]||[];for(k=0;k<b[a].length+1;k++)if("undefined"===typeof b[a][k]){f=k;break}d[a+
57  
-"-"+f]=c;void 0===c.redips&&(c.redips={});c.redips.rowIndex=a;c.redips.cellIndex=f;for(k=a;k<a+e;k++){b[k]=b[k]||[];c=b[k];for(l=f;l<f+g;l++)c[l]="x"}}return d};Pa=function(a){var b=a.rows,c=0,d,e;"string"===typeof a&&document.getElementById(a);for(d=0;d<b.length;d++){for(e=a=0;e<b[d].cells.length;e++)a+=b[d].cells[e].colSpan||1;a>c&&(c=a)}return c};Ja=function(a,b){var c=(b.k1-b.k2*a)*(b.k1-b.k2*a),d,a=a+REDIPS.drag.animation.step*(4-3*c)*b.direction;d=b.m*a+b.b;"horizontal"===b.type?(b.obj.style.left=
58  
-a+"px",b.obj.style.top=d+"px"):(b.obj.style.left=d+"px",b.obj.style.top=a+"px");a<b.last&&0<b.direction||a>b.last&&0>b.direction?setTimeout(function(){Ja(a,b)},REDIPS.drag.animation.pause*c):(Da(b.obj),b.obj.redips&&(b.obj.redips.animated=!1),"cell"===b.mode?(!0===b.overwrite&&fa(b.targetCell),b.targetCell.appendChild(b.obj),b.obj.redips&&!1!==b.obj.redips.enabled&&V(b.obj)):Ka(qa(b.target[0]),b.target[1],b.obj),"function"===typeof b.callback&&b.callback(b.obj))};ra=function(a){var b,c,d;b=[];b=c=
59  
-d=-1;if(void 0===a)b=h<f.length?f[h].redips.idx:null===t||null===v||null===A?f[z].redips.idx:f[t].redips.idx,c=f[z].redips.idx,b=[b,j,k,c,J,U];else{if(a="string"===typeof a?document.getElementById(a):a)"TD"!==a.nodeName&&(a=x("TD",a)),a&&"TD"===a.nodeName&&(b=a.cellIndex,c=a.parentNode.rowIndex,a=x("TABLE",a),d=a.redips.idx);b=[d,c,b]}return b};qa=function(a){var b;for(b=0;b<f.length&&f[b].redips.idx!==a;b++);return b};ta=function(a){void 0!==a&&(a=a.replace(/^\s+|\s+$/g,"").replace(/\s{2,}/g," "));
60  
-return a};Ra=function(a){var b;for(b=0;b<a.childNodes.length;b++)if(1===a.childNodes[b].nodeType)return!0;return!1};sa=function(a,b,c){var d,e;"string"===typeof a&&(a=document.getElementById(a),a=x("TABLE",a));if("TR"===a.nodeName){a=a.getElementsByTagName("td");for(d=0;d<a.length;d++)if(a[d].style.backgroundColor=c?c:"","empty"===b)a[d].innerHTML="";else for(e=0;e<a[d].childNodes.length;e++)1===a[d].childNodes[e].nodeType&&(a[d].childNodes[e].style.opacity=b/100,a[d].childNodes[e].style.filter="alpha(opacity="+
61  
-b+")")}else a.style.opacity=b/100,a.style.filter="alpha(opacity="+b+")",a.style.backgroundColor=c?c:""};return{obj:i,objOld:o,mode:r,td:l,hover:{colorTd:"#E7AB83",colorTr:"#E7AB83"},scroll:{enable:!0,bound:25,speed:20},only:za,mark:Ua,style:{borderEnabled:"solid",borderDisabled:"dotted",opacityDisabled:"",rowEmptyColor:"white"},trash:{className:"trash",question:null,questionRow:null},saveParamName:"p",dropMode:"multiple",multipleDrop:"bottom",clone:Va,animation:{pause:20,step:2,shift:!1},shift:{mode:"horizontal1",
62  
-after:"default",overflow:"bunch"},rowDropMode:"before",tableSort:!0,init:function(a){var b;if(void 0===a||"string"!==typeof a)a="drag";y=document.getElementById(a);ya=L();document.getElementById("redips_clone")||(a=document.createElement("div"),a.id="redips_clone",a.style.width=a.style.height="1px",y.appendChild(a));B("init");q();Ea();REDIPS.event.add(window,"resize",Ea);b=y.getElementsByTagName("img");for(a=0;a<b.length;a++)REDIPS.event.add(b[a],"mousemove",K),REDIPS.event.add(b[a],"touchmove",K);
63  
-REDIPS.event.add(window,"scroll",u)},initTables:q,enableDrag:B,enableTable:function(a,b){var c;if("object"===typeof b&&"TABLE"===b.nodeName)b.redips.enabled=a;else for(c=0;c<f.length;c++)-1<f[c].className.indexOf(b)&&(f[c].redips.enabled=a)},cloneObject:na,saveContent:function(a,b){var c="",d,e,f,i,h,j,k,l=[],m=REDIPS.drag.saveParamName;"string"===typeof a&&(a=document.getElementById(a));if(void 0!==a&&"object"===typeof a&&"TABLE"===a.nodeName){d=a.rows.length;for(h=0;h<d;h++){e=a.rows[h].cells.length;
64  
-for(j=0;j<e;j++)if(f=a.rows[h].cells[j],0<f.childNodes.length)for(k=0;k<f.childNodes.length;k++)i=f.childNodes[k],"DIV"===i.nodeName&&-1<i.className.indexOf("drag")&&(c+=m+"[]="+i.id+"_"+h+"_"+j+"&",l.push([i.id,h,j]))}c="json"===b&&0<l.length?JSON.stringify(l):c.substring(0,c.length-1)}return c},relocate:ea,emptyCell:fa,moveObject:function(a){var b={direction:1},c,d,e,g,i,h;b.callback=a.callback;b.overwrite=a.overwrite;"string"===typeof a.id?b.obj=b.objOld=document.getElementById(a.id):"object"===
65  
-typeof a.obj&&"DIV"===a.obj.nodeName&&(b.obj=b.objOld=a.obj);if("row"===a.mode){b.mode="row";h=qa(a.source[0]);i=a.source[1];o=b.objOld=f[h].rows[i];if(o.redips&&!0===o.redips.emptyRow)return!1;b.obj=ga(b.objOld,"animated")}else if(b.obj&&-1<b.obj.className.indexOf("row")){b.mode="row";b.obj=b.objOld=o=x("TR",b.obj);if(o.redips&&!0===o.redips.emptyRow)return!1;b.obj=ga(b.objOld,"animated")}else b.mode="cell";if(!("object"!==typeof b.obj||null===b.obj))return b.obj.style.zIndex=999,b.obj.redips&&y!==
66  
-b.obj.redips.container&&(y=b.obj.redips.container,q()),h=C(b.obj),e=h[1]-h[3],g=h[2]-h[0],c=h[3],d=h[0],!0===a.clone&&"cell"===b.mode&&(b.obj=na(b.obj,!0),REDIPS.drag.event.cloned(b.obj)),void 0===a.target?a.target=ra():"object"===typeof a.target&&"TD"===a.target.nodeName&&(a.target=ra(a.target)),b.target=a.target,h=qa(a.target[0]),i=a.target[1],a=a.target[2],i>f[h].rows.length-1&&(i=f[h].rows.length-1),b.targetCell=f[h].rows[i].cells[a],"cell"===b.mode?(h=C(b.targetCell),i=h[1]-h[3],a=h[2]-h[0],
67  
-e=h[3]+(i-e)/2,g=h[0]+(a-g)/2):(h=C(f[h].rows[i]),e=h[3],g=h[0]),h=e-c,a=g-d,b.obj.style.position="fixed",Math.abs(h)>Math.abs(a)?(b.type="horizontal",b.m=a/h,b.b=d-b.m*c,b.k1=(c+e)/(c-e),b.k2=2/(c-e),c>e&&(b.direction=-1),h=c,b.last=e):(b.type="vertical",b.m=h/a,b.b=c-b.m*d,b.k1=(d+g)/(d-g),b.k2=2/(d-g),d>g&&(b.direction=-1),h=d,b.last=g),b.obj.redips&&(b.obj.redips.animated=!0),Ja(h,b),[b.obj,b.objOld]},shiftCells:pa,deleteObject:function(a){"object"===typeof a&&"DIV"===a.nodeName?a.parentNode.removeChild(a):
68  
-"string"===typeof a&&(a=document.getElementById(a))&&a.parentNode.removeChild(a)},getPosition:ra,rowOpacity:sa,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;sa(a,"empty",c)},getScrollPosition:L,getStyle:E,findParent:x,findCell:Ia,event:{changed:function(){},clicked:function(){},cloned:function(){},clonedDropped:function(){},clonedEnd1:function(){},clonedEnd2:function(){},dblClicked:function(){},
  49
+"",g[c].style.filter=""):!1===a&&"number"===typeof i&&(g[c].style.opacity=i/100,g[c].style.filter="alpha(opacity="+i+")"),U(g[c],j),g[c].style.borderStyle=w,g[c].style.cursor=h,g[c].redips.enabled=j;else if("init"===a&&(e=E(g[c],"overflow"),"visible"!==e)){REDIPS.event.add(g[c],"scroll",u);e=E(g[c],"position");f=C(g[c],e,!1);e=k.test(g[c].className)?!1:!0;L[d]={div:g[c],offset:f,midstX:(f[1]+f[3])/2,midstY:(f[0]+f[2])/2,autoscroll:e};f=g[c].getElementsByTagName("table");for(e=0;e<f.length;e++)f[e].sca=
  50
+L[d];d++}};E=function(a,b){var c;a&&a.currentStyle?c=a.currentStyle[b]:a&&window.getComputedStyle&&(c=document.defaultView.getComputedStyle(a,null)[b]);return c};x=function(a,b,c){b=b.parentNode;for(void 0===c&&(c=0);b&&b.nodeName!==a;)if((b=b.parentNode)&&b.nodeName===a&&0<c)c--,b=b.parentNode;return b};Ga=function(a,b){var c=x("TABLE",b),d,e;switch(a){case "firstInColumn":d=0;e=b.cellIndex;break;case "firstInRow":d=b.parentNode.rowIndex;e=0;break;case "lastInColumn":d=c.rows.length-1;e=b.cellIndex;
  51
+break;case "lastInRow":d=b.parentNode.rowIndex;e=c.rows[d].cells.length-1;break;case "last":d=c.rows.length-1;e=c.rows[d].cells.length-1;break;default:d=e=0}return[d,e,c.rows[d].cells[e]]};da=function(a,b,c){var d,e,g;d=function(a,b){REDIPS.drag.event.relocateBefore(a,b);var c=REDIPS.drag.getPosition(b);REDIPS.drag.moveObject({obj:a,target:c,callback:function(a){var c=REDIPS.drag.findParent("TABLE",a),d=c.redips.idx;REDIPS.drag.event.relocateAfter(a,b);wa[d]--;0===wa[d]&&(REDIPS.drag.event.relocateEnd(),
  52
+REDIPS.drag.enableTable(!0,c))}})};if(a!==b&&!("object"!==typeof a||"object"!==typeof b))if(g=a.childNodes.length,"animation"===c){if(0<g){c=x("TABLE",b);e=c.redips.idx;REDIPS.drag.enableTable(!1,c);for(c=0;c<g;c++)1===a.childNodes[c].nodeType&&"DIV"===a.childNodes[c].nodeName&&(wa[e]++,d(a.childNodes[c],b))}}else for(d=c=0;c<g;c++)1===a.childNodes[d].nodeType&&"DIV"===a.childNodes[d].nodeName?(e=a.childNodes[d],REDIPS.drag.event.relocateBefore(e,b),b.appendChild(e),e.redips&&!1!==e.redips.enabled&&
  53
+U(e),REDIPS.drag.event.relocateAfter(e)):d++};ea=function(a,b){var c,d=[],e;if("TD"===a.nodeName){c=a.childNodes.length;if("test"===b)return c=l.source===a?void 0:0===a.childNodes.length||1===a.childNodes.length&&3===a.firstChild.nodeType?!0:!1;for(e=0;e<c;e++)d.push(a.childNodes[0]),a.removeChild(a.childNodes[0]);return d}};oa=function(a,b){var c,d,e,g,f,i,h,j,k,n,m,o,p=!1,q,r;q=function(a,b){REDIPS.drag.shift.animation?da(a,b,"animation"):da(a,b)};r=function(a){"delete"===REDIPS.drag.shift.overflow?
  54
+ea(a):"source"===REDIPS.drag.shift.overflow?q(a,l.source):"object"===typeof REDIPS.drag.shift.overflow&&q(a,REDIPS.drag.shift.overflow);p=!1;REDIPS.drag.event.shiftOverflow(a)};if(a!==b){f=REDIPS.drag.shift.mode;c=x("TABLE",a);d=x("TABLE",b);i=Na(d);e=c===d?[a.redips.rowIndex,a.redips.cellIndex]:[-1,-1];g=[b.redips.rowIndex,b.redips.cellIndex];m=d.rows.length;o=Oa(d);switch(f){case "vertical2":c=c===d&&a.redips.cellIndex===b.redips.cellIndex?e:[m,b.redips.cellIndex];break;case "horizontal2":c=c===
  55
+d&&a.parentNode.rowIndex===b.parentNode.rowIndex?e:[b.redips.rowIndex,o];break;default:c=c===d?e:[m,o]}"vertical1"===f||"vertical2"===f?(f=1E3*c[1]+c[0]<1E3*g[1]+g[0]?1:-1,d=m,m=0,o=1):(f=1E3*c[0]+c[1]<1E3*g[0]+g[1]?1:-1,d=o,m=1,o=0);for(c[0]!==e[0]&&c[1]!==e[1]&&(p=!0);c[0]!==g[0]||c[1]!==g[1];)(h=i[c[0]+"-"+c[1]],c[m]+=f,0>c[m]?(c[m]=d,c[o]--):c[m]>d&&(c[m]=0,c[o]++),e=i[c[0]+"-"+c[1]],void 0!==e&&(j=e),void 0!==h&&(k=h),void 0!==e&&void 0!==k||void 0!==j&&void 0!==h)?(e=-1===j.className.indexOf(REDIPS.drag.mark.cname)?
  56
+0:1,h=-1===k.className.indexOf(REDIPS.drag.mark.cname)?0:1,p&&0===e&&1===h&&r(j),1===e?0===h&&(n=k):(0===e&&1===h&&(k=n),q(j,k))):p&&(void 0!==j&&void 0===k)&&(e=-1===j.className.indexOf(REDIPS.drag.mark.cname)?0:1,0===e&&r(j))}};Na=function(a){var b=[],c,d={},e,g,f,i,h,j,k,l;i=a.rows;for(h=0;h<i.length;h++)for(j=0;j<i[h].cells.length;j++){c=i[h].cells[j];a=c.parentNode.rowIndex;e=c.rowSpan||1;g=c.colSpan||1;b[a]=b[a]||[];for(k=0;k<b[a].length+1;k++)if("undefined"===typeof b[a][k]){f=k;break}d[a+
  57
+"-"+f]=c;void 0===c.redips&&(c.redips={});c.redips.rowIndex=a;c.redips.cellIndex=f;for(k=a;k<a+e;k++){b[k]=b[k]||[];c=b[k];for(l=f;l<f+g;l++)c[l]="x"}}return d};Oa=function(a){var b=a.rows,c=0,d,e;"string"===typeof a&&document.getElementById(a);for(d=0;d<b.length;d++){for(e=a=0;e<b[d].cells.length;e++)a+=b[d].cells[e].colSpan||1;a>c&&(c=a)}return c};Ha=function(a,b){var c=(b.k1-b.k2*a)*(b.k1-b.k2*a),d,a=a+REDIPS.drag.animation.step*(4-3*c)*b.direction;d=b.m*a+b.b;"horizontal"===b.type?(b.obj.style.left=
  58
+a+"px",b.obj.style.top=d+"px"):(b.obj.style.left=d+"px",b.obj.style.top=a+"px");a<b.last&&0<b.direction||a>b.last&&0>b.direction?setTimeout(function(){Ha(a,b)},REDIPS.drag.animation.pause*c):(Ba(b.obj),b.obj.redips&&(b.obj.redips.animated=!1),"cell"===b.mode?(!0===b.overwrite&&ea(b.targetCell),b.targetCell.appendChild(b.obj),b.obj.redips&&!1!==b.obj.redips.enabled&&U(b.obj)):Ia(pa(b.target[0]),b.target[1],b.obj),"function"===typeof b.callback&&b.callback(b.obj))};qa=function(a){var b,c,d;b=[];b=c=
  59
+d=-1;if(void 0===a)b=j<f.length?f[j].redips.idx:null===t||null===v||null===A?f[z].redips.idx:f[t].redips.idx,c=f[z].redips.idx,b=[b,h,k,c,I,T];else{if(a="string"===typeof a?document.getElementById(a):a)"TD"!==a.nodeName&&(a=x("TD",a)),a&&"TD"===a.nodeName&&(b=a.cellIndex,c=a.parentNode.rowIndex,a=x("TABLE",a),d=a.redips.idx);b=[d,c,b]}return b};pa=function(a){var b;for(b=0;b<f.length&&f[b].redips.idx!==a;b++);return b};sa=function(a){void 0!==a&&(a=a.replace(/^\s+|\s+$/g,"").replace(/\s{2,}/g," "));
  60
+return a};Qa=function(a){var b;for(b=0;b<a.childNodes.length;b++)if(1===a.childNodes[b].nodeType)return!0;return!1};ra=function(a,b,c){var d,e;"string"===typeof a&&(a=document.getElementById(a),a=x("TABLE",a));if("TR"===a.nodeName){a=a.getElementsByTagName("td");for(d=0;d<a.length;d++)if(a[d].style.backgroundColor=c?c:"","empty"===b)a[d].innerHTML="";else for(e=0;e<a[d].childNodes.length;e++)1===a[d].childNodes[e].nodeType&&(a[d].childNodes[e].style.opacity=b/100,a[d].childNodes[e].style.filter="alpha(opacity="+
  61
+b+")")}else a.style.opacity=b/100,a.style.filter="alpha(opacity="+b+")",a.style.backgroundColor=c?c:""};return{obj:i,objOld:m,mode:r,td:l,hover:{colorTd:"#E7AB83",colorTr:"#E7AB83"},scroll:{enable:!0,bound:25,speed:20},only:ya,mark:Ta,style:{borderEnabled:"solid",borderDisabled:"dotted",opacityDisabled:"",rowEmptyColor:"white"},trash:{className:"trash",question:null,questionRow:null},saveParamName:"p",dropMode:"multiple",multipleDrop:"bottom",clone:Ua,animation:{pause:20,step:2,shift:!1},shift:{mode:"horizontal1",
  62
+after:"default",overflow:"bunch"},rowDropMode:"before",tableSort:!0,init:function(a){var b;if(void 0===a||"string"!==typeof a)a="drag";y=document.getElementById(a);xa=K();document.getElementById("redips_clone")||(a=document.createElement("div"),a.id="redips_clone",a.style.width=a.style.height="1px",y.appendChild(a));B("init");q();Ca();REDIPS.event.add(window,"resize",Ca);b=y.getElementsByTagName("img");for(a=0;a<b.length;a++)REDIPS.event.add(b[a],"mousemove",J),REDIPS.event.add(b[a],"touchmove",J);
  63
+REDIPS.event.add(window,"scroll",u)},initTables:q,enableDrag:B,enableTable:function(a,b){var c;if("object"===typeof b&&"TABLE"===b.nodeName)b.redips.enabled=a;else for(c=0;c<f.length;c++)-1<f[c].className.indexOf(b)&&(f[c].redips.enabled=a)},cloneObject:ma,saveContent:function(a,b){var c="",d,e,f,h,i,j,k,l=[],m=REDIPS.drag.saveParamName;"string"===typeof a&&(a=document.getElementById(a));if(void 0!==a&&"object"===typeof a&&"TABLE"===a.nodeName){d=a.rows.length;for(i=0;i<d;i++){e=a.rows[i].cells.length;
  64
+for(j=0;j<e;j++)if(f=a.rows[i].cells[j],0<f.childNodes.length)for(k=0;k<f.childNodes.length;k++)h=f.childNodes[k],"DIV"===h.nodeName&&-1<h.className.indexOf("drag")&&(c+=m+"[]="+h.id+"_"+i+"_"+j+"&",l.push([h.id,i,j]))}c="json"===b&&0<l.length?JSON.stringify(l):c.substring(0,c.length-1)}return c},relocate:da,emptyCell:ea,moveObject:function(a){var b={direction:1},c,d,e,g,i,h;b.callback=a.callback;b.overwrite=a.overwrite;"string"===typeof a.id?b.obj=b.objOld=document.getElementById(a.id):"object"===
  65
+typeof a.obj&&"DIV"===a.obj.nodeName&&(b.obj=b.objOld=a.obj);if("row"===a.mode){b.mode="row";h=pa(a.source[0]);i=a.source[1];m=b.objOld=f[h].rows[i];if(m.redips&&!0===m.redips.emptyRow)return!1;b.obj=fa(b.objOld,"animated")}else if(b.obj&&-1<b.obj.className.indexOf("row")){b.mode="row";b.obj=b.objOld=m=x("TR",b.obj);if(m.redips&&!0===m.redips.emptyRow)return!1;b.obj=fa(b.objOld,"animated")}else b.mode="cell";if(!("object"!==typeof b.obj||null===b.obj))return b.obj.style.zIndex=999,b.obj.redips&&y!==
  66
+b.obj.redips.container&&(y=b.obj.redips.container,q()),h=C(b.obj),e=h[1]-h[3],g=h[2]-h[0],c=h[3],d=h[0],!0===a.clone&&"cell"===b.mode&&(b.obj=ma(b.obj,!0),REDIPS.drag.event.cloned(b.obj)),void 0===a.target?a.target=qa():"object"===typeof a.target&&"TD"===a.target.nodeName&&(a.target=qa(a.target)),b.target=a.target,h=pa(a.target[0]),i=a.target[1],a=a.target[2],i>f[h].rows.length-1&&(i=f[h].rows.length-1),b.targetCell=f[h].rows[i].cells[a],"cell"===b.mode?(h=C(b.targetCell),i=h[1]-h[3],a=h[2]-h[0],
  67
+e=h[3]+(i-e)/2,g=h[0]+(a-g)/2):(h=C(f[h].rows[i]),e=h[3],g=h[0]),h=e-c,a=g-d,b.obj.style.position="fixed",Math.abs(h)>Math.abs(a)?(b.type="horizontal",b.m=a/h,b.b=d-b.m*c,b.k1=(c+e)/(c-e),b.k2=2/(c-e),c>e&&(b.direction=-1),h=c,b.last=e):(b.type="vertical",b.m=h/a,b.b=c-b.m*d,b.k1=(d+g)/(d-g),b.k2=2/(d-g),d>g&&(b.direction=-1),h=d,b.last=g),b.obj.redips&&(b.obj.redips.animated=!0),Ha(h,b),[b.obj,b.objOld]},shiftCells:oa,deleteObject:function(a){"object"===typeof a&&"DIV"===a.nodeName?a.parentNode.removeChild(a):
  68
+"string"===typeof a&&(a=document.getElementById(a))&&a.parentNode.removeChild(a)},getPosition:qa,rowOpacity:ra,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;ra(a,"empty",c)},getScrollPosition:K,getStyle:E,findParent:x,findCell:Ga,event:{changed:function(){},clicked:function(){},cloned:function(){},clonedDropped:function(){},clonedEnd1:function(){},clonedEnd2:function(){},dblClicked:function(){},
69 69
 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(){},
70  
-rowUndeleted:function(){},switched:function(){},undeleted:function(){}}}}();REDIPS.event||(REDIPS.event=function(){return{add:function(q,B,K){q.addEventListener?q.addEventListener(B,K,!1):q.attachEvent?q.attachEvent("on"+B,K):q["on"+B]=K},remove:function(q,B,K){q.removeEventListener?q.removeEventListener(B,K,!1):q.detachEvent?q.detachEvent("on"+B,K):q["on"+B]=null}}}());
  70
+rowUndeleted:function(){},switched:function(){},undeleted:function(){}}}}();REDIPS.event||(REDIPS.event=function(){return{add:function(q,B,J){q.addEventListener?q.addEventListener(B,J,!1):q.attachEvent?q.attachEvent("on"+B,J):q["on"+B]=J},remove:function(q,B,J){q.removeEventListener?q.removeEventListener(B,J,!1):q.detachEvent?q.detachEvent("on"+B,J):q["on"+B]=null}}}());
16  redips-drag-source.js
@@ -2,8 +2,8 @@
2 2
 Copyright (c) 2008-2011, www.redips.net All rights reserved.
3 3
 Code licensed under the BSD License: http://www.redips.net/license/
4 4
 http://www.redips.net/javascript/drag-and-drop-table-content/
5  
-Version 5.0.7
6  
-May 29, 2013.
  5
+Version 5.0.8
  6
+Jun 28, 2013.
7 7
 */
8 8
 
9 9
 /*jslint white: true, browser: true, undef: true, nomen: true, eqeqeq: true, plusplus: false, bitwise: true, regexp: true, strict: true, newcap: true, immed: true, maxerr: 14 */
@@ -34,7 +34,7 @@ var REDIPS = REDIPS || {};
34 34
  * <a href="http://www.redips.net/javascript/drag-and-drop-table-row/">Drag and drop table rows</a>
35 35
  * <a href="http://www.redips.net/javascript/drag-and-drop-table-content/">Drag and Drop table content</a>
36 36
  * <a href="http://www.redips.net/javascript/drag-and-drop-content-shift/">JavaScript drag and drop plus content shift</a>
37  
- * @version 5.0.7 (2013-05-29)
  37
+ * @version 5.0.8 (2013-06-28)
38 38
  */
39 39
 REDIPS.drag = (function () {
40 40
 		// methods
@@ -860,12 +860,16 @@ REDIPS.drag = (function () {
860 860
 		source.row = tableMini.redips.sourceRow;
861 861
 		source.rowIndex = source.row.rowIndex;
862 862
 		source.table = findParent('TABLE', source.row);
863  
-		source.tableSection = source.table.rows[0].parentNode;
  863
+		source.tableSection = source.row.parentNode;
864 864
 		// define target data: row, row index, table and table section
865 865
 		target.table = tables[tableIdx];
  866
+		// if row index is out of bounds, then set max row index (row will be appended to the table bottom)
  867
+		if (rowIdx > target.table.rows.length - 1) {
  868
+			rowIdx = target.table.rows.length - 1;
  869
+		}
866 870
 		target.row = target.table.rows[rowIdx];
867 871
 		target.rowIndex = rowIdx;
868  
-		target.tableSection = target.table.rows[0].parentNode;
  872
+		target.tableSection = target.row.parentNode;
869 873
 		// set reference to the TR in mini table (mini table has only one row - first row)
870 874
 		trMini = tableMini.getElementsByTagName('tr')[0];
871 875
 		// destroy mini table (node still exists in memory)
@@ -944,7 +948,7 @@ REDIPS.drag = (function () {
944 948
 				}
945 949
 				// if table contains only "empty" row then this row should be deleted after inserting or appending to such table
946 950
 				if (target.row && target.row.redips && target.row.redips.emptyRow) {
947  
-					target.tableSection.deleteRow(target.row.rowIndex);
  951
+					target.table.deleteRow(target.row.rowIndex);
948 952
 				}
949 953
 				// in case of "overwrite", delete target row
950 954
 				else if (REDIPS.drag.rowDropMode === 'overwrite') {

0 notes on commit 52449f5

Please sign in to comment.
Something went wrong with that request. Please try again.