~cdparra/gelee/trunk

« back to all changes in this revision

Viewing changes to webui/ecosystem/workspace/extjs/docs/source/ColumnDD.html

  • Committer: parra
  • Date: 2010-03-15 15:56:56 UTC
  • Revision ID: svn-v4:ac5bba68-f036-4e09-846e-8f32731cc928:trunk/gelee:1448
merged gelee at svn

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
<head>
 
3
  <title>The source code</title>
 
4
    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
 
5
    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
 
6
</head>
 
7
<body  onload="prettyPrint();">
 
8
    <pre class="prettyprint lang-js">// private
 
9
// This is a support class used internally by the Grid components
 
10
Ext.grid.HeaderDragZone = function(grid, hd, hd2){
 
11
    this.grid = grid;
 
12
    this.view = grid.getView();
 
13
    this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
 
14
    Ext.grid.HeaderDragZone.superclass.constructor.call(this, hd);
 
15
    if(hd2){
 
16
        this.setHandleElId(Ext.id(hd));
 
17
        this.setOuterHandleElId(Ext.id(hd2));
 
18
    }
 
19
    this.scroll = false;
 
20
};
 
21
Ext.extend(Ext.grid.HeaderDragZone, Ext.dd.DragZone, {
 
22
    maxDragWidth: 120,
 
23
    getDragData : function(e){
 
24
        var t = Ext.lib.Event.getTarget(e);
 
25
        var h = this.view.findHeaderCell(t);
 
26
        if(h){
 
27
            return {ddel: h.firstChild, header:h};
 
28
        }
 
29
        return false;
 
30
    },
 
31
 
 
32
    onInitDrag : function(e){
 
33
        this.view.headersDisabled = true;
 
34
        var clone = this.dragData.ddel.cloneNode(true);
 
35
        clone.id = Ext.id();
 
36
        clone.style.width = Math.min(this.dragData.header.offsetWidth,this.maxDragWidth) + "px";
 
37
        this.proxy.update(clone);
 
38
        return true;
 
39
    },
 
40
 
 
41
    afterValidDrop : function(){
 
42
        var v = this.view;
 
43
        setTimeout(function(){
 
44
            v.headersDisabled = false;
 
45
        }, 50);
 
46
    },
 
47
 
 
48
    afterInvalidDrop : function(){
 
49
        var v = this.view;
 
50
        setTimeout(function(){
 
51
            v.headersDisabled = false;
 
52
        }, 50);
 
53
    }
 
54
});
 
55
 
 
56
// private
 
57
// This is a support class used internally by the Grid components
 
58
Ext.grid.HeaderDropZone = function(grid, hd, hd2){
 
59
    this.grid = grid;
 
60
    this.view = grid.getView();
 
61
    // split the proxies so they don't interfere with mouse events
 
62
    this.proxyTop = Ext.DomHelper.append(document.body, {
 
63
        cls:"col-move-top", html:"&#160;"
 
64
    }, true);
 
65
    this.proxyBottom = Ext.DomHelper.append(document.body, {
 
66
        cls:"col-move-bottom", html:"&#160;"
 
67
    }, true);
 
68
    this.proxyTop.hide = this.proxyBottom.hide = function(){
 
69
        this.setLeftTop(-100,-100);
 
70
        this.setStyle("visibility", "hidden");
 
71
    };
 
72
    this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
 
73
    // temporarily disabled
 
74
    //Ext.dd.ScrollManager.register(this.view.scroller.dom);
 
75
    Ext.grid.HeaderDropZone.superclass.constructor.call(this, grid.getGridEl().dom);
 
76
};
 
