3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.dd.StatusProxy"></div>/**
\r
10 * @class Ext.dd.StatusProxy
\r
11 * A specialized drag proxy that supports a drop status icon, {@link Ext.Layer} styles and auto-repair. This is the
\r
12 * default drag proxy used by all Ext.dd components.
\r
14 * @param {Object} config
\r
16 Ext.dd.StatusProxy = function(config){
\r
17 Ext.apply(this, config);
\r
18 this.id = this.id || Ext.id();
\r
19 this.el = new Ext.Layer({
\r
21 id: this.id, tag: "div", cls: "x-dd-drag-proxy "+this.dropNotAllowed, children: [
\r
22 {tag: "div", cls: "x-dd-drop-icon"},
\r
23 {tag: "div", cls: "x-dd-drag-ghost"}
\r
26 shadow: !config || config.shadow !== false
\r
28 this.ghost = Ext.get(this.el.dom.childNodes[1]);
\r
29 this.dropStatus = this.dropNotAllowed;
\r
32 Ext.dd.StatusProxy.prototype = {
\r
33 <div id="cfg-Ext.dd.StatusProxy-dropAllowed"></div>/**
\r
34 * @cfg {String} dropAllowed
\r
35 * The CSS class to apply to the status element when drop is allowed (defaults to "x-dd-drop-ok").
\r
37 dropAllowed : "x-dd-drop-ok",
\r
38 <div id="cfg-Ext.dd.StatusProxy-dropNotAllowed"></div>/**
\r
39 * @cfg {String} dropNotAllowed
\r
40 * The CSS class to apply to the status element when drop is not allowed (defaults to "x-dd-drop-nodrop").
\r
42 dropNotAllowed : "x-dd-drop-nodrop",
\r
44 <div id="method-Ext.dd.StatusProxy-setStatus"></div>/**
\r
45 * Updates the proxy's visual element to indicate the status of whether or not drop is allowed
\r
46 * over the current target element.
\r
47 * @param {String} cssClass The css class for the new drop status indicator image
\r
49 setStatus : function(cssClass){
\r
50 cssClass = cssClass || this.dropNotAllowed;
\r
51 if(this.dropStatus != cssClass){
\r
52 this.el.replaceClass(this.dropStatus, cssClass);
\r
53 this.dropStatus = cssClass;
\r
57 <div id="method-Ext.dd.StatusProxy-reset"></div>/**
\r
58 * Resets the status indicator to the default dropNotAllowed value
\r
59 * @param {Boolean} clearGhost True to also remove all content from the ghost, false to preserve it
\r
61 reset : function(clearGhost){
\r
62 this.el.dom.className = "x-dd-drag-proxy " + this.dropNotAllowed;
\r
63 this.dropStatus = this.dropNotAllowed;
\r
65 this.ghost.update("");
\r
69 <div id="method-Ext.dd.StatusProxy-update"></div>/**
\r
70 * Updates the contents of the ghost element
\r
71 * @param {String/HTMLElement} html The html that will replace the current innerHTML of the ghost element, or a
\r
72 * DOM node to append as the child of the ghost element (in which case the innerHTML will be cleared first).
\r
74 update : function(html){
\r
75 if(typeof html == "string"){
\r
76 this.ghost.update(html);
\r
78 this.ghost.update("");
\r
79 html.style.margin = "0";
\r
80 this.ghost.dom.appendChild(html);
\r
82 var el = this.ghost.dom.firstChild;
\r
84 Ext.fly(el).setStyle('float', 'none');
\r
88 <div id="method-Ext.dd.StatusProxy-getEl"></div>/**
\r
89 * Returns the underlying proxy {@link Ext.Layer}
\r
90 * @return {Ext.Layer} el
\r
96 <div id="method-Ext.dd.StatusProxy-getGhost"></div>/**
\r
97 * Returns the ghost element
\r
98 * @return {Ext.Element} el
\r
100 getGhost : function(){
\r
104 <div id="method-Ext.dd.StatusProxy-hide"></div>/**
\r
106 * @param {Boolean} clear True to reset the status and clear the ghost contents, false to preserve them
\r
108 hide : function(clear){
\r
115 <div id="method-Ext.dd.StatusProxy-stop"></div>/**
\r
116 * Stops the repair animation if it's currently running
\r
119 if(this.anim && this.anim.isAnimated && this.anim.isAnimated()){
\r
124 <div id="method-Ext.dd.StatusProxy-show"></div>/**
\r
125 * Displays this proxy
\r
131 <div id="method-Ext.dd.StatusProxy-sync"></div>/**
\r
132 * Force the Layer to sync its shadow and shim positions to the element
\r
138 <div id="method-Ext.dd.StatusProxy-repair"></div>/**
\r
139 * Causes the proxy to return to its position of origin via an animation. Should be called after an
\r
140 * invalid drop operation by the item being dragged.
\r
141 * @param {Array} xy The XY position of the element ([x, y])
\r
142 * @param {Function} callback The function to call after the repair is complete.
\r
143 * @param {Object} scope The scope (<code>this</code> reference) in which the callback function is executed. Defaults to the browser window.
\r
145 repair : function(xy, callback, scope){
\r
146 this.callback = callback;
\r
147 this.scope = scope;
\r
148 if(xy && this.animRepair !== false){
\r
149 this.el.addClass("x-dd-drag-repair");
\r
150 this.el.hideUnders(true);
\r
151 this.anim = this.el.shift({
\r
152 duration: this.repairDuration || .5,
\r
156 callback: this.afterRepair,
\r
160 this.afterRepair();
\r
165 afterRepair : function(){
\r
167 if(typeof this.callback == "function"){
\r
168 this.callback.call(this.scope || this);
\r
170 this.callback = null;
\r
174 destroy: function(){
\r
175 Ext.destroy(this.ghost, this.el);
\r