Permalink
Browse files

Final - fixing code, comments and examples

Ready to publish
  • Loading branch information...
1 parent 6f32824 commit 02e8be366158300813a01869a0e53e9e51137fdf @dbunic committed Nov 8, 2012
View
2 changes.txt
@@ -7,6 +7,8 @@ Changes for REDIPS.drag library
- initTables method exposed as public (needed for cases when table is dynamically added or removed)
- from now lib uses querySelectorAll for tables and div selection (here is compatibility table http://caniuse.com/queryselector)
- enableDrag uses CSS selector
+- added clone.sendBack option - if set to true, cloned DIV element could be returned to the source
+- updated documentation
4.7.6
- added event handler myhandler_relocated() - event can be triggered after single call of relocate() method or after all DIV elements are shifted in "shift" mode
View
2 example03/script.js
@@ -22,7 +22,7 @@ redipsInit = function () {
// REDIPS.drag settings
rd.dropMode = 'single'; // dragged elements can be placed only to the empty cells
rd.hover.colorTd = '#9BB3DA'; // set hover color
- rd.cloneKey.div = true; // enable cloning DIV elements with pressed SHIFT key
+ rd.clone.keyDiv = true; // enable cloning DIV elements with pressed SHIFT key
// prepare node list of DIV elements in table2
divNodeList = document.getElementById('table2').getElementsByTagName('div');
// show / hide report buttons (needed for dynamic version - with index.php)
View
8 example04/script.js
@@ -48,12 +48,12 @@ redipsInit = function () {
toggleXO = function () {
// references to the X and O elements
if (divO.redips.enabled) {
- rd.enableDrag(false, 'o');
- rd.enableDrag(true, 'x');
+ rd.enableDrag(false, '#o');
+ rd.enableDrag(true, '#x');
}
else {
- rd.enableDrag(true, 'o');
- rd.enableDrag(false, 'x');
+ rd.enableDrag(true, '#o');
+ rd.enableDrag(false, '#x');
}
};
View
2 example05/script.js
@@ -17,7 +17,7 @@ redipsInit = function () {
// dragged elements can be placed to the empty cells only
rd.dropMode = 'single';
// elements could be cloned with pressed SHIFT key
- rd.cloneKey.div = true;
+ rd.clone.keyDiv = true;
// every change of current TD will have different background color
rd.event.changed = function () {
rd.hover.colorTd = rndColor();
View
2 example06/script.js
@@ -16,7 +16,7 @@ redipsInit = function () {
// dragged elements can be placed to the empty cells only
rd.dropMode = 'single';
// elements could be cloned with pressed SHIFT key
- rd.cloneKey.div = true;
+ rd.clone.keyDiv = true;
// define dropped handler
rd.event.dropped = function (targetCell) {
var tbl, // table reference of dropped element
View
2 example10/script.js
@@ -16,7 +16,7 @@ redipsInit = function () {
// dragged elements can be placed only to the empty cells
rd.dropMode = 'single';
// enable cloning DIV elements with pressed SHIFT key
- rd.cloneKey.div = true;
+ rd.clone.keyDiv = true;
};
// add onload event listener
View
2 example13/script.js
@@ -15,7 +15,7 @@ redipsInit = function () {
// initialization
rd.init();
// enable cloning DIV elements with pressed SHIFT key
- rd.cloneKey.div = true;
+ rd.clone.keyDiv = true;
// handler clicked - set hover color
rd.event.clicked = function (currentCell) {
setHoverColor(currentCell);
View
4 example16/script.js
@@ -51,10 +51,10 @@ redips.init = function () {
var cid = redips.findContainer(rd.obj);
// set cloning option with shiftKey only for right DIV container
if (cid === redips.right) {
- rd.cloneKey.div = true;
+ rd.clone.keyDiv = true;
}
else {
- rd.cloneKey.div = false;
+ rd.clone.keyDiv = false;
}
// set hover color for original DIV elements and for cloned DIV elements
if (rd.obj.className.indexOf('clnd') === -1) {
View
2 example18/script1.js
@@ -24,7 +24,7 @@ redips.init = function () {
// animation step (minimum is 1)
rd.animation.step = 2;
// define color for "empty row"
- rd.rowEmptyColor = 'LightBlue';
+ rd.style.rowEmptyColor = '#d3ebf3';
};
View
2 example19/script.js
@@ -16,7 +16,7 @@ redipsInit = function () {
// set hover color for TR
rd.hover.colorTr = '#ddd';
// define color for empty row
- rd.rowEmptyColor = '#eee';
+ rd.style.rowEmptyColor = '#eee';
// row was clicked - enable / disable tables
rd.event.rowClicked = function () {
// find table
View
8 example20/script.js
@@ -16,10 +16,12 @@ redipsInit = function () {
// set hover colors for TD and TR
rd.hover.colorTd = '#FFCFAE';
rd.hover.colorTr = '#9BB3DA';
- // confirm row deletion
+ // set color for "empty row"
+ rd.style.rowEmptyColor = '#f8f8f8';
+ // set question for row deletion
rd.trash.questionRow = 'Are you sure you want to delete table row?';
- // enable clone element and row with shift key
- rd.cloneKey.div = rd.cloneKey.row = true;
+ // enable clone element and clone row with shift key
+ rd.clone.keyDiv = rd.clone.keyRow = true;
// mark row in second table as empty
rd.rowEmpty('tbl2', 1);
//
View
4 example23/script.js
@@ -117,12 +117,12 @@ redips.save = function () {
*/
// demo code
message = redips.request.responseText;
- delay = 3000;
+ delay = 2000;
}
// if request status isn't OK
else {
message = 'Error: [' + redips.request.status + '] ' + redips.request.statusText;
- delay = 3000;
+ delay = 2000;
}
// display message and set timeout to delete message
redips.display_message(message, delay);
View
120 redips-drag-min.js
@@ -3,65 +3,65 @@ Copyright (c) 2008-2011, 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.0.0
-Nov 1, 2012.
+Nov 8, 2012.
*/
var REDIPS=REDIPS||{};
-REDIPS.drag=function(){var r,E,J,va,Ja,Ka,ba,ca,ga,wa,xa,R,ha,ya,S,ia,Y,za,B,v,N,ja,ka,la,Aa,Ba,Ca,D,x,Da,da,ma,na,La,Ma,Ea,oa,Fa,pa,ea,Ga,Na,qa,Oa,p=null,F=0,G=0,ra=null,sa=null,K=0,L=0,O=0,P=0,T=0,U=0,t,Z,M=[],f=[],$,ta,q,H=[],n=[],y=null,C=null,W=0,X=0,Pa=0,Qa=0,fa=!1,Ha=!1,aa=!1,Ia=0,h=null,u=null,z=null,j=null,w=null,I=null,l=null,A=null,V=null,i=!1,m=!1,s="cell",ua={div:[],cname:"only",other:"deny"},Ra={action:"deny",cname:"mark",exception:[]},k={};J=function(){return!1};r=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;d=f[b].getElementsByTagName("td");c=0;for(g=!1;c<d.length;c++)if(1<d[c].rowSpan){g=!0;break}f[b].redips.rowspan=g;b++}a=
-0;for(e=$=1;a<f.length;a++)if(0===f[a].redips.nestedLevel){f[a].redips.nestedGroup=e;f[a].redips.sort=100*$;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*$+c[b].redips.nestedLevel);e++;$++}};va=function(a){var b=a||window.event,c,d;if(!0===this.redips.animated)return!0;b.cancelBubble=!0;b.stopPropagation&&b.stopPropagation();Ha=b.shiftKey;a=b.which?b.which:b.button;if(Ca(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);Pa=a;Qa=d;fa=!1;REDIPS.drag.objOld=m=i||this;REDIPS.drag.obj=i=this;aa=-1<i.className.indexOf("clone")?!0:!1;REDIPS.drag.tableSort&&Ka(i);y!==i.redips.container&&(y=i.redips.container,r());-1===i.className.indexOf("row")?REDIPS.drag.mode=s="cell":
-(REDIPS.drag.mode=s="row",REDIPS.drag.obj=i=ea(i));v();!aa&&"cell"===s&&(i.style.zIndex=999);h=j=l=null;S();z=u=h;I=w=j;V=A=l;REDIPS.drag.td.source=k.source=x("TD",i);REDIPS.drag.td.current=k.current=k.source;REDIPS.drag.td.previous=k.previous=k.source;"cell"===s?REDIPS.drag.event.clicked(k.current):REDIPS.drag.event.rowClicked(k.current);if(null===h||null===j||null===l)if(S(),z=u=h,I=w=j,V=A=l,null===h||null===j||null===l)return!0;ta=q=!1;REDIPS.event.add(document,"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!==h&&(null!==j&&null!==l)&&(Z=za(h,j,l));c=D(f[z],"position");"fixed"!==c&&(c=D(f[z].parentNode,"position"));c=B(i,c);p=[d-c[0],c[1]-a,c[2]-d,a-c[3]];y.onselectstart=function(a){b=a||window.event;if(!Ca(b)){b.shiftKey&&document.selection.clear();return false}};return!1};Ja=function(){REDIPS.drag.event.dblClicked()};Ka=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*$+f[a].redips.nestedLevel);f.sort(function(a,b){return b.redips.sort-a.redips.sort});$++};ea=function(a,b){var c,d,e,g,f,o;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);aa&&q&&(g=d.redips.div,g.className=qa(g.className.replace("clone","")));c=a.cloneNode(!0);aa&&q&&(g.className+=" 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(o=0;o<e.cells.length;o++)if(-1<e.cells[o].className.indexOf("rowhandler")){g=!1;break}}c.deleteRow(f)}q||(d.redips.empty_row=g);c.redips={};c.redips.container=a.redips.container;c.redips.source_row=d;Na(d,c.rows[0]);Aa(d,c.rows[0]);document.getElementById("redips_clone").appendChild(c);d=B(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]+"px";return c};Ga=function(a,
-b,c){var d=f[a],a=d.rows[0].parentNode,e=!1,g,Q,o,j;j=function(){m.redips.empty_row?pa(m,"empty",REDIPS.drag.style.rowEmptyColor):(Q=x("TABLE",Q),Q.deleteRow(o))};void 0===c?c=i:e=!0;Q=c.redips.source_row;o=Q.rowIndex;g=c.getElementsByTagName("tr")[0];c.parentNode.removeChild(c);if(!1!==REDIPS.drag.event.rowDroppedBefore(o)){if(!e&&-1<k.target.className.indexOf(REDIPS.drag.trash.className))q?REDIPS.drag.event.rowDeleted():REDIPS.drag.trash.questionRow?confirm(REDIPS.drag.trash.questionRow)?(j(),REDIPS.drag.event.rowDeleted()):
-(delete m.redips.empty_row,REDIPS.drag.event.rowUndeleted()):(j(),REDIPS.drag.event.rowDeleted());else if((e||!q)&&j(),b<d.rows.length?h===z||"before"===REDIPS.drag.rowPosition?(a.insertBefore(g,d.rows[b]),b=d.rows[b+1]):(a.insertBefore(g,d.rows[b].nextSibling),b=d.rows[b]):(a.appendChild(g),b=d.rows[0]),b&&(b.redips&&b.redips.empty_row)&&a.deleteRow(b.rowIndex),delete g.redips.empty_row,!e)"TABLE"!==Q.nodeName&&(Q=x("TABLE",Q)),REDIPS.drag.event.rowDropped(g,Q,o);0<g.getElementsByTagName("table").length&&
-r()}};Na=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");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;T=U=0;i.releaseCapture&&i.releaseCapture();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;xa(i);ra=document.documentElement.scrollWidth;sa=
-document.documentElement.scrollHeight;T=U=0;if(q&&"cell"===s&&(null===h||null===j||null===l))i.parentNode.removeChild(i),H[m.id]-=1,REDIPS.drag.event.notCloned();else if(null===h||null===j||null===l)REDIPS.drag.event.notMoved();else{h<f.length?(b=f[h],REDIPS.drag.td.target=k.target=b.rows[j].cells[l],Y(h,j,l,Z),c=h,d=j):null===u||null===w||null===A?(b=f[z],REDIPS.drag.td.target=k.target=b.rows[I].cells[V],Y(z,I,V,Z),c=z,d=I):(b=f[u],REDIPS.drag.td.target=k.target=b.rows[w].cells[A],Y(u,w,A,Z),c=u,
-d=w);if("row"===s)if(ta)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.empty_row;q?REDIPS.drag.event.rowNotCloned():REDIPS.drag.event.rowDroppedSource(k.target)}else Ga(c,d);else REDIPS.drag.event.rowNotMoved();else if(!q&&!fa)REDIPS.drag.event.notMoved();else if(q&&z===h&&I===j&&V===l)i.parentNode.removeChild(i),
-H[m.id]-=1,REDIPS.drag.event.notCloned();else if(q&&!0===REDIPS.drag.deleteCloned&&(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<k.target.className.indexOf(REDIPS.drag.trash.className))i.parentNode.removeChild(i),REDIPS.drag.trash.question?setTimeout(function(){if(confirm(REDIPS.drag.trash.question))wa();else{if(!q){f[z].rows[I].cells[V].appendChild(i);v()}REDIPS.drag.event.undeleted()}},
-20):wa();else if("switch"===REDIPS.drag.dropMode)if(a=REDIPS.drag.event.droppedBefore(k.target),!1===a)ga(!1);else{i.parentNode.removeChild(i);b=k.target.getElementsByTagName("div");c=b.length;for(a=0;a<c;a++)void 0!==b[0]&&(REDIPS.drag.objOld=m=b[0],k.source.appendChild(m),R(m));ga();c&&REDIPS.drag.event.switched()}else"overwrite"===REDIPS.drag.dropMode?(a=REDIPS.drag.event.droppedBefore(k.target),!1!==a&&ma(k.target)):a=REDIPS.drag.event.droppedBefore(k.target),ga(a);"cell"===s&&0<i.getElementsByTagName("table").length&&
-r();v();REDIPS.drag.event.finish()}u=w=A=null};ga=function(a){!1!==a?("shift"===REDIPS.drag.dropMode&&(Oa(k.target)||"always"===REDIPS.drag.shift.after)&&na(k.source,k.target),"top"===REDIPS.drag.multipleDrop&&k.target.hasChildNodes()?k.target.insertBefore(i,k.target.firstChild):k.target.appendChild(i),R(i),REDIPS.drag.event.dropped(k.target),q&&(REDIPS.drag.event.clonedDropped(k.target),Ba())):q&&i.parentNode.removeChild(i)};R=function(a,b){!1===b?(a.onmousedown=null,a.ontouchstart=null,a.ondblclick=
-null):(a.onmousedown=va,a.ontouchstart=va,a.ondblclick=Ja)};xa=function(a){a.style.top="";a.style.left="";a.style.position="";a.style.zIndex=""};wa=function(){var a;q&&Ba();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"}na(k.source,Da(a,k.source)[2])}REDIPS.drag.event.deleted(q)};ca=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):(d=W=a.clientX,e=X=a.clientY);c=Math.abs(Pa-d);g=Math.abs(Qa-e);if(!ta){if("cell"===s&&(aa||!0===REDIPS.drag.cloneKey.div&&Ha))REDIPS.drag.objOld=m=i,REDIPS.drag.obj=i=la(i,!0),q=!0,REDIPS.drag.event.cloned();else{if("row"===s){if(aa||!0===REDIPS.drag.cloneKey.row&&Ha)q=!0;REDIPS.drag.objOld=m=i;REDIPS.drag.obj=i=ea(i);i.style.zIndex=999}i.setCapture&&i.setCapture();i.style.position="fixed";v();S();"row"===
-s&&(q?REDIPS.drag.event.rowCloned():REDIPS.drag.event.rowMoved())}ia();d>F-p[1]&&(i.style.left=F-(p[1]+p[3])+"px");e>G-p[2]&&(i.style.top=G-(p[0]+p[2])+"px")}ta=!0;if("cell"===s&&(7<c||7<g)&&!fa)fa=!0,ia(),REDIPS.drag.event.moved(q);d>p[3]&&d<F-p[1]&&(i.style.left=d-p[3]+"px");e>p[0]&&e<G-p[2]&&(i.style.top=e-p[0]+"px");if(d<C[1]&&d>C[3]&&e<C[2]&&e>C[0]&&0===T&&0===U&&(n.containTable||d<n[3]||d>n[1]||e<n[0]||e>n[2]))S(),ha();if(REDIPS.drag.scroll.enable){K=b-(F/2>d?d-p[3]:F-d-p[1]);if(0<K){if(K>b&&
-(K=b),c=N()[0],K*=d<F/2?-1:1,!(0>K&&0>=c||0<K&&c>=ra-F)&&0===T++)REDIPS.event.remove(window,"scroll",v),ja(window)}else K=0;L=b-(G/2>e?e-p[0]:G-e-p[2]);if(0<L){if(L>b&&(L=b),c=N()[1],L*=e<G/2?-1:1,!(0>L&&0>=c||0<L&&c>=sa-G)&&0===U++)REDIPS.event.remove(window,"scroll",v),ka(window)}else L=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]){O=b-(c.midstX>d?d-p[3]-c.offset[3]:c.offset[1]-d-p[1]);0<O?(O>b&&(O=b),O*=d<c.midstX?-1:1,0===T++&&(REDIPS.event.remove(c.div,
-"scroll",v),ja(c.div))):O=0;P=b-(c.midstY>e?e-p[0]-c.offset[0]:c.offset[2]-e-p[2]);0<P?(P>b&&(P=b),P*=e<c.midstY?-1:1,0===U++&&(REDIPS.event.remove(c.div,"scroll",v),ka(c.div))):P=0;break}else O=P=0}a.cancelBubble=!0;a.stopPropagation&&a.stopPropagation()};ha=function(){if(h<f.length&&(h!==u||j!==w||l!==A))null!==u&&(null!==w&&null!==A)&&(Y(u,w,A,Z),REDIPS.drag.td.previous=k.previous=f[u].rows[w].cells[A],REDIPS.drag.td.current=k.current=f[h].rows[j].cells[l],"switching"===REDIPS.drag.dropMode&&"cell"===
-s&&(da(k.current,k.previous),v(),S()),"cell"===s?REDIPS.drag.event.changed(k.current):"row"===s&&(h!==u||j!==w)&&REDIPS.drag.event.rowChanged(k.current)),ia()};ya=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;ra=document.documentElement.scrollWidth;sa=document.documentElement.scrollHeight;v()};S=function(){var a,b,c,d,e,g;c=[];a=function(){null!==u&&(null!==w&&null!==A)&&(h=u,j=w,l=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]?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]){n[0]=c[j][0];if(void 0!==c[j+1])n[2]=c[j+1][0];else for(d=j+2;d<c.length;d++)if(void 0!==c[d]){n[2]=c[d][0];break}if(g<=n[2])break}d=j;j===c.length-1&&(n[0]=c[j][0],n[2]=f[h].redips.offset[2]);do for(l=e=f[h].rows[j].cells.length-1;0<=l&&!(n[3]=c[j][3]+f[h].rows[j].cells[l].offsetLeft,
-n[1]=n[3]+f[h].rows[j].cells[l].offsetWidth,n[3]<=b&&b<=n[1]);l--);while(f[h].redips.rowspan&&-1===l&&0<j--);0>j||0>l?a():j!==d&&(n[0]=c[j][0],n[2]=n[0]+f[h].rows[j].cells[l].offsetHeight,(g<n[0]||g>n[2])&&a());b=f[h].rows[j].cells[l];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(ua.div[i.id])){a();break}}else if(void 0!==
-ua.div[i.id]&&"deny"===ua.other){a();break}else if(g=-1<b.className.indexOf(REDIPS.drag.mark.cname)?!0:!1,(!0===g&&"deny"===REDIPS.drag.mark.action||!1===g&&"allow"===REDIPS.drag.mark.action)&&-1===b.className.indexOf(Ra.exception[i.id])){a();break}g=-1<b.className.indexOf("single")?!0:!1;if("cell"===s){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!==u&&null!==w&&null!==A)&&(z!==h||I!==j||V!==l)){a();break}}if(-1<b.className.indexOf("rowhandler")){a();break}if(b.parentNode.redips&&b.parentNode.redips.empty_row){a();break}}break}};ia=function(){h<f.length&&(null!==h&&null!==j&&null!==l)&&(Z=za(h,j,l),Y(h,j,l),u=h,w=j,A=l)};Y=function(a,b,c,d){if("cell"===s&&fa)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],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"===s){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(),void 0!==REDIPS.drag.hover.borderTr&&(void 0===d?h===z?j<I?c.borderTop=REDIPS.drag.hover.borderTr:c.borderBottom=REDIPS.drag.hover.borderTr:"before"===REDIPS.drag.rowPosition?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]))}};za=function(a,b,c){var d={color:[],top:[],right:[],bottom:[],left:[]},e=function(a,b){var c="border"+b+"Style",d="border"+b+"Color";return[D(a,"border"+b+"Width"),D(a,c),D(a,d)]};if("cell"===s)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,"Bottom"))}return d};B=function(a,b,c){var d=0,e=0,g=a;"fixed"!==b&&(b=N(),d=0-b[0],e=0-b[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]};v=function(){var a,b,c,d;for(a=0;a<f.length;a++){c=
-[];d=D(f[a],"position");"fixed"!==d&&(d=D(f[a].parentNode,"position"));for(b=f[a].rows.length-1;0<=b;b--)"none"!==f[a].rows[b].style.display&&(c[b]=B(f[a].rows[b],d));f[a].redips.offset=B(f[a],d);f[a].redips.row_offset=c}C=B(y);for(a=0;a<M.length;a++)d=D(M[a].div,"position"),b=B(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};N=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&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)?(a=document.documentElement.scrollLeft,b=document.documentElement.scrollTop):a=b=0;return[a,b]};ja=function(a){var b,c;b=W;c=X;0<T&&(v(),S(),b<C[1]&&(b>C[3]&&c<C[2]&&c>C[0])&&ha());"object"===typeof a&&(t=a);t===window?(a=N()[0],b=ra-F,c=K):(a=t.scrollLeft,b=t.scrollWidth-t.clientWidth,c=O);0<T&&(0>c&&0<a||0<c&&a<b)?(t===
-window?(window.scrollBy(c,0),N(),a=parseInt(i.style.left,10),isNaN(a)):t.scrollLeft+=c,setTimeout(ja,REDIPS.drag.scroll.speed)):(REDIPS.event.add(t,"scroll",v),T=0,n=[0,0,0,0])};ka=function(a){var b,c;b=W;c=X;0<U&&(v(),S(),b<C[1]&&(b>C[3]&&c<C[2]&&c>C[0])&&ha());"object"===typeof a&&(t=a);t===window?(a=N()[1],b=sa-G,c=L):(a=t.scrollTop,b=t.scrollHeight-t.clientHeight,c=P);0<U&&(0>c&&0<a||0<c&&a<b)?(t===window?(window.scrollBy(0,c),N(),a=parseInt(i.style.top,10),isNaN(a)):t.scrollTop+=c,setTimeout(ka,
-REDIPS.drag.scroll.speed)):(REDIPS.event.add(t,"scroll",v),U=0,n=[0,0,0,0])};la=function(a,b){var c=a.cloneNode(!0),d=c.className,e,g;!0===b&&(document.getElementById("redips_clone").appendChild(c),c.style.zIndex=999,c.style.position="fixed",e=B(a),g=B(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=qa(d);void 0===H[a.id]&&(H[a.id]=0);c.id=a.id+"c"+H[a.id];H[a.id]+=1;Aa(a,c);return c};Aa=
-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,a.redips.enabled&&R(b))};c[1]=function(a,b){a.redips&&(b.redips={},b.redips.empty_row=a.redips.empty_row)};d=function(d){var g,f,o;f=["DIV","TR"];g=a.getElementsByTagName(f[d]);f=b.getElementsByTagName(f[d]);for(o=0;o<f.length;o++)c[d](g[o],f[o])};if("DIV"===a.nodeName)c[0](a,b);else if("TR"===a.nodeName)c[1](a,b);d(0);d(1)};Ba=function(){var a,b,c;c=m.className;
-a=c.match(/climit(\d)_(\d+)/);null!==a&&(b=parseInt(a[1],10),a=parseInt(a[2],10),a-=1,c=c.replace(/climit\d_\d+/g,""),0>=a?(c=c.replace("clone",""),2===b?(c=c.replace("drag",""),R(m,!1),m.style.cursor="auto",REDIPS.drag.event.clonedEnd2()):REDIPS.drag.event.clonedEnd1()):c=c+" climit"+b+"_"+a,m.className=qa(c))};Ca=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};E=function(a,b){var c,d,e,g=[],f=[],o,i,h,j,k=/\bdrag\b/i,l=/\bnoautoscroll\b/i;i=REDIPS.drag.style.opacityDisabled;!0===a||"init"===a?(o=REDIPS.drag.style.borderEnabled,h="move",j=!0):(o=REDIPS.drag.style.borderDisabled,h="auto",j=!1);void 0===b?g=y.getElementsByTagName("div"):"string"===typeof b?g=document.querySelectorAll(b):g[0]=b;for(d=c=0;c<g.length;c++)if(k.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="",g[c].style.filter=""):!1===a&&"number"===typeof i&&(g[c].style.opacity=i/100,g[c].style.filter="alpha(opacity="+i+")"),R(g[c],j),g[c].style.borderStyle=o,g[c].style.cursor=h,g[c].redips.enabled=j;else if("init"===a&&(e=D(g[c],"overflow"),"visible"!==e)){REDIPS.event.add(g[c],"scroll",v);e=D(g[c],"position");f=B(g[c],e,!1);e=l.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=M[d];d++}};D=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};Da=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;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){var c=REDIPS.drag.getPosition(b);REDIPS.drag.moveObject({obj:a,target:c,callback:function(a){Ia--;0===Ia&&(REDIPS.drag.event.relocated(),a=REDIPS.drag.findParent("TABLE",a),REDIPS.drag.enableTable(!0,a))}})};if(a!==b&&!("object"!==typeof a||
-"object"!==typeof b))if(e=a.childNodes.length,"animation"===c){0<e&&(c=x("TABLE",b),REDIPS.drag.enableTable(!1,c));for(c=0;c<e;c++)1===a.childNodes[c].nodeType&&"DIV"===a.childNodes[c].nodeName&&(Ia++,d(a.childNodes[c],b))}else for(d=c=0;c<e;c++)1===a.childNodes[d].nodeType&&"DIV"===a.childNodes[d].nodeName?(g=a.childNodes[d],b.appendChild(g),R(g)):d++};ma=function(a){var b,c;if("TD"!==a.nodeName)return!1;c=a.childNodes.length;for(b=0;b<c;b++)a.removeChild(a.childNodes[0])};na=function(a,b){var c,
-d,e,g,f,o,i,h,j,k,l;if(a!==b){f=REDIPS.drag.shift.mode;c=x("TABLE",a);d=x("TABLE",b);o=La(d);c===d&&(e=[a.redips.rowIndex,a.redips.cellIndex]);g=[b.redips.rowIndex,b.redips.cellIndex];i=d.rows.length-1;h=Ma(d);switch(f){case "vertical2":c=c===d&&a.cellIndex===b.cellIndex?e:[i,b.redips.cellIndex];break;case "horizontal2":c=c===d&&a.parentNode.rowIndex===b.parentNode.rowIndex?e:[b.redips.rowIndex,h];break;default:c=c===d?e:[i,h]}"vertical1"===f||"vertical2"===f?(f=1E3*c[1]+c[0]<1E3*g[1]+g[0]?1:-1,l=
-i,d=0,e=1):(f=1E3*c[0]+c[1]<1E3*g[0]+g[1]?1:-1,l=h,d=1,e=0);for(;c[0]!==g[0]||c[1]!==g[1];)if(h=o[c[0]+"-"+c[1]],c[d]+=f,0>c[d]?(c[d]=l,c[e]--):c[d]>l&&(c[d]=0,c[e]++),i=o[c[0]+"-"+c[1]],void 0!==i&&(j=i),void 0!==h&&(k=h),void 0!==i&&void 0!==k||void 0!==j&&void 0!==h)REDIPS.drag.animation.shift?da(j,k,"animation"):da(j,k)}};La=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+"-"+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};Ma=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};Ea=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=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(){Ea(a,b)},REDIPS.drag.animation.pause*c):(xa(b.obj),b.obj.redips.animated=!1,"cell"===b.mode?(!0===b.overwrite&&ma(b.targetCell),b.targetCell.appendChild(b.obj),R(b.obj)):Ga(oa(b.target[0]),b.target[1],b.obj),"function"===typeof b.callback&&b.callback(b.obj))};Fa=function(a){var b,
-c,d;b=[];b=c=d=-1;if(void 0===a)b=h<f.length?f[h].redips.idx:null===u||null===w||null===A?f[z].redips.idx:f[u].redips.idx,c=f[z].redips.idx,b=[b,j,l,c,I,V];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};oa=function(a){var b;for(b=0;b<f.length&&f[b].redips.idx!==a;b++);return b};qa=function(a){void 0!==a&&(a=a.replace(/^\s+|\s+$/g,"").replace(/\s{2,}/g,
-" "));return a};Oa=function(a){var b;for(b=0;b<a.childNodes.length;b++)if(1===a.childNodes[b].nodeType)return!0;return!1};pa=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="+b+")")}else a.style.opacity=b/100,a.style.filter="alpha(opacity="+b+")",a.style.backgroundColor=c?c:""};return{obj:i,objOld:m,mode:s,td:k,hover:{colorTd:"#E7AB83",colorTr:"#E7AB83"},scroll:{enable:!0,bound:25,speed:20},only:ua,mark:Ra,style:{borderEnabled:"solid",borderDisabled:"dotted",opacityDisabled:"",rowEmptyColor:"white"},trash:{className:"trash",question:null,questionRow:null},saveParamName:"p",dropMode:"multiple",multipleDrop:"bottom",deleteCloned:!0,cloneKey:{div:!1,row:!1},
-animation:{pause:20,step:2,shift:!1},shift:{mode:"horizontal1",after:"default"},rowPosition:"before",tableSort:!0,init:function(a){var b;if(void 0===a||"string"!==typeof a)a="drag";y=document.getElementById(a);document.getElementById("redips_clone")||(a=document.createElement("div"),a.id="redips_clone",a.style.width=a.style.height="1px",y.appendChild(a));E("init");r();ya();REDIPS.event.add(window,"resize",ya);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);REDIPS.event.add(window,"scroll",v)},initTables:r,enableDrag:E,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:la,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;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:da,emptyCell:ma,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"===typeof a.obj&&"DIV"===a.obj.nodeName&&(b.obj=b.objOld=a.obj);if("row"===a.mode){b.mode="row";h=oa(a.source[0]);i=a.source[1];m=b.objOld=f[h].rows[i];if(m.redips&&!0===m.redips.empty_row)return!1;b.obj=ea(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.empty_row)return!1;b.obj=ea(b.objOld,"animated")}else b.mode="cell";if(!("object"!==typeof b.obj||null===b.obj))return b.obj.style.zIndex=
-999,y!==b.obj.redips.container&&(y=b.obj.redips.container,r()),h=B(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=la(b.obj,!0),REDIPS.drag.event.cloned(b.obj)),void 0===a.target&&(a.target=Fa()),b.target=a.target,h=oa(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=B(b.targetCell),i=h[1]-h[3],a=h[2]-h[0],e=h[3]+(i-e)/2,g=h[0]+(a-g)/2):(h=B(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.animated=!0,Ea(h,b),[b.obj,b.objOld]},shiftCells:na,deleteObject:function(a){"object"===typeof a&&"DIV"===a.nodeName?a.parentNode.removeChild(a):"string"===typeof a&&(a=document.getElementById(a))&&a.parentNode.removeChild(a)},
-getPosition:Fa,rowOpacity:pa,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.empty_row=!0;pa(a,"empty",c)},getScrollPosition:N,getStyle:D,findParent:x,findCell:Da,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(){},relocated: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(){}}}}();
-REDIPS.event||(REDIPS.event=function(){return{add:function(r,E,J){r.addEventListener?r.addEventListener(E,J,!1):r.attachEvent?r.attachEvent("on"+E,J):r["on"+E]=J},remove:function(r,E,J){r.removeEventListener?r.removeEventListener(E,J,!1):r.detachEvent?r.detachEvent("on"+E,J):r["on"+E]=null}}}());
+REDIPS.drag=function(){var q,B,J,wa,Ja,Ka,ba,ca,ga,xa,ya,V,ha,za,R,ia,Y,Aa,C,v,N,ja,ka,la,Ba,ma,Ca,E,x,Da,da,na,oa,La,Ma,Ea,pa,Fa,qa,ea,Ga,Na,ra,Oa,o=null,F=0,G=0,sa=null,ta=null,K=0,L=0,O=0,P=0,S=0,T=0,t,Z,M=[],f=[],$,ua,p,H=[],n=[],y=null,D=null,W=0,X=0,Pa=0,Qa=0,fa=!1,Ha=!1,aa=!1,Ia=0,h=null,u=null,z=null,j=null,w=null,I=null,l=null,A=null,U=null,i=!1,m=!1,r="cell",va={div:[],cname:"only",other:"deny"},Ra={action:"deny",cname:"mark",exception:[]},k={},Sa={keyDiv:!1,keyRow:!1,sendBack:!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;d=f[b].getElementsByTagName("td");c=0;for(g=!1;c<d.length;c++)if(1<d[c].rowSpan){g=!0;break}f[b].redips.rowspan=
+g;b++}a=0;for(e=$=1;a<f.length;a++)if(0===f[a].redips.nestedLevel){f[a].redips.nestedGroup=e;f[a].redips.sort=100*$;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*$+c[b].redips.nestedLevel);e++;$++}};wa=function(a){var b=a||window.event,c,d;if(!0===this.redips.animated)return!0;b.cancelBubble=!0;b.stopPropagation&&b.stopPropagation();Ha=b.shiftKey;a=b.which?b.which:b.button;if(Ca(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);Pa=a;Qa=d;fa=!1;REDIPS.drag.objOld=m=i||this;REDIPS.drag.obj=i=this;aa=-1<i.className.indexOf("clone")?!0:!1;REDIPS.drag.tableSort&&Ka(i);y!==i.redips.container&&(y=i.redips.container,q());-1===i.className.indexOf("row")?REDIPS.drag.mode=
+r="cell":(REDIPS.drag.mode=r="row",REDIPS.drag.obj=i=ea(i));v();!aa&&"cell"===r&&(i.style.zIndex=999);h=j=l=null;R();z=u=h;I=w=j;U=A=l;REDIPS.drag.td.source=k.source=x("TD",i);REDIPS.drag.td.current=k.current=k.source;REDIPS.drag.td.previous=k.previous=k.source;"cell"===r?REDIPS.drag.event.clicked(k.current):REDIPS.drag.event.rowClicked(k.current);if(null===h||null===j||null===l)if(R(),z=u=h,I=w=j,U=A=l,null===h||null===j||null===l)return!0;ua=p=!1;REDIPS.event.add(document,"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!==h&&(null!==j&&null!==l)&&(Z=Aa(h,j,l));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(!Ca(b)){b.shiftKey&&document.selection.clear();return false}};return!1};Ja=function(){REDIPS.drag.event.dblClicked()};Ka=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*$+f[a].redips.nestedLevel);f.sort(function(a,b){return b.redips.sort-a.redips.sort});$++};ea=function(a,b){var c,d,e,g,f,s;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);aa&&p&&(g=d.redips.div,g.className=ra(g.className.replace("clone","")));c=a.cloneNode(!0);aa&&p&&(g.className+=" 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(s=0;s<e.cells.length;s++)if(-1<e.cells[s].className.indexOf("rowhandler")){g=!1;break}}c.deleteRow(f)}p||(d.redips.empty_row=g);c.redips={};c.redips.container=a.redips.container;c.redips.source_row=d;Na(d,c.rows[0]);Ba(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]+"px";return c};Ga=function(a,
+b,c){var d=f[a],a=d.rows[0].parentNode,e=!1,g,Q,s,j;j=function(){m.redips.empty_row?qa(m,"empty",REDIPS.drag.style.rowEmptyColor):(Q=x("TABLE",Q),Q.deleteRow(s))};void 0===c?c=i:e=!0;Q=c.redips.source_row;s=Q.rowIndex;g=c.getElementsByTagName("tr")[0];c.parentNode.removeChild(c);if(!1!==REDIPS.drag.event.rowDroppedBefore(s)){if(!e&&-1<k.target.className.indexOf(REDIPS.drag.trash.className))p?REDIPS.drag.event.rowDeleted():REDIPS.drag.trash.questionRow?confirm(REDIPS.drag.trash.questionRow)?(j(),REDIPS.drag.event.rowDeleted()):
+(delete m.redips.empty_row,REDIPS.drag.event.rowUndeleted()):(j(),REDIPS.drag.event.rowDeleted());else if((e||!p)&&j(),b<d.rows.length?h===z||"before"===REDIPS.drag.rowPosition?(a.insertBefore(g,d.rows[b]),b=d.rows[b+1]):(a.insertBefore(g,d.rows[b].nextSibling),b=d.rows[b]):(a.appendChild(g),b=d.rows[0]),b&&(b.redips&&b.redips.empty_row)&&a.deleteRow(b.rowIndex),delete g.redips.empty_row,!e)"TABLE"!==Q.nodeName&&(Q=x("TABLE",Q)),REDIPS.drag.event.rowDropped(g,Q,s);0<g.getElementsByTagName("table").length&&
+q()}};Na=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");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;S=T=0;i.releaseCapture&&i.releaseCapture();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;ya(i);sa=document.documentElement.scrollWidth;ta=
+document.documentElement.scrollHeight;S=T=0;if(p&&"cell"===r&&(null===h||null===j||null===l))i.parentNode.removeChild(i),H[m.id]-=1,REDIPS.drag.event.notCloned();else if(null===h||null===j||null===l)REDIPS.drag.event.notMoved();else{h<f.length?(b=f[h],REDIPS.drag.td.target=k.target=b.rows[j].cells[l],Y(h,j,l,Z),c=h,d=j):null===u||null===w||null===A?(b=f[z],REDIPS.drag.td.target=k.target=b.rows[I].cells[U],Y(z,I,U,Z),c=z,d=I):(b=f[u],REDIPS.drag.td.target=k.target=b.rows[w].cells[A],Y(u,w,A,Z),c=u,
+d=w);if("row"===r)if(ua)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.empty_row;p?REDIPS.drag.event.rowNotCloned():REDIPS.drag.event.rowDroppedSource(k.target)}else Ga(c,d);else REDIPS.drag.event.rowNotMoved();else if(!p&&!fa)REDIPS.drag.event.notMoved();else if(p&&z===h&&I===j&&U===l)i.parentNode.removeChild(i),
+H[m.id]-=1,REDIPS.drag.event.notCloned();else if(p&&!0===REDIPS.drag.deleteCloned&&(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<k.target.className.indexOf(REDIPS.drag.trash.className))i.parentNode.removeChild(i),REDIPS.drag.trash.question?setTimeout(function(){if(confirm(REDIPS.drag.trash.question))xa();else{if(!p){f[z].rows[I].cells[U].appendChild(i);v()}REDIPS.drag.event.undeleted()}},
+20):xa();else if("switch"===REDIPS.drag.dropMode)if(a=REDIPS.drag.event.droppedBefore(k.target),!1===a)ga(!1);else{i.parentNode.removeChild(i);b=k.target.getElementsByTagName("div");c=b.length;for(a=0;a<c;a++)void 0!==b[0]&&(REDIPS.drag.objOld=m=b[0],k.source.appendChild(m),V(m));ga();c&&REDIPS.drag.event.switched()}else"overwrite"===REDIPS.drag.dropMode?(a=REDIPS.drag.event.droppedBefore(k.target),!1!==a&&na(k.target)):a=REDIPS.drag.event.droppedBefore(k.target),ga(a);"cell"===r&&0<i.getElementsByTagName("table").length&&
+q();v();REDIPS.drag.event.finish()}u=w=A=null};ga=function(a){var b=null,c;if(!1!==a){if(!0===Sa.sendBack){a=k.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){ma(b,1);i.parentNode.removeChild(i);return}}"shift"===REDIPS.drag.dropMode&&(Oa(k.target)||"always"===REDIPS.drag.shift.after)&&oa(k.source,k.target);"top"===REDIPS.drag.multipleDrop&&k.target.hasChildNodes()?k.target.insertBefore(i,k.target.firstChild):k.target.appendChild(i);
+V(i);REDIPS.drag.event.dropped(k.target);p&&(REDIPS.drag.event.clonedDropped(k.target),ma(m,-1))}else p&&i.parentNode.removeChild(i)};V=function(a,b){!1===b?(a.onmousedown=null,a.ontouchstart=null,a.ondblclick=null):(a.onmousedown=wa,a.ontouchstart=wa,a.ondblclick=Ja)};ya=function(a){a.style.top="";a.style.left="";a.style.position="";a.style.zIndex=""};xa=function(){var a;p&&ma(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(k.source,Da(a,k.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=W=a.touches[0].clientX,e=X=a.touches[0].clientY):(d=W=a.clientX,e=X=a.clientY);c=Math.abs(Pa-d);g=Math.abs(Qa-e);if(!ua){if("cell"===r&&(aa||!0===REDIPS.drag.clone.keyDiv&&Ha))REDIPS.drag.objOld=m=i,REDIPS.drag.obj=i=la(i,!0),p=!0,REDIPS.drag.event.cloned();else{if("row"===r){if(aa||
+!0===REDIPS.drag.clone.keyRow&&Ha)p=!0;REDIPS.drag.objOld=m=i;REDIPS.drag.obj=i=ea(i);i.style.zIndex=999}i.setCapture&&i.setCapture();i.style.position="fixed";v();R();"row"===r&&(p?REDIPS.drag.event.rowCloned():REDIPS.drag.event.rowMoved())}ia();d>F-o[1]&&(i.style.left=F-(o[1]+o[3])+"px");e>G-o[2]&&(i.style.top=G-(o[0]+o[2])+"px")}ua=!0;if("cell"===r&&(7<c||7<g)&&!fa)fa=!0,ia(),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===S&&0===T&&(n.containTable||d<n[3]||d>n[1]||e<n[0]||e>n[2]))R(),ha();if(REDIPS.drag.scroll.enable){K=b-(F/2>d?d-o[3]:F-d-o[1]);if(0<K){if(K>b&&(K=b),c=N()[0],K*=d<F/2?-1:1,!(0>K&&0>=c||0<K&&c>=sa-F)&&0===S++)REDIPS.event.remove(window,"scroll",v),ja(window)}else K=0;L=b-(G/2>e?e-o[0]:G-e-o[2]);if(0<L){if(L>b&&(L=b),c=N()[1],L*=e<G/2?-1:1,!(0>L&&0>=c||0<L&&c>=ta-G)&&0===T++)REDIPS.event.remove(window,"scroll",v),ka(window)}else L=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]){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===S++&&(REDIPS.event.remove(c.div,"scroll",v),ja(c.div))):O=0;P=b-(c.midstY>e?e-o[0]-c.offset[0]:c.offset[2]-e-o[2]);0<P?(P>b&&(P=b),P*=e<c.midstY?-1:1,0===T++&&(REDIPS.event.remove(c.div,"scroll",v),ka(c.div))):P=0;break}else O=P=0}a.cancelBubble=!0;a.stopPropagation&&a.stopPropagation()};ha=function(){if(h<f.length&&(h!==u||j!==w||
+l!==A))null!==u&&(null!==w&&null!==A)&&(Y(u,w,A,Z),REDIPS.drag.td.previous=k.previous=f[u].rows[w].cells[A],REDIPS.drag.td.current=k.current=f[h].rows[j].cells[l],"switching"===REDIPS.drag.dropMode&&"cell"===r&&(da(k.current,k.previous),v(),R()),"cell"===r?REDIPS.drag.event.changed(k.current):"row"===r&&(h!==u||j!==w)&&REDIPS.drag.event.rowChanged(k.current)),ia()};za=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;sa=document.documentElement.scrollWidth;ta=document.documentElement.scrollHeight;v()};R=function(){var a,b,c,d,e,g;c=[];a=function(){null!==u&&(null!==w&&null!==A)&&(h=u,j=w,l=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]?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]){n[0]=c[j][0];if(void 0!==c[j+1])n[2]=c[j+1][0];else for(d=j+2;d<c.length;d++)if(void 0!==
+c[d]){n[2]=c[d][0];break}if(g<=n[2])break}d=j;j===c.length-1&&(n[0]=c[j][0],n[2]=f[h].redips.offset[2]);do for(l=e=f[h].rows[j].cells.length-1;0<=l&&!(n[3]=c[j][3]+f[h].rows[j].cells[l].offsetLeft,n[1]=n[3]+f[h].rows[j].cells[l].offsetWidth,n[3]<=b&&b<=n[1]);l--);while(f[h].redips.rowspan&&-1===l&&0<j--);0>j||0>l?a():j!==d&&(n[0]=c[j][0],n[2]=n[0]+f[h].rows[j].cells[l].offsetHeight,(g<n[0]||g>n[2])&&a());b=f[h].rows[j].cells[l];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(va.div[i.id])){a();break}}else if(void 0!==va.div[i.id]&&"deny"===va.other){a();break}else if(g=-1<b.className.indexOf(REDIPS.drag.mark.cname)?!0:!1,(!0===g&&"deny"===REDIPS.drag.mark.action||!1===g&&"allow"===REDIPS.drag.mark.action)&&-1===b.className.indexOf(Ra.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!==u&&null!==w&&null!==A)&&(z!==h||I!==j||U!==l)){a();break}}if(-1<b.className.indexOf("rowhandler")){a();break}if(b.parentNode.redips&&b.parentNode.redips.empty_row){a();break}}break}};ia=function(){h<f.length&&(null!==h&&null!==j&&
+null!==l)&&(Z=Aa(h,j,l),Y(h,j,l),u=h,w=j,A=l)};Y=function(a,b,c,d){if("cell"===r&&fa)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],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(),void 0!==REDIPS.drag.hover.borderTr&&(void 0===d?h===z?j<I?c.borderTop=REDIPS.drag.hover.borderTr:c.borderBottom=REDIPS.drag.hover.borderTr:"before"===REDIPS.drag.rowPosition?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]))}};Aa=function(a,b,c){var d={color:[],top:[],right:[],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,"Bottom"))}return d};C=function(a,b,c){var d=0,e=0,g=a;"fixed"!==b&&(b=N(),d=0-b[0],e=0-b[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]};v=function(){var a,b,c,d;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-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};N=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&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)?(a=document.documentElement.scrollLeft,b=document.documentElement.scrollTop):a=b=0;return[a,b]};ja=function(a){var b,c;b=W;c=X;0<S&&(v(),R(),b<D[1]&&(b>D[3]&&c<D[2]&&
+c>D[0])&&ha());"object"===typeof a&&(t=a);t===window?(a=N()[0],b=sa-F,c=K):(a=t.scrollLeft,b=t.scrollWidth-t.clientWidth,c=O);0<S&&(0>c&&0<a||0<c&&a<b)?(t===window?(window.scrollBy(c,0),N(),a=parseInt(i.style.left,10),isNaN(a)):t.scrollLeft+=c,setTimeout(ja,REDIPS.drag.scroll.speed)):(REDIPS.event.add(t,"scroll",v),S=0,n=[0,0,0,0])};ka=function(a){var b,c;b=W;c=X;0<T&&(v(),R(),b<D[1]&&(b>D[3]&&c<D[2]&&c>D[0])&&ha());"object"===typeof a&&(t=a);t===window?(a=N()[1],b=ta-G,c=L):(a=t.scrollTop,b=t.scrollHeight-
+t.clientHeight,c=P);0<T&&(0>c&&0<a||0<c&&a<b)?(t===window?(window.scrollBy(0,c),N(),a=parseInt(i.style.top,10),isNaN(a)):t.scrollTop+=c,setTimeout(ka,REDIPS.drag.scroll.speed)):(REDIPS.event.add(t,"scroll",v),T=0,n=[0,0,0,0])};la=function(a,b){var c=a.cloneNode(!0),d=c.className,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=ra(d);void 0===H[a.id]&&(H[a.id]=0);c.id=a.id+"c"+H[a.id];H[a.id]+=1;Ba(a,c);return c};Ba=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,a.redips.enabled&&V(b))};c[1]=function(a,b){a.redips&&(b.redips={},b.redips.empty_row=a.redips.empty_row)};d=function(d){var g,f,s;f=["DIV","TR"];g=a.getElementsByTagName(f[d]);f=b.getElementsByTagName(f[d]);for(s=0;s<f.length;s++)c[d](g[s],
+f[s])};if("DIV"===a.nodeName)c[0](a,b);else if("TR"===a.nodeName)c[1](a,b);d(0);d(1)};ma=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,"climit"+d+"_"+c),0>=c&&(e=e.replace("clone",""),2===d?(B(!1,a),REDIPS.drag.event.clonedEnd2()):REDIPS.drag.event.clonedEnd1()),a.className=ra(e))};Ca=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=[],s,i,h,j,k=/\bdrag\b/i,l=/\bnoautoscroll\b/i;i=REDIPS.drag.style.opacityDisabled;!0===a||"init"===a?(s=REDIPS.drag.style.borderEnabled,h="move",j=!0):(s=REDIPS.drag.style.borderDisabled,h="auto",j=!1);void 0===b?g=y.getElementsByTagName("div"):"string"===typeof b?g=document.querySelectorAll(b):
+g[0]=b;for(d=c=0;c<g.length;c++)if(k.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="",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=s,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",v);e=E(g[c],"position");f=C(g[c],
+e,!1);e=l.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=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};Da=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;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){var c=REDIPS.drag.getPosition(b);REDIPS.drag.moveObject({obj:a,target:c,callback:function(a){Ia--;
+0===Ia&&(REDIPS.drag.event.relocated(),a=REDIPS.drag.findParent("TABLE",a),REDIPS.drag.enableTable(!0,a))}})};if(a!==b&&!("object"!==typeof a||"object"!==typeof b))if(e=a.childNodes.length,"animation"===c){0<e&&(c=x("TABLE",b),REDIPS.drag.enableTable(!1,c));for(c=0;c<e;c++)1===a.childNodes[c].nodeType&&"DIV"===a.childNodes[c].nodeName&&(Ia++,d(a.childNodes[c],b))}else for(d=c=0;c<e;c++)1===a.childNodes[d].nodeType&&"DIV"===a.childNodes[d].nodeName?(g=a.childNodes[d],b.appendChild(g),V(g)):d++};na=
+function(a){var b,c;if("TD"!==a.nodeName)return!1;c=a.childNodes.length;for(b=0;b<c;b++)a.removeChild(a.childNodes[0])};oa=function(a,b){var c,d,e,g,f,i,h,j,k,l,m;if(a!==b){f=REDIPS.drag.shift.mode;c=x("TABLE",a);d=x("TABLE",b);i=La(d);c===d&&(e=[a.redips.rowIndex,a.redips.cellIndex]);g=[b.redips.rowIndex,b.redips.cellIndex];h=d.rows.length-1;j=Ma(d);switch(f){case "vertical2":c=c===d&&a.cellIndex===b.cellIndex?e:[h,b.redips.cellIndex];break;case "horizontal2":c=c===d&&a.parentNode.rowIndex===b.parentNode.rowIndex?
+e:[b.redips.rowIndex,j];break;default:c=c===d?e:[h,j]}"vertical1"===f||"vertical2"===f?(f=1E3*c[1]+c[0]<1E3*g[1]+g[0]?1:-1,m=h,d=0,e=1):(f=1E3*c[0]+c[1]<1E3*g[0]+g[1]?1:-1,m=j,d=1,e=0);for(;c[0]!==g[0]||c[1]!==g[1];)if(j=i[c[0]+"-"+c[1]],c[d]+=f,0>c[d]?(c[d]=m,c[e]--):c[d]>m&&(c[d]=0,c[e]++),h=i[c[0]+"-"+c[1]],void 0!==h&&(k=h),void 0!==j&&(l=j),void 0!==h&&void 0!==l||void 0!==k&&void 0!==j)REDIPS.drag.animation.shift?da(k,l,"animation"):da(k,l)}};La=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+"-"+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};Ma=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};Ea=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=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(){Ea(a,b)},REDIPS.drag.animation.pause*c):(ya(b.obj),b.obj.redips.animated=!1,"cell"===b.mode?(!0===b.overwrite&&na(b.targetCell),
+b.targetCell.appendChild(b.obj),V(b.obj)):Ga(pa(b.target[0]),b.target[1],b.obj),"function"===typeof b.callback&&b.callback(b.obj))};Fa=function(a){var b,c,d;b=[];b=c=d=-1;if(void 0===a)b=h<f.length?f[h].redips.idx:null===u||null===w||null===A?f[z].redips.idx:f[u].redips.idx,c=f[z].redips.idx,b=[b,j,l,c,I,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};
+pa=function(a){var b;for(b=0;b<f.length&&f[b].redips.idx!==a;b++);return b};ra=function(a){void 0!==a&&(a=a.replace(/^\s+|\s+$/g,"").replace(/\s{2,}/g," "));return a};Oa=function(a){var b;for(b=0;b<a.childNodes.length;b++)if(1===a.childNodes[b].nodeType)return!0;return!1};qa=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="+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:k,hover:{colorTd:"#E7AB83",colorTr:"#E7AB83"},scroll:{enable:!0,bound:25,speed:20},only:va,mark:Ra,style:{borderEnabled:"solid",borderDisabled:"dotted",opacityDisabled:"",rowEmptyColor:"white"},trash:{className:"trash",
+question:null,questionRow:null},saveParamName:"p",dropMode:"multiple",multipleDrop:"bottom",deleteCloned:!0,clone:Sa,animation:{pause:20,step:2,shift:!1},shift:{mode:"horizontal1",after:"default"},rowPosition:"before",tableSort:!0,init:function(a){var b;if(void 0===a||"string"!==typeof a)a="drag";y=document.getElementById(a);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();za();REDIPS.event.add(window,
+"resize",za);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);REDIPS.event.add(window,"scroll",v)},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:la,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;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:da,emptyCell:na,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"===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.empty_row)return!1;b.obj=ea(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.empty_row)return!1;
+b.obj=ea(b.objOld,"animated")}else b.mode="cell";if(!("object"!==typeof b.obj||null===b.obj))return b.obj.style.zIndex=999,y!==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=la(b.obj,!0),REDIPS.drag.event.cloned(b.obj)),void 0===a.target&&(a.target=Fa()),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],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.animated=!0,Ea(h,b),[b.obj,b.objOld]},shiftCells:oa,deleteObject:function(a){"object"===typeof a&&
+"DIV"===a.nodeName?a.parentNode.removeChild(a):"string"===typeof a&&(a=document.getElementById(a))&&a.parentNode.removeChild(a)},getPosition:Fa,rowOpacity:qa,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.empty_row=!0;qa(a,"empty",c)},getScrollPosition:N,getStyle:E,findParent:x,findCell:Da,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(){},relocated: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(){}}}}();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}}}());
View
137 redips-drag-source.js
@@ -3,7 +3,7 @@ Copyright (c) 2008-2011, 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.0.0
-Nov 1, 2012.
+Nov 8, 2012.
*/
/*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 */
@@ -166,8 +166,9 @@ REDIPS.drag = (function () {
shift = {mode : 'horizontal1', // (object) contains shift modes (horizontal1, horizontal2, vertical1, vertical2) and how to shift elements (always, if DIV element is dropped to the empty cell as well or if DIV element is deleted)
after : 'default'},
- cloneKey = {div : false, // (boolean) if true, elements could be cloned with pressed SHIFT key
- row : false}, // (boolean) if true, rows could be cloned with pressed SHIFT key
+ clone = {keyDiv : false, // (boolean) if true, elements could be cloned with pressed SHIFT key
+ keyRow : false, // (boolean) if true, rows could be cloned with pressed SHIFT key
+ sendBack : false}, // (boolean) if true, then cloned element can be returned to its source
rowPosition = 'before', // (string) drop row before or after highlighted row (values are "before" or "after")
// (object) event handlers
event = {changed : function () {},
@@ -224,7 +225,7 @@ REDIPS.drag = (function () {
var self = this, // assign reference to current object to "self"
i, // used in local for loops
imgs, // collect images inside div=drag
- redips_clone; // reference to the DIV element needed for cloned elements
+ redipsClone; // reference to the DIV element needed for cloned elements
// if drag container is undefined or input parameter is not a string, then set reference to DIV element with default id="drag"
if (dc === undefined || typeof(dc) !== 'string') {
dc = 'drag';
@@ -235,10 +236,10 @@ REDIPS.drag = (function () {
// if automatic creation isn't precise enough, user can manually create and place element with id="redips_clone" to prevent window expanding
// (then this code will be skipped)
if (!document.getElementById('redips_clone')) {
- redips_clone = document.createElement('div');
- redips_clone.id = 'redips_clone';
- redips_clone.style.width = redips_clone.style.height = '1px';
- dragContainer.appendChild(redips_clone);
+ redipsClone = document.createElement('div');
+ redipsClone.id = 'redips_clone';
+ redipsClone.style.width = redipsClone.style.height = '1px';
+ dragContainer.appendChild(redipsClone);
}
// attach onmousedown event handler to the DIV elements
// attach onscroll='calculateCells' for DIV elements with 'scroll' in class name (prepare scrollable container areas)
@@ -323,7 +324,7 @@ REDIPS.drag = (function () {
}
// loop through tables and define table sort parameter
for (i = 0, j = 0; i < tableNodeList.length; i++) {
- // skip table if table belongs to the "redips_clone" container (possible for cloned rows - if initTables() is called after rowClone())
+ // skip table if table belongs to the "redipsClone" container (possible for cloned rows - if initTables() is called after rowClone())
// or table has "nolayout" className
if (tableNodeList[i].parentNode.id === 'redips_clone' || tableNodeList[i].className.indexOf('nolayout') > -1) {
continue;
@@ -1275,8 +1276,36 @@ REDIPS.drag = (function () {
* @memberOf REDIPS.drag#
*/
elementDrop = function (drop) {
+ var cloneSourceDiv = null, // clone source element (needed if clone.sendBack is set to true)
+ div, // nodeList of DIV elements in target cell (needed if clone.sendBack is set to true)
+ i; // local variables
// if input parameter is not "false" then DIV element will be dropped to the table cell
if (drop !== false) {
+ // if clone.sendBack is set to true then try to find source element in target cell
+ if (clone.sendBack === true) {
+ // search all DIV elements in target cell
+ div = td.target.getElementsByTagName('DIV');
+ // loop through all DIV elements in target cell
+ for (i = 0; i < div.length; i++) {
+ // if DIV in target cell is source of dropped DIV element (dropped DIV id and id of DIV in target cell has the same name beginning like "d12c2" and "d12")
+ // of course, the case where source DIV element is dropped to the cell with cloned DIV element should be excluded (possible in climit1 type)
+ if (obj !== div[i] && obj.id.indexOf(div[i].id) === 0) {
+ // set reference to cloneSourceDiv element
+ cloneSourceDiv = div[i];
+ // break the loop
+ break;
+ }
+ }
+ // if clone source DIV element exists in target cell
+ if (cloneSourceDiv) {
+ // update climit class (increment by 1)
+ cloneLimit(cloneSourceDiv, 1);
+ // delete dropped DIV element
+ obj.parentNode.removeChild(obj);
+ // return from the method (everything is done)
+ return;
+ }
+ }
// shift table content if dropMode is set to "shift" and target cell is not empty or shift.after option is set to always
// has_child() is a private method
if (REDIPS.drag.dropMode === 'shift' && (hasChilds(td.target) || REDIPS.drag.shift.after === 'always')) {
@@ -1298,7 +1327,7 @@ REDIPS.drag = (function () {
// call clonedDropped event handler
REDIPS.drag.event.clonedDropped(td.target);
// update climit1_X or climit2_X classname
- cloneLimit();
+ cloneLimit(objOld, -1);
}
}
// cloned element should be deleted
@@ -1360,7 +1389,7 @@ REDIPS.drag = (function () {
var param;
// if object is cloned, update climit1_X or climit2_X classname
if (cloned) {
- cloneLimit();
+ cloneLimit(objOld, -1);
}
// shift table content if dropMode is set to "shift" and shift.after is set to "delete" or "always"
if (REDIPS.drag.dropMode === 'shift' && (REDIPS.drag.shift.after === 'delete' || REDIPS.drag.shift.after === 'always')) {
@@ -1420,7 +1449,7 @@ REDIPS.drag = (function () {
// if moved object is element and has clone in class name or cloneShiftKey is enabled and shift key is pressed
// then remember previous object, clone object, set cloned flag and call event.cloned
// (shiftKey is defined in handler_mousedown)
- if (mode === 'cell' && (clone_class || (REDIPS.drag.cloneKey.div === true && shiftKey))) {
+ if (mode === 'cell' && (clone_class || (REDIPS.drag.clone.keyDiv === true && shiftKey))) {
// remember previous object (original element)
REDIPS.drag.objOld = objOld = obj;
// clone DIV element ready for dragging
@@ -1438,7 +1467,7 @@ REDIPS.drag = (function () {
if (mode === 'row') {
// settings of "cloned" flag should go before calling rowClone() because "cloned" is needed in rowClone()
// to cut out "clone" class name from <div class="drag row clone"> elements
- if (clone_class || (REDIPS.drag.cloneKey.row === true && shiftKey)) {
+ if (clone_class || (REDIPS.drag.clone.keyRow === true && shiftKey)) {
cloned = true;
}
// remember reference to the source row
@@ -2516,46 +2545,53 @@ REDIPS.drag = (function () {
/**
- * After element is cloned, this method will update climit1_X or climit2_X class names (X defines number of elements to clone).
- * Method is called from handlerOnMouseUp method.
+ * Method updates climit1_X or climit2_X class name (X defines cloning limit).
* <ul>
* <li>climit1_X - after cloning X elements, last element will be normal drag-able element</li>
* <li>climit2_X - after cloning X elements, last element will stay unmovable</li>
* </ul>
+ * @param {HTMLElement} el Element on which cname class should be updated.
+ * @param {Integer} value Increment or decrement climit value.
* @see <a href="#handlerOnMouseUp">handlerOnMouseUp</a>
* @private
* @memberOf REDIPS.drag#
*/
- cloneLimit = function () {
+ cloneLimit = function (el, value) {
// declare local variables
var matchArray, // match array
limitType, // limit type (1 - clone becomes "normal" drag element at last; 2 - clone element stays immovable)
limit, // limit number
classes; // class names of clone element
- // set classes variable for clone object (objOld is reference to the clone object not cloned)
- classes = objOld.className;
+ // read class name from element
+ classes = el.className;
// match climit class name
matchArray = classes.match(/climit(\d)_(\d+)/);
- // if class name contains climit option
+ // if DIV class contains climit
if (matchArray !== null) {
// prepare limitType (1 or 2) and limit
limitType = parseInt(matchArray[1], 10);
limit = parseInt(matchArray[2], 10);
- // decrease limit number and cut out "climit" class
- limit -= 1;
- classes = classes.replace(/climit\d_\d+/g, '');
+ // if current limit is 0 and should be set to 1 then return "cloning" to the DIV element
+ if (limit === 0 && value === 1) {
+ // add "clone" class to class attribute
+ classes += ' clone';
+ // enable DIV element for climit2 type
+ if (limitType === 2) {
+ enableDrag(true, el);
+ }
+ }
+ // update limit value
+ limit += value;
+ // update climit class name with new limit value
+ classes = classes.replace(/climit\d_\d+/g, 'climit' + limitType + '_' + limit);
// test if limit drops to zero
if (limit <= 0) {
- // no more cloning, cut "clone" from class names
+ // no more cloning, cut out "clone" from class name
classes = classes.replace('clone', '');
- // if limit type is 2 then clone object becomes immovable
+ // if limit type is 2 then disable clone element (it will stay in cell)
if (limitType === 2) {
- // cut "drag" class
- classes = classes.replace('drag', '');
- // remove attached event listener from source element
- registerEvents(objOld, false);
- // set cursor style to auto
- objOld.style.cursor = 'auto';
+ // disable source DIV element
+ enableDrag(false, el);
// call event.clonedEnd2 handler
REDIPS.drag.event.clonedEnd2();
}
@@ -2564,12 +2600,8 @@ REDIPS.drag = (function () {
REDIPS.drag.event.clonedEnd1();
}
}
- // return "climit" class but with decreased limit_number
- else {
- classes = classes + ' climit' + limitType + '_' + limit;
- }
// normalize spaces and return classes to the clone object
- objOld.className = normalize(classes);
+ el.className = normalize(classes);
}
};
@@ -2669,13 +2701,13 @@ REDIPS.drag = (function () {
regexNoAutoscroll = /\bnoautoscroll\b/i; // regular expression to search "noautoscroll" class name
// set opacity for disabled elements from public property "opacityDisabled"
opacity = REDIPS.drag.style.opacityDisabled;
- // define onmousedown/ondblclick handlers and styles
+ // set styles for enabled DIV element
if (enable_flag === true || enable_flag === 'init') {
borderStyle = REDIPS.drag.style.borderEnabled;
cursor = 'move';
enabled = true;
}
- // else remove event handlers
+ // else set styles for disabled DIV element
else {
borderStyle = REDIPS.drag.style.borderDisabled;
cursor = 'auto';
@@ -2686,13 +2718,11 @@ REDIPS.drag = (function () {
if (el === undefined) {
div = dragContainer.getElementsByTagName('div');
}
- // "type" parameter is not "subtree" and "el" is string - assuming el is id of one element to enable/disable
- // e.g. enableDrag(true, 'drag1')
+ // "el" is string (CSS selector) - it can collect one DIV element (like "#d12") or many DIV elements (like "#drag1 div")
else if (typeof(el) === 'string') {
div = document.querySelectorAll(el);
}
- // prepare array with one div element
- // e.g. enableDrag(true, el)
+ // prepare array with one div element if el is reference of DIV element
else {
div[0] = el;
}
@@ -2749,11 +2779,11 @@ REDIPS.drag = (function () {
}
// prepare scrollable container areas
scrollContainer[j] = {
- div : div[i], // reference to the scrollable container
- offset : cb, // box offset of the scrollable container
- midstX : (cb[1] + cb[3]) / 2, // middle X
- midstY : (cb[0] + cb[2]) / 2, // middle Y
- autoscroll : autoscroll // autoscroll enabled or disabled (true or false)
+ div : div[i], // reference to the scrollable container
+ offset : cb, // box offset of the scrollable container
+ midstX : (cb[1] + cb[3]) / 2, // middle X
+ midstY : (cb[0] + cb[2]) / 2, // middle Y
+ autoscroll : autoscroll // autoscroll enabled or disabled (true or false)
};
// search for tables inside scrollable container
tbls = div[i].getElementsByTagName('table');
@@ -4134,17 +4164,20 @@ REDIPS.drag = (function () {
*/
deleteCloned : deleteCloned,
/**
- * Object has boolean properties to enable / disable cloning DIV elements or table rows with shift key.
- * Just press SHIFT key and try to drag DIV element / row.
+ * Object has boolean properties to enable cloning DIV elements or table rows with shift key and to enable returning cloned DIV elements to its source.
* Instead of moving, DIV element / row will be cloned and ready for dragging.
+ * Just press SHIFT key and try to drag DIV element / row.
+ * On the other hand, with clone.sendBack property set to true, cloned DIV element will be deleted when dropped to the cell containing its source clone element.
+ * If exists, "climit" class will be updated (increased by 1).
* <ul>
- * <li>{Boolean} cloneKey.div - If set to true, all DIV elements on tables could be cloned with pressed SHIFT key. Default is false</li>
- * <li>{Boolean} cloneKey.row - If set to true, table rows could be cloned with pressed SHIFT key. Default is false</li>
+ * <li>{Boolean} clone.keyDiv - If set to true, all DIV elements on tables could be cloned with pressed SHIFT key. Default is false</li>
+ * <li>{Boolean} clone.keyRow - If set to true, table rows could be cloned with pressed SHIFT key. Default is false</li>
+ * <li>{Boolean} clone.sendBack - If set to true, cloned element can be returned to its source. Default is false</li>
* </ul>
* @type Object
- * @name REDIPS.drag#cloneKey
+ * @name REDIPS.drag#clone
*/
- cloneKey : cloneKey,
+ clone : clone,
/**
* Object contains animation pause, step and animation shift drop option.
* <ul>

0 comments on commit 02e8be3

Please sign in to comment.