Skip to content
Browse files

fixed find_cell() method for cases "lastInRow" and "last" (instead of

using index of first row it's used index of current row and last row)
- thanks to Bruno Jesus
  • Loading branch information...
1 parent 8476de8 commit 705763dcc73a2def2c24d97a80d28c77f9542f97 @dbunic committed May 20, 2012
Showing with 6 additions and 5 deletions.
  1. +1 −0 changes.txt
  2. +1 −1 redips-drag-min.js
  3. +4 −4 redips-drag.js
View
1 changes.txt
@@ -6,6 +6,7 @@ Changes for REDIPS.drag library
- added "clone" and "overwrite" checkboxes to example18
- calling myhandler_cloned placed inside clone_div() method
- added private method reset_styles()
+- fixed find_cell() method for cases "lastInRow" and "last" (instead of using index of first row it's used index of current row and last row) - thanks to Bruno Jesus
4.6.16
- fixed relocate() method - discarded "REDIPS.drag.obj !== from.childNodes[i]" condition from element filter
View
2 redips-drag-min.js
@@ -209,7 +209,7 @@ else{for(i=0;i<tables.length;i++){if(tables[i].className.indexOf(el)>-1){tables[
else if(el&&window.getComputedStyle){val=document.defaultView.getComputedStyle(el,null)[style_name];}
return val;};find_parent=function(tag_name,el,skip){el=el.parentNode;if(skip===undefined){skip=0;}
while(el&&el.nodeName!==tag_name){el=el.parentNode;if(el&&el.nodeName===tag_name&&skip>0){skip--;el=el.parentNode;}}
-return el;};find_cell=function(param,el){var tbl=find_parent('TABLE',el),ri,ci,c;switch(param){case'firstInColumn':ri=0;ci=el.cellIndex;break;case'firstInRow':ri=el.parentNode.rowIndex;ci=0;break;case'lastInColumn':ri=tbl.rows.length-1;ci=el.cellIndex;break;case'lastInRow':ri=el.parentNode.rowIndex;ci=tbl.rows[0].cells.length-1;break;case'last':ri=tbl.rows.length-1;ci=tbl.rows[0].cells.length-1;break;default:ri=ci=0;}
+return el;};find_cell=function(param,el){var tbl=find_parent('TABLE',el),ri,ci,c;switch(param){case'firstInColumn':ri=0;ci=el.cellIndex;break;case'firstInRow':ri=el.parentNode.rowIndex;ci=0;break;case'lastInColumn':ri=tbl.rows.length-1;ci=el.cellIndex;break;case'lastInRow':ri=el.parentNode.rowIndex;ci=tbl.rows[ri].cells.length-1;break;case'last':ri=tbl.rows.length-1;ci=tbl.rows[ri].cells.length-1;break;default:ri=ci=0;}
c=tbl.rows[ri].cells[ci];return[ri,ci,c];};save_content=function(tbl,type){var query='',tbl_start,tbl_end,tbl_rows,cells,tbl_cell,cn,id,r,c,d,JSONobj=[],pname=REDIPS.drag.save_pname;if(typeof(tbl)==='string'){tbl=document.getElementById(tbl);}
if(tbl!==undefined&&typeof(tbl)==='object'&&tbl.nodeName==='TABLE'){tbl_rows=tbl.rows.length;for(r=0;r<tbl_rows;r++){cells=tbl.rows[r].cells.length;for(c=0;c<cells;c++){tbl_cell=tbl.rows[r].cells[c];if(tbl_cell.childNodes.length>0){for(d=0;d<tbl_cell.childNodes.length;d++){cn=tbl_cell.childNodes[d];if(cn.nodeName==='DIV'&&cn.className.indexOf('drag')>-1){query+=pname+'[]='+cn.id+'_'+r+'_'+c+'&';JSONobj.push([cn.id,r,c]);}}}}}
if(type==='json'&&JSONobj.length>0){query=JSON.stringify(JSONobj);}
View
8 redips-drag.js
@@ -2795,15 +2795,15 @@ REDIPS.drag = (function () {
ri = tbl.rows.length - 1;
ci = el.cellIndex;
break;
- // last in row
+ // last in row (cell index for current row)
case 'lastInRow':
ri = el.parentNode.rowIndex;
- ci = tbl.rows[0].cells.length - 1;
+ ci = tbl.rows[ri].cells.length - 1;
break;
- // last in table
+ // last in table (cell index for last row)
case 'last':
ri = tbl.rows.length - 1;
- ci = tbl.rows[0].cells.length - 1;
+ ci = tbl.rows[ri].cells.length - 1;
break;
// define cell reference for first table cell (row and column indexes are 0)
default:

0 comments on commit 705763d

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