PanelDD_wev8.js
4.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
* Ext JS Library 2.0.2
* Copyright(c) 2006-2008, Ext JS, LLC.
* licensing@extjs.com
*
* http://extjs.com/license
*/
/* // Internal developer documentation -- will not show up in API docs
* @class Ext.dd.PanelProxy
* A custom drag proxy implementation specific to {@link Ext.Panel}s. This class is primarily used internally
* for the Panel's drag drop implementation, and should never need to be created directly.
* @constructor
* @param panel The {@link Ext.Panel} to proxy for
* @param config Configuration options
*/
Ext.dd.PanelProxy = function(panel, config){
this.panel = panel;
this.id = this.panel.id +'-ddproxy';
Ext.apply(this, config);
};
Ext.dd.PanelProxy.prototype = {
/**
* @cfg {Boolean} insertProxy True to insert a placeholder proxy element while dragging the panel,
* false to drag with no proxy (defaults to true).
*/
insertProxy : true,
// private overrides
setStatus : Ext.emptyFn,
reset : Ext.emptyFn,
update : Ext.emptyFn,
stop : Ext.emptyFn,
sync: Ext.emptyFn,
/**
* Gets the proxy's element
* @return {Element} The proxy's element
*/
getEl : function(){
return this.ghost;
},
/**
* Gets the proxy's ghost element
* @return {Element} The proxy's ghost element
*/
getGhost : function(){
return this.ghost;
},
/**
* Gets the proxy's element
* @return {Element} The proxy's element
*/
getProxy : function(){
return this.proxy;
},
/**
* Hides the proxy
*/
hide : function(){
if(this.ghost){
if(this.proxy){
this.proxy.remove();
delete this.proxy;
}
this.panel.el.dom.style.display = '';
this.ghost.remove();
delete this.ghost;
}
},
/**
* Shows the proxy
*/
show : function(){
if(!this.ghost){
this.ghost = this.panel.createGhost(undefined, undefined, Ext.getBody());
this.ghost.setXY(this.panel.el.getXY())
if(this.insertProxy){
this.proxy = this.panel.el.insertSibling({cls:'x-panel-dd-spacer'});
this.proxy.setSize(this.panel.getSize());
}
this.panel.el.dom.style.display = 'none';
}
},
// private
repair : function(xy, callback, scope){
this.hide();
if(typeof callback == "function"){
callback.call(scope || this);
}
},
/**
* Moves the proxy to a different position in the DOM. This is typically called while dragging the Panel
* to keep the proxy sync'd to the Panel's location.
* @param {HTMLElement} parentNode The proxy's parent DOM node
* @param {HTMLElement} before (optional) The sibling node before which the proxy should be inserted (defaults
* to the parent's last child if not specified)
*/
moveProxy : function(parentNode, before){
if(this.proxy){
parentNode.insertBefore(this.proxy.dom, before);
}
}
};
// private - DD implementation for Panels
Ext.Panel.DD = function(panel, cfg){
this.panel = panel;
this.dragData = {panel: panel};
this.proxy = new Ext.dd.PanelProxy(panel, cfg);
Ext.Panel.DD.superclass.constructor.call(this, panel.el, cfg);
this.setHandleElId(panel.header.id);
panel.header.setStyle('cursor', 'move');
this.scroll = false;
};
Ext.extend(Ext.Panel.DD, Ext.dd.DragSource, {
showFrame: Ext.emptyFn,
startDrag: Ext.emptyFn,
b4StartDrag: function(x, y) {
this.proxy.show();
},
b4MouseDown: function(e) {
var x = e.getPageX();
var y = e.getPageY();
this.autoOffset(x, y);
},
onInitDrag : function(x, y){
this.onStartDrag(x, y);
return true;
},
createFrame : Ext.emptyFn,
getDragEl : function(e){
return this.proxy.ghost.dom;
},
endDrag : function(e){
this.proxy.hide();
this.panel.saveState();
},
autoOffset : function(x, y) {
x -= this.startPageX;
y -= this.startPageY;
this.setDelta(x, y);
}
});