From 2707bd5f4852e5db3e5b66f5043cfdc169a22885 Mon Sep 17 00:00:00 2001 From: Cip Date: Wed, 27 Mar 2013 11:30:43 +0200 Subject: [PATCH 1/2] commit --- extensions/DnD.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/DnD.js b/extensions/DnD.js index 38c4c385b..fcba9475a 100644 --- a/extensions/DnD.js +++ b/extensions/DnD.js @@ -56,7 +56,7 @@ define([ if(!this.before && targetRow){ // target before next node if dropped within bottom half of this node // (unless there's no node to target at all) - targetRow = targetRow.nextSibling; + for(targetRow = targetRow.nextSibling; !grid.row(targetRow); targetRow=targetRow.nextSibling) { } } targetRow = targetRow && grid.row(targetRow); From d8f3cc80e38a96c3dd47e3d5c209d63c5bbc8d78 Mon Sep 17 00:00:00 2001 From: Cip Date: Thu, 28 Mar 2013 15:06:19 +0200 Subject: [PATCH 2/2] commit --- extensions/DnD.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/extensions/DnD.js b/extensions/DnD.js index fcba9475a..abba63fb3 100644 --- a/extensions/DnD.js +++ b/extensions/DnD.js @@ -53,10 +53,20 @@ define([ grid = this.grid, store = grid.store; + var after = false; + if(!this.before && targetRow){ // target before next node if dropped within bottom half of this node // (unless there's no node to target at all) - for(targetRow = targetRow.nextSibling; !grid.row(targetRow); targetRow=targetRow.nextSibling) { } + + var afterRow = targetRow; + + for(targetRow = targetRow.nextSibling; !grid.row((targetRow)?targetRow:{}); targetRow=targetRow.nextSibling ) { } + + if(!targetRow) { + targetRow = afterRow; + after = true; + } } targetRow = targetRow && grid.row(targetRow); @@ -68,13 +78,13 @@ define([ // Delegate to onDropInternal or onDropExternal for rest of logic. // These are passed the target item as an additional argument. if(targetSource != sourceSource){ - targetSource.onDropExternal(sourceSource, nodes, copy, target); + targetSource.onDropExternal(sourceSource, nodes, copy, target, after); }else{ - targetSource.onDropInternal(nodes, copy, target); + targetSource.onDropInternal(nodes, copy, target, after); } }); }, - onDropInternal: function(nodes, copy, targetItem){ + onDropInternal: function(nodes, copy, targetItem, after){ var store = this.grid.store, targetSource = this, grid = this.grid, @@ -100,12 +110,13 @@ define([ // otherwise settle for put anyway. // (put will relocate an existing item with the same id, i.e. move). store[copy && store.copy ? "copy" : "put"](object, { - before: targetItem + before: (!after)?targetItem:null, + after : (after)?targetItem:null }); }); }); }, - onDropExternal: function(sourceSource, nodes, copy, targetItem){ + onDropExternal: function(sourceSource, nodes, copy, targetItem, after){ // Note: this default implementation expects that two grids do not // share the same store. There may be more ideal implementations in the // case of two grids using the same store (perhaps differentiated by @@ -135,7 +146,8 @@ define([ // since this coming from another dnd source, always behave as if // it is a new store item if possible, rather than replacing existing. store[store.copy ? "copy" : "put"](object, { - before: targetItem + before: (!after)?targetItem:null, + after : (after)?targetItem:null }); }); });