Roo/grid/GridDragZone.js
[roojs1] / Roo / grid / GridDragZone.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.GridDragZone = function(grid, config){
15     this.view = grid.getView();
16     Roo.grid.GridDragZone.superclass.constructor.call(this, this.view.mainBody.dom, config);
17     if(this.view.lockedBody){
18         this.setHandleElId(Roo.id(this.view.mainBody.dom));
19         this.setOuterHandleElId(Roo.id(this.view.lockedBody.dom));
20     }
21     this.scroll = false;
22     this.grid = grid;
23     this.ddel = document.createElement('div');
24     this.ddel.className = 'x-grid-dd-wrap';
25 };
26
27 Roo.extend(Roo.grid.GridDragZone, Roo.dd.DragZone, {
28     ddGroup : "GridDD",
29
30     getDragData : function(e){
31         var t = Roo.lib.Event.getTarget(e);
32         var rowIndex = this.view.findRowIndex(t);
33         if(rowIndex !== false){
34             var sm = this.grid.selModel;
35             
36             if (sm.getSelectedCell && !sm.getSelectedCell()) {
37                 sm.mouseDown(e, t);
38             }
39             
40             //if(!sm.isSelected(rowIndex) || e.hasModifier()){
41               //  
42             //}
43             if (e.hasModifier()){
44                 sm.handleMouseDown(e, t); // non modifier buttons are handled by row select.
45             }
46             
47             Roo.log("getDragData");
48             
49             return {
50                 grid: this.grid,
51                 ddel: this.ddel,
52                 rowIndex: rowIndex,
53                 selections:sm.getSelections ? sm.getSelections() : (
54                     sm.getSelectedCell() ? [ grid.ds.getAt(sm.getSelectedCell()[0]) ] : []
55                 )
56             };
57         }
58         return false;
59     },
60
61     onInitDrag : function(e){
62         var data = this.dragData;
63         this.ddel.innerHTML = this.grid.getDragDropText();
64         this.proxy.update(this.ddel);
65         // fire start drag?
66     },
67
68     afterRepair : function(){
69         this.dragging = false;
70     },
71
72     getRepairXY : function(e, data){
73         return false;
74     },
75
76     onEndDrag : function(data, e){
77         // fire end drag?
78     },
79
80     onValidDrop : function(dd, e, id){
81         // fire drag drop?
82         this.hideProxy();
83     },
84
85     beforeInvalidDrop : function(e, id){
86
87     }
88 });