3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">// private
\r
9 // This is a support class used internally by the Grid components
\r
10 Ext.grid.HeaderDragZone = function(grid, hd, hd2){
\r
12 this.view = grid.getView();
\r
13 this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
\r
14 Ext.grid.HeaderDragZone.superclass.constructor.call(this, hd);
\r
16 this.setHandleElId(Ext.id(hd));
\r
17 this.setOuterHandleElId(Ext.id(hd2));
\r
19 this.scroll = false;
\r
21 Ext.extend(Ext.grid.HeaderDragZone, Ext.dd.DragZone, {
\r
23 getDragData : function(e){
\r
24 var t = Ext.lib.Event.getTarget(e);
\r
25 var h = this.view.findHeaderCell(t);
\r
27 return {ddel: h.firstChild, header:h};
\r
32 onInitDrag : function(e){
\r
33 this.view.headersDisabled = true;
\r
34 var clone = this.dragData.ddel.cloneNode(true);
\r
35 clone.id = Ext.id();
\r
36 clone.style.width = Math.min(this.dragData.header.offsetWidth,this.maxDragWidth) + "px";
\r
37 this.proxy.update(clone);
\r
41 afterValidDrop : function(){
\r
43 setTimeout(function(){
\r
44 v.headersDisabled = false;
\r
48 afterInvalidDrop : function(){
\r
50 setTimeout(function(){
\r
51 v.headersDisabled = false;
\r
57 // This is a support class used internally by the Grid components
\r
58 Ext.grid.HeaderDropZone = function(grid, hd, hd2){
\r
60 this.view = grid.getView();
\r
61 // split the proxies so they don't interfere with mouse events
\r
62 this.proxyTop = Ext.DomHelper.append(document.body, {
\r
63 cls:"col-move-top", html:" "
\r
65 this.proxyBottom = Ext.DomHelper.append(document.body, {
\r
66 cls:"col-move-bottom", html:" "
\r
68 this.proxyTop.hide = this.proxyBottom.hide = function(){
\r
69 this.setLeftTop(-100,-100);
\r
70 this.setStyle("visibility", "hidden");
\r
72 this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
\r
73 // temporarily disabled
\r
74 //Ext.dd.ScrollManager.register(this.view.scroller.dom);
\r
75 Ext.grid.HeaderDropZone.superclass.constructor.call(this, grid.getGridEl().dom);
\r
77 Ext.extend(Ext.grid.HeaderDropZone, Ext.dd.DropZone, {
\r
78 proxyOffsets : [-4, -9],
\r
79 fly: Ext.Element.fly,
\r
81 getTargetFromEvent : function(e){
\r
82 var t = Ext.lib.Event.getTarget(e);
\r
83 var cindex = this.view.findCellIndex(t);
\r
84 if(cindex !== false){
\r
85 return this.view.getHeaderCell(cindex);
\r
89 nextVisible : function(h){
\r
90 var v = this.view, cm = this.grid.colModel;
\r
93 if(!cm.isHidden(v.getCellIndex(h))){
\r
101 prevVisible : function(h){
\r
102 var v = this.view, cm = this.grid.colModel;
\r
105 if(!cm.isHidden(v.getCellIndex(h))){
\r
113 positionIndicator : function(h, n, e){
\r
114 var x = Ext.lib.Event.getPageX(e);
\r
115 var r = Ext.lib.Dom.getRegion(n.firstChild);
\r
116 var px, pt, py = r.top + this.proxyOffsets[1];
\r
117 if((r.right - x) <= (r.right-r.left)/2){
\r
118 px = r.right+this.view.borderWidth;
\r
125 if(this.grid.colModel.isFixed(this.view.getCellIndex(n))){
\r
129 px += this.proxyOffsets[0];
\r
130 this.proxyTop.setLeftTop(px, py);
\r
131 this.proxyTop.show();
\r
132 if(!this.bottomOffset){
\r
133 this.bottomOffset = this.view.mainHd.getHeight();
\r
135 this.proxyBottom.setLeftTop(px, py+this.proxyTop.dom.offsetHeight+this.bottomOffset);
\r
136 this.proxyBottom.show();
\r
140 onNodeEnter : function(n, dd, e, data){
\r
141 if(data.header != n){
\r
142 this.positionIndicator(data.header, n, e);
\r
146 onNodeOver : function(n, dd, e, data){
\r
147 var result = false;
\r
148 if(data.header != n){
\r
149 result = this.positionIndicator(data.header, n, e);
\r
152 this.proxyTop.hide();
\r
153 this.proxyBottom.hide();
\r
155 return result ? this.dropAllowed : this.dropNotAllowed;
\r
158 onNodeOut : function(n, dd, e, data){
\r
159 this.proxyTop.hide();
\r
160 this.proxyBottom.hide();
\r
163 onNodeDrop : function(n, dd, e, data){
\r
164 var h = data.header;
\r
166 var cm = this.grid.colModel;
\r
167 var x = Ext.lib.Event.getPageX(e);
\r
168 var r = Ext.lib.Dom.getRegion(n.firstChild);
\r
169 var pt = (r.right - x) <= ((r.right-r.left)/2) ? "after" : "before";
\r
170 var oldIndex = this.view.getCellIndex(h);
\r
171 var newIndex = this.view.getCellIndex(n);
\r
175 if(oldIndex < newIndex){
\r
178 cm.moveColumn(oldIndex, newIndex);
\r
179 this.grid.fireEvent("columnmove", oldIndex, newIndex);
\r
187 Ext.grid.GridView.ColumnDragZone = function(grid, hd){
\r
188 Ext.grid.GridView.ColumnDragZone.superclass.constructor.call(this, grid, hd, null);
\r
189 this.proxy.el.addClass('x-grid3-col-dd');
\r
192 Ext.extend(Ext.grid.GridView.ColumnDragZone, Ext.grid.HeaderDragZone, {
\r
193 handleMouseDown : function(e){
\r
197 callHandleMouseDown : function(e){
\r
198 Ext.grid.GridView.ColumnDragZone.superclass.handleMouseDown.call(this, e);
\r