77
Ext.extend(Ext.grid.HeaderDropZone, Ext.dd.DropZone, {
 
78
    proxyOffsets : [-4, -9],
 
79
    fly: Ext.Element.fly,
 
80
 
 
81
    getTargetFromEvent : function(e){
 
82
        var t = Ext.lib.Event.getTarget(e);
 
83
        var cindex = this.view.findCellIndex(t);
 
84
        if(cindex !== false){
 
85
            return this.view.getHeaderCell(cindex);
 
86
        }
 
87
    },
 
88
 
 
89
    nextVisible : function(h){
 
90
        var v = this.view, cm = this.grid.colModel;
 
91
        h = h.nextSibling;
 
92
        while(h){
 
93
            if(!cm.isHidden(v.getCellIndex(h))){
 
94
                return h;
 
95
            }
 
96
            h = h.nextSibling;
 
97
        }
 
98
        return null;
 
99
    },
 
100
 
 
101
    prevVisible : function(h){
 
102
        var v = this.view, cm = this.grid.colModel;
 
103
        h = h.prevSibling;
 
104
        while(h){
 
105
            if(!cm.isHidden(v.getCellIndex(h))){
 
106
                return h;
 
107
            }
 
108
            h = h.prevSibling;
 
109
        }
 
110
        return null;
 
111
    },
 
112
 
 
113
    positionIndicator : function(h, n, e){
 
114
        var x = Ext.lib.Event.getPageX(e);
 
115
        var r = Ext.lib.Dom.getRegion(n.firstChild);
 
116
        var px, pt, py = r.top + this.proxyOffsets[1];
 
117
        if((r.right - x) <= (r.right-r.left)/2){
 
118
            px = r.right+this.view.borderWidth;
 
119
            pt = "after";
 
120
        }else{
 
121
            px = r.left;
 
122
            pt = "before";
 
123
        }
 
124
 
 
125
        if(this.grid.colModel.isFixed(this.view.getCellIndex(n))){
 
126
            return false;
 
127
        }
 
128
 
 
129
        px +=  this.proxyOffsets[0];
 
130
        this.proxyTop.setLeftTop(px, py);
 
131
        this.proxyTop.show();
 
132
        if(!this.bottomOffset){
 
133
            this.bottomOffset = this.view.mainHd.getHeight();
 
134
        }
 
135
        this.proxyBottom.setLeftTop(px, py+this.proxyTop.dom.offsetHeight+this.bottomOffset);
 
136
        this.proxyBottom.show();
 
137
        return pt;
 
138
    },
 
139
 
 
140
    onNodeEnter : function(n, dd, e, data){
 
141
        if(data.header != n){
 
142
            this.positionIndicator(data.header, n, e);
 
143
        }
 
144
    },
 
145
 
 
146
    onNodeOver : function(n, dd, e, data){
 
147
        var result = false;
 
148
        if(data.header != n){
 
149
            result = this.positionIndicator(data.header, n, e);
 
150
        }
 
151
        if(!result){
 
152
            this.proxyTop.hide();
 
153
            this.proxyBottom.hide();
 
154
        }
 
155
        return result ? this.dropAllowed : this.dropNotAllowed;
 
156
    },
 
157
 
 
158
    onNodeOut : function(n, dd, e, data){
 
159
        this.proxyTop.hide();
 
160
        this.proxyBottom.hide();
 
161
    },
 
162
 
 
163
    onNodeDrop : function(n, dd, e, data){
 
164
        var h = data.header;
 
165
        if(h != n){
 
166
            var cm = this.grid.colModel;
 
167
            var x = Ext.lib.Event.getPageX(e);
 
168
            var r = Ext.lib.Dom.getRegion(n.firstChild);
 
169
            var pt = (r.right - x) <= ((r.right-r.left)/2) ? "after" : "before";
 
170
            var oldIndex = this.view.getCellIndex(h);
 
171
            var newIndex = this.view.getCellIndex(n);
 
172
            if(pt == "after"){
 
173
                newIndex++;
 
174
            }
 
175
            if(oldIndex < newIndex){
 
176
                newIndex--;
 
177
            }
 
178
            cm.moveColumn(oldIndex, newIndex);
 
179
            this.grid.fireEvent("columnmove", oldIndex, newIndex);
 
180
            return true;
 
181
        }
 
182
        return false;
 
183
    }
 
184
});
 
185
 
 
186
 
 
187
Ext.grid.GridView.ColumnDragZone = function(grid, hd){
 
188
    Ext.grid.GridView.ColumnDragZone.superclass.constructor.call(this, grid, hd, null);
 
189
    this.proxy.el.addClass('x-grid3-col-dd');
 
190
};
 
191
 
 
192
Ext.extend(Ext.grid.GridView.ColumnDragZone, Ext.grid.HeaderDragZone, {
 
193
    handleMouseDown : function(e){
 
194
 
 
195
    },
 
196
 
 
197
    callHandleMouseDown : function(e){
 
198
        Ext.grid.GridView.ColumnDragZone.superclass.handleMouseDown.call(this, e);
 
199
    }
 
200
});</pre>    
 
201
</body>
 
202
</html>
 
 
b'\\ No newline at end of file'