3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 <div id="cls-Ext.dd.StatusProxy"></div>/**
\r
15 * @class Ext.dd.StatusProxy
\r
16 * A specialized drag proxy that supports a drop status icon, {@link Ext.Layer} styles and auto-repair. This is the
\r
17 * default drag proxy used by all Ext.dd components.
\r
19 * @param {Object} config
\r
21 Ext.dd.StatusProxy = function(config){
\r
22 Ext.apply(this, config);
\r
23 this.id = this.id || Ext.id();
\r
24 this.el = new Ext.Layer({
\r
26 id: this.id, tag: "div", cls: "x-dd-drag-proxy "+this.dropNotAllowed, children: [
\r
27 {tag: "div", cls: "x-dd-drop-icon"},
\r
28 {tag: "div", cls: "x-dd-drag-ghost"}
\r
31 shadow: !config || config.shadow !== false
\r
33 this.ghost = Ext.get(this.el.dom.childNodes[1]);
\r
34 this.dropStatus = this.dropNotAllowed;
\r
37 Ext.dd.StatusProxy.prototype = {
\r
38 <div id="cfg-Ext.dd.StatusProxy-dropAllowed"></div>/**
\r
39 * @cfg {String} dropAllowed
\r
40 * The CSS class to apply to the status element when drop is allowed (defaults to "x-dd-drop-ok").
\r
42 dropAllowed : "x-dd-drop-ok",
\r
43 <div id="cfg-Ext.dd.StatusProxy-dropNotAllowed"></div>/**
\r
44 * @cfg {String} dropNotAllowed
\r
45 * The CSS class to apply to the status element when drop is not allowed (defaults to "x-dd-drop-nodrop").
\r
47 dropNotAllowed : "x-dd-drop-nodrop",
\r
49 <div id="method-Ext.dd.StatusProxy-setStatus"></div>/**
\r
50 * Updates the proxy's visual element to indicate the status of whether or not drop is allowed
\r
51 * over the current target element.
\r
52 * @param {String} cssClass The css class for the new drop status indicator image
\r
54 setStatus : function(cssClass){
\r
55 cssClass = cssClass || this.dropNotAllowed;
\r
56 if(this.dropStatus != cssClass){
\r
57 this.el.replaceClass(this.dropStatus, cssClass);
\r
58 this.dropStatus = cssClass;
\r
62 <div id="method-Ext.dd.StatusProxy-reset"></div>/**
\r
63 * Resets the status indicator to the default dropNotAllowed value
\r
64 * @param {Boolean} clearGhost True to also remove all content from the ghost, false to preserve it
\r
66 reset : function(clearGhost){
\r
67 this.el.dom.className = "x-dd-drag-proxy " + this.dropNotAllowed;
\r
68 this.dropStatus = this.dropNotAllowed;
\r
70 this.ghost.update("");
\r
74 <div id="method-Ext.dd.StatusProxy-update"></div>/**
\r
75 * Updates the contents of the ghost element
\r
76 * @param {String/HTMLElement} html The html that will replace the current innerHTML of the ghost element, or a
\r
77 * DOM node to append as the child of the ghost element (in which case the innerHTML will be cleared first).
\r
79 update : function(html){
\r
80 if(typeof html == "string"){
\r
81 this.ghost.update(html);
\r
83 this.ghost.update("");
\r
84 html.style.margin = "0";
\r
85 this.ghost.dom.appendChild(html);
\r
87 var el = this.ghost.dom.firstChild;
\r
89 Ext.fly(el).setStyle('float', 'none');
\r
93 <div id="method-Ext.dd.StatusProxy-getEl"></div>/**
\r
94 * Returns the underlying proxy {@link Ext.Layer}
\r
95 * @return {Ext.Layer} el
\r
101 <div id="method-Ext.dd.StatusProxy-getGhost"></div>/**
\r
102 * Returns the ghost element
\r
103 * @return {Ext.Element} el
\r
105 getGhost : function(){
\r
109 <div id="method-Ext.dd.StatusProxy-hide"></div>/**
\r
111 * @param {Boolean} clear True to reset the status and clear the ghost contents, false to preserve them
\r
113 hide : function(clear){
\r
120 <div id="method-Ext.dd.StatusProxy-stop"></div>/**
\r
121 * Stops the repair animation if it's currently running
\r
124 if(this.anim && this.anim.isAnimated && this.anim.isAnimated()){
\r
129 <div id="method-Ext.dd.StatusProxy-show"></div>/**
\r
130 * Displays this proxy
\r
136 <div id="method-Ext.dd.StatusProxy-sync"></div>/**
\r
137 * Force the Layer to sync its shadow and shim positions to the element
\r
143 <div id="method-Ext.dd.StatusProxy-repair"></div>/**
\r
144 * Causes the proxy to return to its position of origin via an animation. Should be called after an
\r
145 * invalid drop operation by the item being dragged.
\r
146 * @param {Array} xy The XY position of the element ([x, y])
\r
147 * @param {Function} callback The function to call after the repair is complete
\r
148 * @param {Object} scope The scope in which to execute the callback
\r
150 repair : function(xy, callback, scope){
\r
151 this.callback = callback;
\r
152 this.scope = scope;
\r
153 if(xy && this.animRepair !== false){
\r
154 this.el.addClass("x-dd-drag-repair");
\r
155 this.el.hideUnders(true);
\r
156 this.anim = this.el.shift({
\r
157 duration: this.repairDuration || .5,
\r
161 callback: this.afterRepair,
\r
165 this.afterRepair();
\r
170 afterRepair : function(){
\r
172 if(typeof this.callback == "function"){
\r
173 this.callback.call(this.scope || this);
\r
175 this.callback = null;
\r