- onNodeDrop: function(node, dragZone, e, data) {
- if (this.valid) {
- this.invalidateDrop();
- var hd = data.header,
- lastLocation = this.lastLocation,
- fromCt = hd.ownerCt,
- fromIdx = fromCt.items.indexOf(hd), // Container.items is a MixedCollection
- toCt = lastLocation.header.ownerCt,
- toIdx = toCt.items.indexOf(lastLocation.header),
- headerCt = this.headerCt,
- groupCt,
- scrollerOwner;
-
- if (lastLocation.pos === 'after') {
- toIdx++;
- }
-
- // If we are dragging in between two HeaderContainers that have had the lockable
- // mixin injected we will lock/unlock headers in between sections. Note that lockable
- // does NOT currently support grouped headers.
- if (fromCt !== toCt && fromCt.lockableInjected && toCt.lockableInjected && toCt.lockedCt) {
- scrollerOwner = fromCt.up('[scrollerOwner]');
- scrollerOwner.lock(hd, toIdx);
- } else if (fromCt !== toCt && fromCt.lockableInjected && toCt.lockableInjected && fromCt.lockedCt) {
- scrollerOwner = fromCt.up('[scrollerOwner]');
- scrollerOwner.unlock(hd, toIdx);
- } else {
- // If dragging rightwards, then after removal, the insertion index will be one less when moving
- // in between the same container.
- if ((fromCt === toCt) && (toIdx > fromCt.items.indexOf(hd))) {
- toIdx--;
- }
-
- // Remove dragged header from where it was without destroying it or relaying its Container
- if (fromCt !== toCt) {
- fromCt.suspendLayout = true;
- fromCt.remove(hd, false);
- fromCt.suspendLayout = false;
- }
-
- // Dragged the last header out of the fromCt group... The fromCt group must die
- if (fromCt.isGroupHeader) {
- if (!fromCt.items.getCount()) {
- groupCt = fromCt.ownerCt;
- groupCt.suspendLayout = true;
- groupCt.remove(fromCt, false);
- fromCt.el.dom.parentNode.removeChild(fromCt.el.dom);
- groupCt.suspendLayout = false;
- } else {
- fromCt.minWidth = fromCt.getWidth() - hd.getWidth();
- fromCt.setWidth(fromCt.minWidth);
- }
- }