3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
8 // This is a support class used internally by the Grid components
\r
9 Ext.grid.HeaderDragZone = function(grid, hd, hd2){
\r
11 this.view = grid.getView();
\r
12 this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
\r
13 Ext.grid.HeaderDragZone.superclass.constructor.call(this, hd);
\r
15 this.setHandleElId(Ext.id(hd));
\r
16 this.setOuterHandleElId(Ext.id(hd2));
\r
18 this.scroll = false;
\r
20 Ext.extend(Ext.grid.HeaderDragZone, Ext.dd.DragZone, {
\r
22 getDragData : function(e){
\r
23 var t = Ext.lib.Event.getTarget(e);
\r
24 var h = this.view.findHeaderCell(t);
\r
26 return {ddel: h.firstChild, header:h};
\r
31 onInitDrag : function(e){
\r
32 this.view.headersDisabled = true;
\r
33 var clone = this.dragData.ddel.cloneNode(true);
\r
34 clone.id = Ext.id();
\r
35 clone.style.width = Math.min(this.dragData.header.offsetWidth,this.maxDragWidth) + "px";
\r
36 this.proxy.update(clone);
\r
40 afterValidDrop : function(){
\r
42 setTimeout(function(){
\r
43 v.headersDisabled = false;
\r
47 afterInvalidDrop : function(){
\r
49 setTimeout(function(){
\r
50 v.headersDisabled = false;
\r
56 // This is a support class used internally by the Grid components
\r
57 Ext.grid.HeaderDropZone = function(grid, hd, hd2){
\r
59 this.view = grid.getView();
\r
60 // split the proxies so they don't interfere with mouse events
\r
61 this.proxyTop = Ext.DomHelper.append(document.body, {
\r
62 cls:"col-move-top", html:" "
\r
64 this.proxyBottom = Ext.DomHelper.append(document.body, {
\r
65 cls:"col-move-bottom", html:" "
\r
67 this.proxyTop.hide = this.proxyBottom.hide = function(){
\r
68 this.setLeftTop(-100,-100);
\r
69 this.setStyle("visibility", "hidden");
\r
71 this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
\r
72 // temporarily disabled
\r
73 //Ext.dd.ScrollManager.register(this.view.scroller.dom);
\r
74 Ext.grid.HeaderDropZone.superclass.constructor.call(this, grid.getGridEl().dom);
\r
76 Ext.extend(Ext.grid.HeaderDropZone, Ext.dd.DropZone, {
\r
77 proxyOffsets : [-4, -9],
\r
78 fly: Ext.Element.fly,
\r
80 getTargetFromEvent : function(e){
\r
81 var t = Ext.lib.Event.getTarget(e);
\r
82 var cindex = this.view.findCellIndex(t);
\r
83 if(cindex !== false){
\r
84 return this.view.getHeaderCell(cindex);
\r
88 nextVisible : function(h){
\r
89 var v = this.view, cm = this.grid.colModel;
\r
92 if(!cm.isHidden(v.getCellIndex(h))){
\r
100 prevVisible : function(h){
\r
101 var v = this.view, cm = this.grid.colModel;
\r
104 if(!cm.isHidden(v.getCellIndex(h))){
\r
112 positionIndicator : function(h, n, e){
\r
113 var x = Ext.lib.Event.getPageX(e);
\r
114 var r = Ext.lib.Dom.getRegion(n.firstChild);
\r
115 var px, pt, py = r.top + this.proxyOffsets[1];
\r
116 if((r.right - x) <= (r.right-r.left)/2){
\r
117 px = r.right+this.view.borderWidth;
\r
124 if(this.grid.colModel.isFixed(this.view.getCellIndex(n))){
\r
128 px += this.proxyOffsets[0];
\r
129 this.proxyTop.setLeftTop(px, py);
\r
130 this.proxyTop.show();
\r
131 if(!this.bottomOffset){
\r
132 this.bottomOffset = this.view.mainHd.getHeight();
\r
134 this.proxyBottom.setLeftTop(px, py+this.proxyTop.dom.offsetHeight+this.bottomOffset);
\r
135 this.proxyBottom.show();
\r
139 onNodeEnter : function(n, dd, e, data){
\r
140 if(data.header != n){
\r
141 this.positionIndicator(data.header, n, e);
\r
145 onNodeOver : function(n, dd, e, data){
\r
146 var result = false;
\r
147 if(data.header != n){
\r
148 result = this.positionIndicator(data.header, n, e);
\r
151 this.proxyTop.hide();
\r
152 this.proxyBottom.hide();
\r
154 return result ? this.dropAllowed : this.dropNotAllowed;
\r
157 onNodeOut : function(n, dd, e, data){
\r
158 this.proxyTop.hide();
\r
159 this.proxyBottom.hide();
\r
162 onNodeDrop : function(n, dd, e, data){
\r
163 var h = data.header;
\r
165 var cm = this.grid.colModel;
\r
166 var x = Ext.lib.Event.getPageX(e);
\r
167 var r = Ext.lib.Dom.getRegion(n.firstChild);
\r
168 var pt = (r.right - x) <= ((r.right-r.left)/2) ? "after" : "before";
\r
169 var oldIndex = this.view.getCellIndex(h);
\r
170 var newIndex = this.view.getCellIndex(n);
\r
174 if(oldIndex < newIndex){
\r
177 cm.moveColumn(oldIndex, newIndex);
\r
185 Ext.grid.GridView.ColumnDragZone = function(grid, hd){
\r
186 Ext.grid.GridView.ColumnDragZone.superclass.constructor.call(this, grid, hd, null);
\r
187 this.proxy.el.addClass('x-grid3-col-dd');
\r
190 Ext.extend(Ext.grid.GridView.ColumnDragZone, Ext.grid.HeaderDragZone, {
\r
191 handleMouseDown : function(e){
\r
195 callHandleMouseDown : function(e){
\r
196 Ext.grid.GridView.ColumnDragZone.superclass.handleMouseDown.call(this, e);
\r