3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js">// private
\r
10 // This is a support class used internally by the Grid components
\r
11 Ext.grid.HeaderDragZone = Ext.extend(Ext.dd.DragZone, {
\r
14 constructor : function(grid, hd, hd2){
\r
16 this.view = grid.getView();
\r
17 this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
\r
18 Ext.grid.HeaderDragZone.superclass.constructor.call(this, hd);
\r
20 this.setHandleElId(Ext.id(hd));
\r
21 this.setOuterHandleElId(Ext.id(hd2));
\r
23 this.scroll = false;
\r
26 getDragData : function(e){
\r
27 var t = Ext.lib.Event.getTarget(e);
\r
28 var h = this.view.findHeaderCell(t);
\r
30 return {ddel: h.firstChild, header:h};
\r
35 onInitDrag : function(e){
\r
36 this.view.headersDisabled = true;
\r
37 var clone = this.dragData.ddel.cloneNode(true);
\r
38 clone.id = Ext.id();
\r
39 clone.style.width = Math.min(this.dragData.header.offsetWidth,this.maxDragWidth) + "px";
\r
40 this.proxy.update(clone);
\r
44 afterValidDrop : function(){
\r
46 setTimeout(function(){
\r
47 v.headersDisabled = false;
\r
51 afterInvalidDrop : function(){
\r
53 setTimeout(function(){
\r
54 v.headersDisabled = false;
\r
60 // This is a support class used internally by the Grid components
\r
61 Ext.grid.HeaderDropZone = Ext.extend(Ext.dd.DropZone, {
\r
62 proxyOffsets : [-4, -9],
\r
63 fly: Ext.Element.fly,
\r
65 constructor : function(grid, hd, hd2){
\r
67 this.view = grid.getView();
\r
68 // split the proxies so they don't interfere with mouse events
\r
69 this.proxyTop = Ext.DomHelper.append(document.body, {
\r
70 cls:"col-move-top", html:" "
\r
72 this.proxyBottom = Ext.DomHelper.append(document.body, {
\r
73 cls:"col-move-bottom", html:" "
\r
75 this.proxyTop.hide = this.proxyBottom.hide = function(){
\r
76 this.setLeftTop(-100,-100);
\r
77 this.setStyle("visibility", "hidden");
\r
79 this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
\r
80 // temporarily disabled
\r
81 //Ext.dd.ScrollManager.register(this.view.scroller.dom);
\r
82 Ext.grid.HeaderDropZone.superclass.constructor.call(this, grid.getGridEl().dom);
\r
85 getTargetFromEvent : function(e){
\r
86 var t = Ext.lib.Event.getTarget(e);
\r
87 var cindex = this.view.findCellIndex(t);
\r
88 if(cindex !== false){
\r
89 return this.view.getHeaderCell(cindex);
\r
93 nextVisible : function(h){
\r
94 var v = this.view, cm = this.grid.colModel;
\r
97 if(!cm.isHidden(v.getCellIndex(h))){
\r
105 prevVisible : function(h){
\r
106 var v = this.view, cm = this.grid.colModel;
\r
109 if(!cm.isHidden(v.getCellIndex(h))){
\r
117 positionIndicator : function(h, n, e){
\r
118 var x = Ext.lib.Event.getPageX(e);
\r
119 var r = Ext.lib.Dom.getRegion(n.firstChild);
\r
120 var px, pt, py = r.top + this.proxyOffsets[1];
\r
121 if((r.right - x) <= (r.right-r.left)/2){
\r
122 px = r.right+this.view.borderWidth;
\r
129 if(this.grid.colModel.isFixed(this.view.getCellIndex(n))){
\r
133 px += this.proxyOffsets[0];
\r
134 this.proxyTop.setLeftTop(px, py);
\r
135 this.proxyTop.show();
\r
136 if(!this.bottomOffset){
\r
137 this.bottomOffset = this.view.mainHd.getHeight();
\r
139 this.proxyBottom.setLeftTop(px, py+this.proxyTop.dom.offsetHeight+this.bottomOffset);
\r
140 this.proxyBottom.show();
\r
144 onNodeEnter : function(n, dd, e, data){
\r
145 if(data.header != n){
\r
146 this.positionIndicator(data.header, n, e);
\r
150 onNodeOver : function(n, dd, e, data){
\r
151 var result = false;
\r
152 if(data.header != n){
\r
153 result = this.positionIndicator(data.header, n, e);
\r
156 this.proxyTop.hide();
\r
157 this.proxyBottom.hide();
\r
159 return result ? this.dropAllowed : this.dropNotAllowed;
\r
162 onNodeOut : function(n, dd, e, data){
\r
163 this.proxyTop.hide();
\r
164 this.proxyBottom.hide();
\r
167 onNodeDrop : function(n, dd, e, data){
\r
168 var h = data.header;
\r
170 var cm = this.grid.colModel;
\r
171 var x = Ext.lib.Event.getPageX(e);
\r
172 var r = Ext.lib.Dom.getRegion(n.firstChild);
\r
173 var pt = (r.right - x) <= ((r.right-r.left)/2) ? "after" : "before";
\r
174 var oldIndex = this.view.getCellIndex(h);
\r
175 var newIndex = this.view.getCellIndex(n);
\r
179 if(oldIndex < newIndex){
\r
182 cm.moveColumn(oldIndex, newIndex);
\r
189 Ext.grid.GridView.ColumnDragZone = Ext.extend(Ext.grid.HeaderDragZone, {
\r
191 constructor : function(grid, hd){
\r
192 Ext.grid.GridView.ColumnDragZone.superclass.constructor.call(this, grid, hd, null);
\r
193 this.proxy.el.addClass('x-grid3-col-dd');
\r
196 handleMouseDown : function(e){
\r
199 callHandleMouseDown : function(e){
\r
200 Ext.grid.GridView.ColumnDragZone.superclass.handleMouseDown.call(this, e);
\r