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; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-dd-StatusProxy'>/**
19 </span> * @class Ext.dd.StatusProxy
20 * A specialized drag proxy that supports a drop status icon, {@link Ext.Layer} styles and auto-repair. This is the
21 * default drag proxy used by all Ext.dd components.
23 Ext.define('Ext.dd.StatusProxy', {
26 <span id='Ext-dd-StatusProxy-method-constructor'> /**
27 </span> * Creates new StatusProxy.
28 * @param {Object} config (optional) Config object.
30 constructor: function(config){
31 Ext.apply(this, config);
32 this.id = this.id || Ext.id();
33 this.proxy = Ext.createWidget('component', {
37 html: '<div class="' + Ext.baseCSSPrefix + 'dd-drop-icon"></div>' +
38 '<div class="' + Ext.baseCSSPrefix + 'dd-drag-ghost"></div>',
39 cls: Ext.baseCSSPrefix + 'dd-drag-proxy ' + this.dropNotAllowed,
40 shadow: !config || config.shadow !== false,
41 renderTo: document.body
44 this.el = this.proxy.el;
46 this.el.setVisibilityMode(Ext.Element.VISIBILITY);
49 this.ghost = Ext.get(this.el.dom.childNodes[1]);
50 this.dropStatus = this.dropNotAllowed;
52 <span id='Ext-dd-StatusProxy-cfg-dropAllowed'> /**
53 </span> * @cfg {String} [dropAllowed="x-dd-drop-ok"]
54 * The CSS class to apply to the status element when drop is allowed.
56 dropAllowed : Ext.baseCSSPrefix + 'dd-drop-ok',
57 <span id='Ext-dd-StatusProxy-cfg-dropNotAllowed'> /**
58 </span> * @cfg {String} [dropNotAllowed="x-dd-drop-nodrop"]
59 * The CSS class to apply to the status element when drop is not allowed.
61 dropNotAllowed : Ext.baseCSSPrefix + 'dd-drop-nodrop',
63 <span id='Ext-dd-StatusProxy-method-setStatus'> /**
64 </span> * Updates the proxy's visual element to indicate the status of whether or not drop is allowed
65 * over the current target element.
66 * @param {String} cssClass The css class for the new drop status indicator image
68 setStatus : function(cssClass){
69 cssClass = cssClass || this.dropNotAllowed;
70 if(this.dropStatus != cssClass){
71 this.el.replaceCls(this.dropStatus, cssClass);
72 this.dropStatus = cssClass;
76 <span id='Ext-dd-StatusProxy-method-reset'> /**
77 </span> * Resets the status indicator to the default dropNotAllowed value
78 * @param {Boolean} clearGhost True to also remove all content from the ghost, false to preserve it
80 reset : function(clearGhost){
81 this.el.dom.className = Ext.baseCSSPrefix + 'dd-drag-proxy ' + this.dropNotAllowed;
82 this.dropStatus = this.dropNotAllowed;
84 this.ghost.update("");
88 <span id='Ext-dd-StatusProxy-method-update'> /**
89 </span> * Updates the contents of the ghost element
90 * @param {String/HTMLElement} html The html that will replace the current innerHTML of the ghost element, or a
91 * DOM node to append as the child of the ghost element (in which case the innerHTML will be cleared first).
93 update : function(html){
94 if(typeof html == "string"){
95 this.ghost.update(html);
97 this.ghost.update("");
98 html.style.margin = "0";
99 this.ghost.dom.appendChild(html);
101 var el = this.ghost.dom.firstChild;
103 Ext.fly(el).setStyle('float', 'none');
107 <span id='Ext-dd-StatusProxy-method-getEl'> /**
108 </span> * Returns the underlying proxy {@link Ext.Layer}
109 * @return {Ext.Layer} el
115 <span id='Ext-dd-StatusProxy-method-getGhost'> /**
116 </span> * Returns the ghost element
117 * @return {Ext.Element} el
119 getGhost : function(){
123 <span id='Ext-dd-StatusProxy-method-hide'> /**
124 </span> * Hides the proxy
125 * @param {Boolean} clear True to reset the status and clear the ghost contents, false to preserve them
127 hide : function(clear) {
134 <span id='Ext-dd-StatusProxy-method-stop'> /**
135 </span> * Stops the repair animation if it's currently running
138 if(this.anim && this.anim.isAnimated && this.anim.isAnimated()){
143 <span id='Ext-dd-StatusProxy-method-show'> /**
144 </span> * Displays this proxy
148 this.proxy.toFront();
151 <span id='Ext-dd-StatusProxy-method-sync'> /**
152 </span> * Force the Layer to sync its shadow and shim positions to the element
155 this.proxy.el.sync();
158 <span id='Ext-dd-StatusProxy-method-repair'> /**
159 </span> * Causes the proxy to return to its position of origin via an animation. Should be called after an
160 * invalid drop operation by the item being dragged.
161 * @param {Number[]} xy The XY position of the element ([x, y])
162 * @param {Function} callback The function to call after the repair is complete.
163 * @param {Object} scope The scope (<code>this</code> reference) in which the callback function is executed. Defaults to the browser window.
165 repair : function(xy, callback, scope){
166 this.callback = callback;
168 if (xy && this.animRepair !== false) {
169 this.el.addCls(Ext.baseCSSPrefix + 'dd-drag-repair');
170 this.el.hideUnders(true);
171 this.anim = this.el.animate({
172 duration: this.repairDuration || 500,
179 callback: this.afterRepair,
188 afterRepair : function(){
190 if(typeof this.callback == "function"){
191 this.callback.call(this.scope || this);
193 this.callback = null;
198 Ext.destroy(this.ghost, this.proxy, this.el);