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);
45 nextVisible : function(h){
46 var v = this.view, cm = this.grid.colModel;
49 if(!cm.isHidden(v.getCellIndex(h))){
57 prevVisible : function(h){
58 var v = this.view, cm = this.grid.colModel;
61 if(!cm.isHidden(v.getCellIndex(h))){
69 positionIndicator : function(h, n, e){
70 var x = Roo.lib.Event.getPageX(e);
71 var r = Roo.lib.Dom.getRegion(n.firstChild);
72 var px, pt, py = r.top + this.proxyOffsets[1];
73 if((r.right - x) <= (r.right-r.left)/2){
74 px = r.right+this.view.borderWidth;
80 var oldIndex = this.view.getCellIndex(h);
81 var newIndex = this.view.getCellIndex(n);
83 if(this.grid.colModel.isFixed(newIndex)){
87 var locked = this.grid.colModel.isLocked(newIndex);
92 if(oldIndex < newIndex){
95 if(oldIndex == newIndex && (locked == this.grid.colModel.isLocked(oldIndex))){
98 px += this.proxyOffsets[0];
99 this.proxyTop.setLeftTop(px, py);
100 this.proxyTop.show();
101 if(!this.bottomOffset){
102 this.bottomOffset = this.view.mainHd.getHeight();
104 this.proxyBottom.setLeftTop(px, py+this.proxyTop.dom.offsetHeight+this.bottomOffset);
105 this.proxyBottom.show();
109 onNodeEnter : function(n, dd, e, data){
110 if(data.header != n){
111 this.positionIndicator(data.header, n, e);
115 onNodeOver : function(n, dd, e, data){
117 if(data.header != n){
118 result = this.positionIndicator(data.header, n, e);
121 this.proxyTop.hide();
122 this.proxyBottom.hide();
124 return result ? this.dropAllowed : this.dropNotAllowed;
127 onNodeOut : function(n, dd, e, data){
128 this.proxyTop.hide();
129 this.proxyBottom.hide();
132 onNodeDrop : function(n, dd, e, data){
135 var cm = this.grid.colModel;
136 var x = Roo.lib.Event.getPageX(e);
137 var r = Roo.lib.Dom.getRegion(n.firstChild);
138 var pt = (r.right - x) <= ((r.right-r.left)/2) ? "after" : "before";
139 var oldIndex = this.view.getCellIndex(h);
140 var newIndex = this.view.getCellIndex(n);
141 var locked = cm.isLocked(newIndex);
145 if(oldIndex < newIndex){
148 if(oldIndex == newIndex && (locked == cm.isLocked(oldIndex))){
151 cm.setLocked(oldIndex, locked, true);
152 cm.moveColumn(oldIndex, newIndex);
153 this.grid.fireEvent("columnmove", oldIndex, newIndex);