Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / docs / source / Proxy.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5   <title>The source code</title>
6   <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7   <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8   <style type="text/css">
9     .highlight { display: block; background-color: #ddd; }
10   </style>
11   <script type="text/javascript">
12     function highlight() {
13       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
14     }
15   </script>
16 </head>
17 <body onload="prettyPrint(); highlight();">
18   <pre class="prettyprint lang-js"><span id='Ext-panel-Proxy'>/**
19 </span> * A custom drag proxy implementation specific to {@link Ext.panel.Panel}s. This class
20  * is primarily used internally for the Panel's drag drop implementation, and
21  * should never need to be created directly.
22  * @private
23  */
24 Ext.define('Ext.panel.Proxy', {
25
26     alternateClassName: 'Ext.dd.PanelProxy',
27
28 <span id='Ext-panel-Proxy-method-constructor'>    /**
29 </span>     * Creates new panel proxy.
30      * @param {Ext.panel.Panel} panel The {@link Ext.panel.Panel} to proxy for
31      * @param {Object} [config] Config object
32      */
33     constructor: function(panel, config){
34 <span id='Ext-panel-Proxy-property-panel'>        /**
35 </span>         * @property panel
36          * @type Ext.panel.Panel
37          */
38         this.panel = panel;
39         this.id = this.panel.id +'-ddproxy';
40         Ext.apply(this, config);
41     },
42
43 <span id='Ext-panel-Proxy-cfg-insertProxy'>    /**
44 </span>     * @cfg {Boolean} insertProxy
45      * True to insert a placeholder proxy element while dragging the panel, false to drag with no proxy.
46      * Most Panels are not absolute positioned and therefore we need to reserve this space.
47      */
48     insertProxy: true,
49
50     // private overrides
51     setStatus: Ext.emptyFn,
52     reset: Ext.emptyFn,
53     update: Ext.emptyFn,
54     stop: Ext.emptyFn,
55     sync: Ext.emptyFn,
56
57 <span id='Ext-panel-Proxy-method-getEl'>    /**
58 </span>     * Gets the proxy's element
59      * @return {Ext.Element} The proxy's element
60      */
61     getEl: function(){
62         return this.ghost.el;
63     },
64
65 <span id='Ext-panel-Proxy-method-getGhost'>    /**
66 </span>     * Gets the proxy's ghost Panel
67      * @return {Ext.panel.Panel} The proxy's ghost Panel
68      */
69     getGhost: function(){
70         return this.ghost;
71     },
72
73 <span id='Ext-panel-Proxy-method-getProxy'>    /**
74 </span>     * Gets the proxy element. This is the element that represents where the
75      * Panel was before we started the drag operation.
76      * @return {Ext.Element} The proxy's element
77      */
78     getProxy: function(){
79         return this.proxy;
80     },
81
82 <span id='Ext-panel-Proxy-method-hide'>    /**
83 </span>     * Hides the proxy
84      */
85     hide : function(){
86         if (this.ghost) {
87             if (this.proxy) {
88                 this.proxy.remove();
89                 delete this.proxy;
90             }
91
92             // Unghost the Panel, do not move the Panel to where the ghost was
93             this.panel.unghost(null, false);
94             delete this.ghost;
95         }
96     },
97
98 <span id='Ext-panel-Proxy-method-show'>    /**
99 </span>     * Shows the proxy
100      */
101     show: function(){
102         if (!this.ghost) {
103             var panelSize = this.panel.getSize();
104             this.panel.el.setVisibilityMode(Ext.Element.DISPLAY);
105             this.ghost = this.panel.ghost();
106             if (this.insertProxy) {
107                 // bc Panels aren't absolute positioned we need to take up the space
108                 // of where the panel previously was
109                 this.proxy = this.panel.el.insertSibling({cls: Ext.baseCSSPrefix + 'panel-dd-spacer'});
110                 this.proxy.setSize(panelSize);
111             }
112         }
113     },
114
115     // private
116     repair: function(xy, callback, scope) {
117         this.hide();
118         if (typeof callback == &quot;function&quot;) {
119             callback.call(scope || this);
120         }
121     },
122
123 <span id='Ext-panel-Proxy-method-moveProxy'>    /**
124 </span>     * Moves the proxy to a different position in the DOM.  This is typically
125      * called while dragging the Panel to keep the proxy sync'd to the Panel's
126      * location.
127      * @param {HTMLElement} parentNode The proxy's parent DOM node
128      * @param {HTMLElement} [before] The sibling node before which the
129      * proxy should be inserted (defaults to the parent's last child if not
130      * specified)
131      */
132     moveProxy : function(parentNode, before){
133         if (this.proxy) {
134             parentNode.insertBefore(this.proxy.dom, before);
135         }
136     }
137 });</pre>
138 </body>
139 </html>