Subversion Repositories eFlore/Applications.cel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
27 jpm 1
/*
2
 * Ext.ux.grid.BufferedGridDragZone V0.1
3
 * Copyright(c) 2007, http://www.siteartwork.de
4
 *
5
 * Licensed under the terms of the Open Source LGPL 3.0
6
 * http://www.gnu.org/licenses/lgpl.html
7
 *
8
 * @author Thorsten Suckow-Homberg <ts@siteartwork.de>
9
 */
10
 
11
// private
12
// This is a support class used internally by the Grid components
13
 
14
Ext.namespace('Ext.ux.grid');
15
 
16
Ext.ux.grid.BufferedGridDragZone = function(grid, config){
17
 
18
 
19
 
20
    this.view = grid.getView();
21
    Ext.ux.grid.BufferedGridDragZone.superclass.constructor.call(this, this.view.mainBody.dom, config);
22
 
23
  //  this.addEvents({
24
    //    'startdrag' : true
25
    //});
26
 
27
    if(this.view.lockedBody){
28
        this.setHandleElId(Ext.id(this.view.mainBody.dom));
29
        this.setOuterHandleElId(Ext.id(this.view.lockedBody.dom));
30
    }
31
    this.scroll = false;
32
    this.grid = grid;
33
    this.ddel = document.createElement('div');
34
    this.ddel.className = 'x-grid-dd-wrap';
35
 
36
    this.view.ds.on('beforeselectionsload', this.onBeforeSelectionsLoad, this);
37
    this.view.ds.on('selectionsload',       this.onSelectionsLoad,       this);
38
};
39
 
40
Ext.extend(Ext.ux.grid.BufferedGridDragZone, Ext.dd.DragZone, {
41
    ddGroup : "GridDD",
42
 
43
    isDropValid : true,
44
 
45
    getDragData : function(e)
46
    {
47
        var t = Ext.lib.Event.getTarget(e);
48
        var rowIndex = this.view.findRowIndex(t);
49
        if(rowIndex !== false){
50
            var sm = this.grid.selModel;
51
            if(!sm.isSelected(rowIndex) || e.hasModifier()){
52
                sm.handleMouseDown(this.grid, rowIndex, e);
53
            }
54
            return {grid: this.grid, ddel: this.ddel, rowIndex: rowIndex, selections:sm.getSelections()};
55
        }
56
        return false;
57
    },
58
 
59
    onInitDrag : function(e)
60
    {
61
        this.view.ds.loadSelections(this.grid.selModel.getPendingSelections(true));
62
 
63
        var data = this.dragData;
64
        this.ddel.innerHTML = this.grid.getDragDropText();
65
        this.proxy.update(this.ddel);
66
        // fire start drag?
67
    },
68
 
69
    onBeforeSelectionsLoad : function()
70
    {
71
        this.isDropValid = false;
72
        Ext.fly(this.proxy.el.dom.firstChild).addClass('x-dd-drop-waiting');
73
    },
74
 
75
    onSelectionsLoad : function()
76
    {
77
        this.isDropValid = true;
78
        this.ddel.innerHTML = this.grid.getDragDropText();
79
        Ext.fly(this.proxy.el.dom.firstChild).removeClass('x-dd-drop-waiting');
80
    },
81
 
82
    afterRepair : function()
83
    {
84
        this.dragging = false;
85
    },
86
 
87
    getRepairXY : function(e, data)
88
    {
89
        return false;
90
    },
91
 
92
    onStartDrag : function()
93
    {
94
 
95
    },
96
 
97
    onEndDrag : function(data, e)
98
    {
99
        // fire end drag?
100
    },
101
 
102
    onValidDrop : function(dd, e, id)
103
    {
104
        // fire drag drop?
105
        this.hideProxy();
106
    },
107
 
108
    beforeInvalidDrop : function(e, id)
109
    {
110
 
111
    }
112
});