3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
8 * @class Ext.dd.PanelProxy
\r
9 * A custom drag proxy implementation specific to {@link Ext.Panel}s. This class is primarily used internally
\r
10 * for the Panel's drag drop implementation, and should never need to be created directly.
\r
12 * @param panel The {@link Ext.Panel} to proxy for
\r
13 * @param config Configuration options
\r
15 Ext.dd.PanelProxy = function(panel, config){
\r
17 this.id = this.panel.id +'-ddproxy';
\r
18 Ext.apply(this, config);
\r
21 Ext.dd.PanelProxy.prototype = {
\r
23 * @cfg {Boolean} insertProxy True to insert a placeholder proxy element while dragging the panel,
\r
24 * false to drag with no proxy (defaults to true).
\r
28 // private overrides
\r
29 setStatus : Ext.emptyFn,
\r
30 reset : Ext.emptyFn,
\r
31 update : Ext.emptyFn,
\r
36 * Gets the proxy's element
\r
37 * @return {Element} The proxy's element
\r
44 * Gets the proxy's ghost element
\r
45 * @return {Element} The proxy's ghost element
\r
47 getGhost : function(){
\r
52 * Gets the proxy's element
\r
53 * @return {Element} The proxy's element
\r
55 getProxy : function(){
\r
65 this.proxy.remove();
\r
68 this.panel.el.dom.style.display = '';
\r
69 this.ghost.remove();
\r
79 this.ghost = this.panel.createGhost(undefined, undefined, Ext.getBody());
\r
80 this.ghost.setXY(this.panel.el.getXY())
\r
81 if(this.insertProxy){
\r
82 this.proxy = this.panel.el.insertSibling({cls:'x-panel-dd-spacer'});
\r
83 this.proxy.setSize(this.panel.getSize());
\r
85 this.panel.el.dom.style.display = 'none';
\r
90 repair : function(xy, callback, scope){
\r
92 if(typeof callback == "function"){
\r
93 callback.call(scope || this);
\r
98 * Moves the proxy to a different position in the DOM. This is typically called while dragging the Panel
\r
99 * to keep the proxy sync'd to the Panel's location.
\r
100 * @param {HTMLElement} parentNode The proxy's parent DOM node
\r
101 * @param {HTMLElement} before (optional) The sibling node before which the proxy should be inserted (defaults
\r
102 * to the parent's last child if not specified)
\r
104 moveProxy : function(parentNode, before){
\r
106 parentNode.insertBefore(this.proxy.dom, before);
\r
111 // private - DD implementation for Panels
\r
112 Ext.Panel.DD = function(panel, cfg){
\r
113 this.panel = panel;
\r
114 this.dragData = {panel: panel};
\r
115 this.proxy = new Ext.dd.PanelProxy(panel, cfg);
\r
116 Ext.Panel.DD.superclass.constructor.call(this, panel.el, cfg);
\r
117 var h = panel.header;
\r
119 this.setHandleElId(h.id);
\r
121 (h ? h : this.panel.body).setStyle('cursor', 'move');
\r
122 this.scroll = false;
\r
125 Ext.extend(Ext.Panel.DD, Ext.dd.DragSource, {
\r
126 showFrame: Ext.emptyFn,
\r
127 startDrag: Ext.emptyFn,
\r
128 b4StartDrag: function(x, y) {
\r
131 b4MouseDown: function(e) {
\r
132 var x = e.getPageX();
\r
133 var y = e.getPageY();
\r
134 this.autoOffset(x, y);
\r
136 onInitDrag : function(x, y){
\r
137 this.onStartDrag(x, y);
\r
140 createFrame : Ext.emptyFn,
\r
141 getDragEl : function(e){
\r
142 return this.proxy.ghost.dom;
\r
144 endDrag : function(e){
\r
146 this.panel.saveState();
\r
149 autoOffset : function(x, y) {
\r
150 x -= this.startPageX;
\r
151 y -= this.startPageY;
\r
152 this.setDelta(x, y);
\r