4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../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-method-constructor'><span id='Ext-dd-StatusProxy'>/**
19 </span></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 * @param {Object} config
25 Ext.define('Ext.dd.StatusProxy', {
28 constructor: function(config){
29 Ext.apply(this, config);
30 this.id = this.id || Ext.id();
31 this.proxy = Ext.createWidget('component', {
34 html: '<div class="' + Ext.baseCSSPrefix + 'dd-drop-icon"></div>' +
35 '<div class="' + Ext.baseCSSPrefix + 'dd-drag-ghost"></div>',
36 cls: Ext.baseCSSPrefix + 'dd-drag-proxy ' + this.dropNotAllowed,
37 shadow: !config || config.shadow !== false,
38 renderTo: document.body
41 this.el = this.proxy.el;
43 this.el.setVisibilityMode(Ext.core.Element.VISIBILITY);
46 this.ghost = Ext.get(this.el.dom.childNodes[1]);
47 this.dropStatus = this.dropNotAllowed;
49 <span id='Ext-dd-StatusProxy-cfg-dropAllowed'> /**
50 </span> * @cfg {String} dropAllowed
51 * The CSS class to apply to the status element when drop is allowed (defaults to "x-dd-drop-ok").
53 dropAllowed : Ext.baseCSSPrefix + 'dd-drop-ok',
54 <span id='Ext-dd-StatusProxy-cfg-dropNotAllowed'> /**
55 </span> * @cfg {String} dropNotAllowed
56 * The CSS class to apply to the status element when drop is not allowed (defaults to "x-dd-drop-nodrop").
58 dropNotAllowed : Ext.baseCSSPrefix + 'dd-drop-nodrop',
60 <span id='Ext-dd-StatusProxy-method-setStatus'> /**
61 </span> * Updates the proxy's visual element to indicate the status of whether or not drop is allowed
62 * over the current target element.
63 * @param {String} cssClass The css class for the new drop status indicator image
65 setStatus : function(cssClass){
66 cssClass = cssClass || this.dropNotAllowed;
67 if(this.dropStatus != cssClass){
68 this.el.replaceCls(this.dropStatus, cssClass);
69 this.dropStatus = cssClass;
73 <span id='Ext-dd-StatusProxy-method-reset'> /**
74 </span> * Resets the status indicator to the default dropNotAllowed value
75 * @param {Boolean} clearGhost True to also remove all content from the ghost, false to preserve it
77 reset : function(clearGhost){
78 this.el.dom.className = Ext.baseCSSPrefix + 'dd-drag-proxy ' + this.dropNotAllowed;
79 this.dropStatus = this.dropNotAllowed;
81 this.ghost.update("");
85 <span id='Ext-dd-StatusProxy-method-update'> /**
86 </span> * Updates the contents of the ghost element
87 * @param {String/HTMLElement} html The html that will replace the current innerHTML of the ghost element, or a
88 * DOM node to append as the child of the ghost element (in which case the innerHTML will be cleared first).
90 update : function(html){
91 if(typeof html == "string"){
92 this.ghost.update(html);
94 this.ghost.update("");
95 html.style.margin = "0";
96 this.ghost.dom.appendChild(html);
98 var el = this.ghost.dom.firstChild;
100 Ext.fly(el).setStyle('float', 'none');
104 <span id='Ext-dd-StatusProxy-method-getEl'> /**
105 </span> * Returns the underlying proxy {@link Ext.Layer}
106 * @return {Ext.Layer} el
112 <span id='Ext-dd-StatusProxy-method-getGhost'> /**
113 </span> * Returns the ghost element
114 * @return {Ext.core.Element} el
116 getGhost : function(){
120 <span id='Ext-dd-StatusProxy-method-hide'> /**
121 </span> * Hides the proxy
122 * @param {Boolean} clear True to reset the status and clear the ghost contents, false to preserve them
124 hide : function(clear) {
131 <span id='Ext-dd-StatusProxy-method-stop'> /**
132 </span> * Stops the repair animation if it's currently running
135 if(this.anim && this.anim.isAnimated && this.anim.isAnimated()){
140 <span id='Ext-dd-StatusProxy-method-show'> /**
141 </span> * Displays this proxy
145 this.proxy.toFront();
148 <span id='Ext-dd-StatusProxy-method-sync'> /**
149 </span> * Force the Layer to sync its shadow and shim positions to the element
152 this.proxy.el.sync();
155 <span id='Ext-dd-StatusProxy-method-repair'> /**
156 </span> * Causes the proxy to return to its position of origin via an animation. Should be called after an
157 * invalid drop operation by the item being dragged.
158 * @param {Array} xy The XY position of the element ([x, y])
159 * @param {Function} callback The function to call after the repair is complete.
160 * @param {Object} scope The scope (<code>this</code> reference) in which the callback function is executed. Defaults to the browser window.
162 repair : function(xy, callback, scope){
163 this.callback = callback;
165 if (xy && this.animRepair !== false) {
166 this.el.addCls(Ext.baseCSSPrefix + 'dd-drag-repair');
167 this.el.hideUnders(true);
168 this.anim = this.el.animate({
169 duration: this.repairDuration || 500,
176 callback: this.afterRepair,
185 afterRepair : function(){
187 if(typeof this.callback == "function"){
188 this.callback.call(this.scope || this);
190 this.callback = null;
195 Ext.destroy(this.ghost, this.proxy, this.el);