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