initial import
[roojs1] / Roo / grid / HeaderDragZone.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11
12 // private
13 // This is a support class used internally by the Grid components
14 Roo.grid.HeaderDragZone = function(grid, hd, hd2){
15     this.grid = grid;
16     this.view = grid.getView();
17     this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
18     Roo.grid.HeaderDragZone.superclass.constructor.call(this, hd);
19     if(hd2){
20         this.setHandleElId(Roo.id(hd));
21         this.setOuterHandleElId(Roo.id(hd2));
22     }
23     this.scroll = false;
24 };
25 Roo.extend(Roo.grid.HeaderDragZone, Roo.dd.DragZone, {
26     maxDragWidth: 120,
27     getDragData : function(e){
28         var t = Roo.lib.Event.getTarget(e);
29         var h = this.view.findHeaderCell(t);
30         if(h){
31             return {ddel: h.firstChild, header:h};
32         }
33         return false;
34     },
35
36     onInitDrag : function(e){
37         this.view.headersDisabled = true;
38         var clone = this.dragData.ddel.cloneNode(true);
39         clone.id = Roo.id();
40         clone.style.width = Math.min(this.dragData.header.offsetWidth,this.maxDragWidth) + "px";
41         this.proxy.update(clone);
42         return true;
43     },
44
45     afterValidDrop : function(){
46         var v = this.view;
47         setTimeout(function(){
48             v.headersDisabled = false;
49         }, 50);
50     },
51
52     afterInvalidDrop : function(){
53         var v = this.view;
54         setTimeout(function(){
55             v.headersDisabled = false;
56         }, 50);
57     }
58 });