3
* Copyright(c) 2006-2008, Ext JS, LLC.
6
* http://extjs.com/license
10
* @class Ext.dd.StatusProxy
11
* A specialized drag proxy that supports a drop status icon, {@link Ext.Layer} styles and auto-repair. This is the
12
* default drag proxy used by all Ext.dd components.
14
* @param {Object} config
16
Ext.dd.StatusProxy = function(config){
17
Ext.apply(this, config);
18
this.id = this.id || Ext.id();
19
this.el = new Ext.Layer({
21
id: this.id, tag: "div", cls: "x-dd-drag-proxy "+this.dropNotAllowed, children: [
22
{tag: "div", cls: "x-dd-drop-icon"},
23
{tag: "div", cls: "x-dd-drag-ghost"}
26
shadow: !config || config.shadow !== false
28
this.ghost = Ext.get(this.el.dom.childNodes[1]);
29
this.dropStatus = this.dropNotAllowed;
32
Ext.dd.StatusProxy.prototype = {
34
* @cfg {String} dropAllowed
35
* The CSS class to apply to the status element when drop is allowed (defaults to "x-dd-drop-ok").
37
dropAllowed : "x-dd-drop-ok",
39
* @cfg {String} dropNotAllowed
40
* The CSS class to apply to the status element when drop is not allowed (defaults to "x-dd-drop-nodrop").
42
dropNotAllowed : "x-dd-drop-nodrop",
45
* Updates the proxy's visual element to indicate the status of whether or not drop is allowed
46
* over the current target element.
47
* @param {String} cssClass The css class for the new drop status indicator image
49
setStatus : function(cssClass){
50
cssClass = cssClass || this.dropNotAllowed;
51
if(this.dropStatus != cssClass){
52
this.el.replaceClass(this.dropStatus, cssClass);
53
this.dropStatus = cssClass;
58
* Resets the status indicator to the default dropNotAllowed value
59
* @param {Boolean} clearGhost True to also remove all content from the ghost, false to preserve it
61
reset : function(clearGhost){
62
this.el.dom.className = "x-dd-drag-proxy " + this.dropNotAllowed;
63
this.dropStatus = this.dropNotAllowed;
65
this.ghost.update("");
70
* Updates the contents of the ghost element
71
* @param {String/HTMLElement} html The html that will replace the current innerHTML of the ghost element, or a
72
* DOM node to append as the child of the ghost element (in which case the innerHTML will be cleared first).
74
update : function(html){
75
if(typeof html == "string"){
76
this.ghost.update(html);
78
this.ghost.update("");
79
html.style.margin = "0";
80
this.ghost.dom.appendChild(html);
82
var el = this.ghost.dom.firstChild;
84
Ext.fly(el).setStyle(Ext.isIE ? 'styleFloat' : 'cssFloat', 'none');
89
* Returns the underlying proxy {@link Ext.Layer}
90
* @return {Ext.Layer} el
97
* Returns the ghost element
98
* @return {Ext.Element} el
100
getGhost : function(){
106
* @param {Boolean} clear True to reset the status and clear the ghost contents, false to preserve them
108
hide : function(clear){
116
* Stops the repair animation if it's currently running
119
if(this.anim && this.anim.isAnimated && this.anim.isAnimated()){
125
* Displays this proxy
132
* Force the Layer to sync its shadow and shim positions to the element
139
* Causes the proxy to return to its position of origin via an animation. Should be called after an
140
* invalid drop operation by the item being dragged.
141
* @param {Array} xy The XY position of the element ([x, y])
142
* @param {Function} callback The function to call after the repair is complete
143
* @param {Object} scope The scope in which to execute the callback
145
repair : function(xy, callback, scope){
146
this.callback = callback;
148
if(xy && this.animRepair !== false){
149
this.el.addClass("x-dd-drag-repair");
150
this.el.hideUnders(true);
151
this.anim = this.el.shift({
152
duration: this.repairDuration || .5,
156
callback: this.afterRepair,
165
afterRepair : function(){
167
if(typeof this.callback == "function"){
168
this.callback.call(this.scope || this);
170
this.callback = null;
b'\\ No newline at end of file'