4 * Copyright(c) 2006-2007, Ext JS, LLC.
6 * Originally Released Under LGPL - original licence link has changed is not relivant.
9 * <script type="text/javascript">
12 // This is a support class used internally by the Grid components
13 Roo.grid.HeaderDropZone = function(grid, hd, hd2){
15 this.view = grid.getView();
16 // split the proxies so they don't interfere with mouse events
17 this.proxyTop = Roo.DomHelper.append(document.body, {
18 cls:"col-move-top", html:" "
20 this.proxyBottom = Roo.DomHelper.append(document.body, {
21 cls:"col-move-bottom", html:" "
23 this.proxyTop.hide = this.proxyBottom.hide = function(){
24 this.setLeftTop(-100,-100);
25 this.setStyle("visibility", "hidden");
27 this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
28 // temporarily disabled
29 //Roo.dd.ScrollManager.register(this.view.scroller.dom);
30 Roo.grid.HeaderDropZone.superclass.constructor.call(this, grid.getGridEl().dom);
32 Roo.extend(Roo.grid.HeaderDropZone, Roo.dd.DropZone, {
33 proxyOffsets : [-4, -9],
36 getTargetFromEvent : function(e){
37 var t = Roo.lib.Event.getTarget(e);
38 var cindex = this.view.findCellIndex(t);
40 return this.view.getHeaderCell(cindex);
44 nextVisible : function(h){
45 var v = this.view, cm = this.grid.colModel;
48 if(!cm.isHidden(v.getCellIndex(h))){
56 prevVisible : function(h){
57 var v = this.view, cm = this.grid.colModel;
60 if(!cm.isHidden(v.getCellIndex(h))){
68 positionIndicator : function(h, n, e){
69 var x = Roo.lib.Event.getPageX(e);
70 var r = Roo.lib.Dom.getRegion(n.firstChild);
71 var px, pt, py = r.top + this.proxyOffsets[1];
72 if((r.right - x) <= (r.right-r.left)/2){
73 px = r.right+this.view.borderWidth;
79 var oldIndex = this.view.getCellIndex(h);
80 var newIndex = this.view.getCellIndex(n);
82 if(this.grid.colModel.isFixed(newIndex)){
86 var locked = this.grid.colModel.isLocked(newIndex);
91 if(oldIndex < newIndex){
94 if(oldIndex == newIndex && (locked == this.grid.colModel.isLocked(oldIndex))){
97 px += this.proxyOffsets[0];
98 this.proxyTop.setLeftTop(px, py);
100 if(!this.bottomOffset){
101 this.bottomOffset = this.view.mainHd.getHeight();
103 this.proxyBottom.setLeftTop(px, py+this.proxyTop.dom.offsetHeight+this.bottomOffset);
104 this.proxyBottom.show();
108 onNodeEnter : function(n, dd, e, data){
109 if(data.header != n){
110 this.positionIndicator(data.header, n, e);
114 onNodeOver : function(n, dd, e, data){
116 if(data.header != n){
117 result = this.positionIndicator(data.header, n, e);
120 this.proxyTop.hide();
121 this.proxyBottom.hide();
123 return result ? this.dropAllowed : this.dropNotAllowed;
126 onNodeOut : function(n, dd, e, data){
127 this.proxyTop.hide();
128 this.proxyBottom.hide();
131 onNodeDrop : function(n, dd, e, data){
134 var cm = this.grid.colModel;
135 var x = Roo.lib.Event.getPageX(e);
136 var r = Roo.lib.Dom.getRegion(n.firstChild);
137 var pt = (r.right - x) <= ((r.right-r.left)/2) ? "after" : "before";
138 var oldIndex = this.view.getCellIndex(h);
139 var newIndex = this.view.getCellIndex(n);
140 var locked = cm.isLocked(newIndex);
144 if(oldIndex < newIndex){
147 if(oldIndex == newIndex && (locked == cm.isLocked(oldIndex))){
150 cm.setLocked(oldIndex, locked, true);
151 cm.moveColumn(oldIndex, newIndex);
152 this.grid.fireEvent("columnmove", oldIndex, newIndex);