3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.2.1
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
16 // This is a support class used internally by the Grid components
17 Ext.grid.HeaderDragZone = Ext.extend(Ext.dd.DragZone, {
20 constructor : function(grid, hd, hd2){
22 this.view = grid.getView();
23 this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
24 Ext.grid.HeaderDragZone.superclass.constructor.call(this, hd);
26 this.setHandleElId(Ext.id(hd));
27 this.setOuterHandleElId(Ext.id(hd2));
32 getDragData : function(e){
33 var t = Ext.lib.Event.getTarget(e),
34 h = this.view.findHeaderCell(t);
36 return {ddel: h.firstChild, header:h};
41 onInitDrag : function(e){
42 // keep the value here so we can restore it;
43 this.dragHeadersDisabled = this.view.headersDisabled;
44 this.view.headersDisabled = true;
45 var clone = this.dragData.ddel.cloneNode(true);
47 clone.style.width = Math.min(this.dragData.header.offsetWidth,this.maxDragWidth) + "px";
48 this.proxy.update(clone);
52 afterValidDrop : function(){
56 afterInvalidDrop : function(){
60 completeDrop: function(){
62 disabled = this.dragHeadersDisabled;
63 setTimeout(function(){
64 v.headersDisabled = disabled;
70 // This is a support class used internally by the Grid components
71 Ext.grid.HeaderDropZone = Ext.extend(Ext.dd.DropZone, {
72 proxyOffsets : [-4, -9],
75 constructor : function(grid, hd, hd2){
77 this.view = grid.getView();
78 // split the proxies so they don't interfere with mouse events
79 this.proxyTop = Ext.DomHelper.append(document.body, {
80 cls:"col-move-top", html:" "
82 this.proxyBottom = Ext.DomHelper.append(document.body, {
83 cls:"col-move-bottom", html:" "
85 this.proxyTop.hide = this.proxyBottom.hide = function(){
86 this.setLeftTop(-100,-100);
87 this.setStyle("visibility", "hidden");
89 this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
90 // temporarily disabled
91 //Ext.dd.ScrollManager.register(this.view.scroller.dom);
92 Ext.grid.HeaderDropZone.superclass.constructor.call(this, grid.getGridEl().dom);
95 getTargetFromEvent : function(e){
96 var t = Ext.lib.Event.getTarget(e),
97 cindex = this.view.findCellIndex(t);
99 return this.view.getHeaderCell(cindex);
103 nextVisible : function(h){
104 var v = this.view, cm = this.grid.colModel;
107 if(!cm.isHidden(v.getCellIndex(h))){
115 prevVisible : function(h){
116 var v = this.view, cm = this.grid.colModel;
119 if(!cm.isHidden(v.getCellIndex(h))){
127 positionIndicator : function(h, n, e){
128 var x = Ext.lib.Event.getPageX(e),
129 r = Ext.lib.Dom.getRegion(n.firstChild),
132 py = r.top + this.proxyOffsets[1];
133 if((r.right - x) <= (r.right-r.left)/2){
134 px = r.right+this.view.borderWidth;
141 if(this.grid.colModel.isFixed(this.view.getCellIndex(n))){
145 px += this.proxyOffsets[0];
146 this.proxyTop.setLeftTop(px, py);
147 this.proxyTop.show();
148 if(!this.bottomOffset){
149 this.bottomOffset = this.view.mainHd.getHeight();
151 this.proxyBottom.setLeftTop(px, py+this.proxyTop.dom.offsetHeight+this.bottomOffset);
152 this.proxyBottom.show();
156 onNodeEnter : function(n, dd, e, data){
157 if(data.header != n){
158 this.positionIndicator(data.header, n, e);
162 onNodeOver : function(n, dd, e, data){
164 if(data.header != n){
165 result = this.positionIndicator(data.header, n, e);
168 this.proxyTop.hide();
169 this.proxyBottom.hide();
171 return result ? this.dropAllowed : this.dropNotAllowed;
174 onNodeOut : function(n, dd, e, data){
175 this.proxyTop.hide();
176 this.proxyBottom.hide();
179 onNodeDrop : function(n, dd, e, data){
182 var cm = this.grid.colModel,
183 x = Ext.lib.Event.getPageX(e),
184 r = Ext.lib.Dom.getRegion(n.firstChild),
185 pt = (r.right - x) <= ((r.right-r.left)/2) ? "after" : "before",
186 oldIndex = this.view.getCellIndex(h),
187 newIndex = this.view.getCellIndex(n);
191 if(oldIndex < newIndex){
194 cm.moveColumn(oldIndex, newIndex);
201 Ext.grid.GridView.ColumnDragZone = Ext.extend(Ext.grid.HeaderDragZone, {
203 constructor : function(grid, hd){
204 Ext.grid.GridView.ColumnDragZone.superclass.constructor.call(this, grid, hd, null);
205 this.proxy.el.addClass('x-grid3-col-dd');
208 handleMouseDown : function(e){
211 callHandleMouseDown : function(e){
212 Ext.grid.GridView.ColumnDragZone.superclass.handleMouseDown.call(this, e);