2 * Ext JS Library 2.2.1
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
10 // This is a support class used internally by the Grid components
\r
11 Ext.grid.HeaderDragZone = function(grid, hd, hd2){
\r
13 this.view = grid.getView();
\r
14 this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
\r
15 Ext.grid.HeaderDragZone.superclass.constructor.call(this, hd);
\r
17 this.setHandleElId(Ext.id(hd));
\r
18 this.setOuterHandleElId(Ext.id(hd2));
\r
20 this.scroll = false;
\r
22 Ext.extend(Ext.grid.HeaderDragZone, Ext.dd.DragZone, {
\r
24 getDragData : function(e){
\r
25 var t = Ext.lib.Event.getTarget(e);
\r
26 var h = this.view.findHeaderCell(t);
\r
28 return {ddel: h.firstChild, header:h};
\r
33 onInitDrag : function(e){
\r
34 this.view.headersDisabled = true;
\r
35 var clone = this.dragData.ddel.cloneNode(true);
\r
36 clone.id = Ext.id();
\r
37 clone.style.width = Math.min(this.dragData.header.offsetWidth,this.maxDragWidth) + "px";
\r
38 this.proxy.update(clone);
\r
42 afterValidDrop : function(){
\r
44 setTimeout(function(){
\r
45 v.headersDisabled = false;
\r
49 afterInvalidDrop : function(){
\r
51 setTimeout(function(){
\r
52 v.headersDisabled = false;
\r
58 // This is a support class used internally by the Grid components
\r
59 Ext.grid.HeaderDropZone = function(grid, hd, hd2){
\r
61 this.view = grid.getView();
\r
62 // split the proxies so they don't interfere with mouse events
\r
63 this.proxyTop = Ext.DomHelper.append(document.body, {
\r
64 cls:"col-move-top", html:" "
\r
66 this.proxyBottom = Ext.DomHelper.append(document.body, {
\r
67 cls:"col-move-bottom", html:" "
\r
69 this.proxyTop.hide = this.proxyBottom.hide = function(){
\r
70 this.setLeftTop(-100,-100);
\r
71 this.setStyle("visibility", "hidden");
\r
73 this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
\r
74 // temporarily disabled
\r
75 //Ext.dd.ScrollManager.register(this.view.scroller.dom);
\r
76 Ext.grid.HeaderDropZone.superclass.constructor.call(this, grid.getGridEl().dom);
\r
78 Ext.extend(Ext.grid.HeaderDropZone, Ext.dd.DropZone, {
\r
79 proxyOffsets : [-4, -9],
\r
80 fly: Ext.Element.fly,
\r
82 getTargetFromEvent : function(e){
\r
83 var t = Ext.lib.Event.getTarget(e);
\r
84 var cindex = this.view.findCellIndex(t);
\r
85 if(cindex !== false){
\r
86 return this.view.getHeaderCell(cindex);
\r
90 nextVisible : function(h){
\r
91 var v = this.view, cm = this.grid.colModel;
\r
94 if(!cm.isHidden(v.getCellIndex(h))){
\r
102 prevVisible : function(h){
\r
103 var v = this.view, cm = this.grid.colModel;
\r
106 if(!cm.isHidden(v.getCellIndex(h))){
\r
114 positionIndicator : function(h, n, e){
\r
115 var x = Ext.lib.Event.getPageX(e);
\r
116 var r = Ext.lib.Dom.getRegion(n.firstChild);
\r
117 var px, pt, py = r.top + this.proxyOffsets[1];
\r
118 if((r.right - x) <= (r.right-r.left)/2){
\r
119 px = r.right+this.view.borderWidth;
\r
125 var oldIndex = this.view.getCellIndex(h);
\r
126 var newIndex = this.view.getCellIndex(n);
\r
128 if(this.grid.colModel.isFixed(newIndex)){
\r
132 var locked = this.grid.colModel.isLocked(newIndex);
\r
137 if(oldIndex < newIndex){
\r
140 if(oldIndex == newIndex && (locked == this.grid.colModel.isLocked(oldIndex))){
\r
143 px += this.proxyOffsets[0];
\r
144 this.proxyTop.setLeftTop(px, py);
\r
145 this.proxyTop.show();
\r
146 if(!this.bottomOffset){
\r
147 this.bottomOffset = this.view.mainHd.getHeight();
\r
149 this.proxyBottom.setLeftTop(px, py+this.proxyTop.dom.offsetHeight+this.bottomOffset);
\r
150 this.proxyBottom.show();
\r
154 onNodeEnter : function(n, dd, e, data){
\r
155 if(data.header != n){
\r
156 this.positionIndicator(data.header, n, e);
\r
160 onNodeOver : function(n, dd, e, data){
\r
161 var result = false;
\r
162 if(data.header != n){
\r
163 result = this.positionIndicator(data.header, n, e);
\r
166 this.proxyTop.hide();
\r
167 this.proxyBottom.hide();
\r
169 return result ? this.dropAllowed : this.dropNotAllowed;
\r
172 onNodeOut : function(n, dd, e, data){
\r
173 this.proxyTop.hide();
\r
174 this.proxyBottom.hide();
\r
177 onNodeDrop : function(n, dd, e, data){
\r
178 var h = data.header;
\r
180 var cm = this.grid.colModel;
\r
181 var x = Ext.lib.Event.getPageX(e);
\r
182 var r = Ext.lib.Dom.getRegion(n.firstChild);
\r
183 var pt = (r.right - x) <= ((r.right-r.left)/2) ? "after" : "before";
\r
184 var oldIndex = this.view.getCellIndex(h);
\r
185 var newIndex = this.view.getCellIndex(n);
\r
186 var locked = cm.isLocked(newIndex);
\r
190 if(oldIndex < newIndex){
\r
193 if(oldIndex == newIndex && (locked == cm.isLocked(oldIndex))){
\r
196 cm.setLocked(oldIndex, locked, true);
\r
197 cm.moveColumn(oldIndex, newIndex);
\r
198 this.grid.fireEvent("columnmove", oldIndex, newIndex);
\r
206 Ext.grid.GridView.ColumnDragZone = function(grid, hd){
\r
207 Ext.grid.GridView.ColumnDragZone.superclass.constructor.call(this, grid, hd, null);
\r
208 this.proxy.el.addClass('x-grid3-col-dd');
\r
211 Ext.extend(Ext.grid.GridView.ColumnDragZone, Ext.grid.HeaderDragZone, {
\r
212 handleMouseDown : function(e){
\r
216 callHandleMouseDown : function(e){
\r
217 Ext.grid.GridView.ColumnDragZone.superclass.handleMouseDown.call(this, e);
\r