Upgrade to ExtJS 3.3.0 - Released 10/06/2010
[extjs.git] / examples / calendar / src / dd / StatusProxy.js
1 /*!
2  * Ext JS Library 3.3.0
3  * Copyright(c) 2006-2010 Ext JS, Inc.
4  * licensing@extjs.com
5  * http://www.extjs.com/license
6  */
7 /*
8  * @class Ext.calendar.StatusProxy
9  * A specialized drag proxy that supports a drop status icon, {@link Ext.Layer} styles and auto-repair. It also
10  * contains a calendar-specific drag status message containing details about the dragged event's target drop date range.  
11  * This is the default drag proxy used by all calendar views.
12  * @constructor
13  * @param {Object} config
14  */
15 Ext.calendar.StatusProxy = function(config) {
16     Ext.apply(this, config);
17     this.id = this.id || Ext.id();
18     this.el = new Ext.Layer({
19         dh: {
20             id: this.id,
21             cls: 'ext-dd-drag-proxy x-dd-drag-proxy ' + this.dropNotAllowed,
22             cn: [
23             {
24                 cls: 'x-dd-drop-icon'
25             },
26             {
27                 cls: 'ext-dd-ghost-ct',
28                 cn: [
29                 {
30                     cls: 'x-dd-drag-ghost'
31                 },
32                 {
33                     cls: 'ext-dd-msg'
34                 }
35                 ]
36             }
37             ]
38         },
39         shadow: !config || config.shadow !== false
40     });
41     this.ghost = Ext.get(this.el.dom.childNodes[1].childNodes[0]);
42     this.message = Ext.get(this.el.dom.childNodes[1].childNodes[1]);
43     this.dropStatus = this.dropNotAllowed;
44 };
45
46 Ext.extend(Ext.calendar.StatusProxy, Ext.dd.StatusProxy, {
47     /**
48      * @cfg {String} moveEventCls
49      * The CSS class to apply to the status element when an event is being dragged (defaults to 'ext-cal-dd-move').
50      */
51     moveEventCls: 'ext-cal-dd-move',
52     /**
53      * @cfg {String} addEventCls
54      * The CSS class to apply to the status element when drop is not allowed (defaults to 'ext-cal-dd-add').
55      */
56     addEventCls: 'ext-cal-dd-add',
57
58     // inherit docs
59     update: function(html) {
60         if (typeof html == 'string') {
61             this.ghost.update(html);
62         } else {
63             this.ghost.update('');
64             html.style.margin = '0';
65             this.ghost.dom.appendChild(html);
66         }
67         var el = this.ghost.dom.firstChild;
68         if (el) {
69             Ext.fly(el).setStyle('float', 'none').setHeight('auto');
70             Ext.getDom(el).id += '-ddproxy';
71         }
72     },
73
74     /**
75      * Update the calendar-specific drag status message without altering the ghost element.
76      * @param {String} msg The new status message
77      */
78     updateMsg: function(msg) {
79         this.message.update(msg);
80     }
81 });